Home › Glossary › xpub (extended public key)

xpub (extended public key)

Also called: extended public key, xpub key, ypub, zpub, tpub, vpub, upub, xprv, extended key.

An xpub is a BIP 32 extended public key: a public key plus chain code that can derive every address in an account, but can't spend from them.

An xpub, or extended public key, is a public key bundled with a 32-byte chain code. Together they let software derive all the non-hardened child public keys below that point in an HD wallet, so it can generate and watch addresses but can't sign. Its secret counterpart is the xprv.

Format

BIP 32 serializes an extended key as 78 bytes: 4 version bytes, 1 depth byte, a 4-byte parent fingerprint, a 4-byte child number, the 32-byte chain code and the 33-byte key. Adding a Base58Check checksum gives a 111-character string. The version bytes set the first letters:

Prefix (mainnet / testnet) Defined in Typical use
xpub / tpub BIP 32 Any script type
ypub / upub BIP 49 P2SH-wrapped SegWit
zpub / vpub BIP 84 Native SegWit (P2WPKH)

The key inside a zpub and an xpub can be identical; only the label differs. Output descriptors (BIP 380) state the script type explicitly instead, which is why newer standards, including Taproot wallets under BIP 86, simply use xpub.

Privacy and safety

An xpub can't move funds, but it reveals every address and the full balance and history of the account. Share it only with software you trust, such as your own watch-only wallet or a multisig coordinator. An xprv, like a seed phrase, gives full spending power and should never be shared.

Account-level xpubs sit at a derivation path like m/84'/0'/0'. Below that point hardened derivation isn't used, which is what makes address generation from the xpub possible.

BIPs that define xpub (extended public key)

Related terms

  • HD wallet: An HD (hierarchical deterministic) wallet derives a whole tree of keys from one seed, as defined in BIP 32, so a single backup restores every address.
  • Derivation path: A derivation path like m/84'/0'/0'/0/0 locates one key inside an HD wallet: the sequence of child indexes taken from the master key.
  • Hardened derivation: Hardened derivation is a BIP 32 way of deriving child keys that requires the parent private key, written with ' or h, as in m/84'/0'/0'.
  • Output descriptor: An output descriptor is a short text string that says exactly which scripts and addresses a wallet uses: script type, keys and derivation paths.
  • Public key: A public key is a point on the secp256k1 curve derived from a private key. Others use it to verify your signatures, and addresses are built from it.

Learn more

Guides