Leading Bitcoin Wallet

Extended Transaction Serialization in Electrum 2.0

Electrum 2.0 introduces an improved way to serialize transactions. This new method allows users to share unsigned or partially signed transactions with other signers or store them in cold storage devices.

The main change in this serialization format is found in the transaction input. Specifically, Electrum expands the pubkey field to include additional information. This expansion enables the wallet to handle transactions that aren’t fully signed yet, making it easier to manage multi-signature setups and cold storage operations.

Extended Public Keys

Standard Bitcoin public keys start with 0x02, 0x03, or 0x04. These are the normal compressed or uncompressed public keys used in Bitcoin transactions.

Extended public keys start with 0xFF, 0xFE, or 0xFD. Electrum uses these to provide more information about the key’s origin and derivation path.

There are three types of extended public keys:

  1. Keys starting with 0xFF are BIP32 extended public keys (xpubs) with their derivation path.
  2. Keys beginning with 0xFE use Electrum’s legacy derivation method, combining a master public key and its derivation path.
  3. Keys starting with 0xFD represent unknown public keys where only the Bitcoin address is known.

Types

  1. BIP32 Derivation (starts with 0xFF): This format consists of an extended public key (xpub) that’s 78 bytes long, followed by the BIP32 derivation path. The derivation path is represented as a series of 4-byte integers, with the total length being twice the number of derivation steps.
  2. Legacy Electrum Derivation (starts with 0xFE): This older format uses a master public key (mpk) that’s 64 bytes long, followed by a 4-byte derivation value. This method is specific to earlier versions of Electrum.
  3. Bitcoin Address Only (starts with 0xFD): This format is used when the full public key isn’t available, but we know the Bitcoin address or its corresponding script hash. It stores the 20-byte hash160 of the output script. This format assumes that the cosigner can provide the actual public key when needed.

These extended formats allow Electrum to handle various wallet types and derivation methods, supporting both modern BIP32-based hierarchical wallets and older Electrum wallet structures. The 0xFD format also provides flexibility when working with partially known transaction data.

Standard Public Keys

Bitcoin uses specific formats to represent public keys. These formats are recognized as standard across the Bitcoin network:

Compressed Public Keys: These start with either 0x02 or 0x03, followed by 32 bytes of data. The starting byte indicates whether the y-coordinate of the public key’s point on the elliptic curve is even (0x02) or odd (0x03).

Uncompressed Public Keys: These begin with 0x04, followed by 64 bytes of data. This format includes both the x and y coordinates of the public key’s point on the elliptic curve.

Table of Contents