Expand description
Substrate extrinsic signing payload decoder.
Decodes the opaque payload bytes from a NeedsSign outcome (tag 36,
sign_payload) into structured fields: genesis hash, block hash,
spec version, transaction version, and optional metadata hash.
§Layout
A Substrate V4 extrinsic signing payload is:
[call_data ++ signed_extensions_extra] | spec_version(4) | tx_version(4) | genesis_hash(32) | block_hash(32) [| metadata_hash_option(1 or 33)]The “additional signed” tail has fixed sizes and is always at the end. Everything before it (call data concatenated with extensions extra like era, nonce, tip) is returned as an opaque blob — separating call data from extensions requires runtime metadata.
§Limitations
-
Heuristic, not a security boundary. A malicious app can craft raw bytes where the tail positions produce any
genesis_hash. Use the decoded fields for display/hint purposes only — they are not a guarantee of what the signer will actually commit to. -
Substrate V4 only. Future extrinsic format versions (V5+) may change the additional-signed layout. If decoding fails, callers should fall back to displaying the raw hex payload.
-
Pre-hashed payloads. When the original payload exceeds 256 bytes, the Substrate signing protocol hashes it (blake2b-256) to 32 bytes before signing. If the
payloadfield inNeedsSignis already the 32-byte hash, this function returnsExtrinsicError::PayloadHashed.
No I/O. No threads. WASM-safe.
Structs§
- Decoded
Sign Payload - Decoded fields from a Substrate extrinsic signing payload.
Enums§
- Extrinsic
Error - Errors from extrinsic signing payload decoding.
Functions§
- decode_
sign_ payload - Decode a Substrate extrinsic signing payload into its constituent fields.