3 min to read.
xpub
An extended public key: a master public key from which all receiving addresses of a wallet account can be derived, without the ability to spend.
What is an xpub?
An xpub, short for extended public key, is a special public key from which all the public keys and addresses of a wallet account can be generated. It allows balances and transactions to be viewed and new receiving addresses to be created, but it cannot be used to spend. The name comes from the fact that such keys, when written out, begin with the letters "xpub".
How it works
Modern wallets are hierarchical deterministic (HD) wallets, a design defined in the Bitcoin standard BIP-32. Starting from a seed, the wallet derives a tree of keys. At each branch of the tree there is an extended private key (xprv), which can derive all private keys below it, and a matching extended public key (xpub), which can derive only the public keys below it.
Because addresses are computed from public keys, software that holds an xpub can calculate every address in that account, in the same order as the wallet itself, without ever having access to a private key. Some wallets show variants that begin with "ypub" or "zpub"; these work the same way and indicate different address formats.
Example
An online shop puts its xpub into its payment software. For each order, the server derives a fresh Bitcoin address, so that incoming payments can be told apart. The private keys remain on a hardware wallet that is never connected to the server. If the server is breached, the attacker cannot move the funds.
Other uses include watch-only wallets, which show the balance of a hardware wallet on a phone, and accounting or tax tools.
Why it matters
An xpub separates the ability to receive and monitor from the ability to spend, which is the basis of many secure setups.
Risks
- Privacy. Whoever has an xpub can see every past and future address of that account, with all balances and transactions. It should be shared only with services that need it.
- An xpub is not sufficient to steal funds. There is one technical caveat: in standard derivation, someone who has the xpub and also obtains a single private key from the same branch can calculate the other private keys in that branch.
- An xpub is not a backup. Only the seed phrase restores a wallet.