An xPub key, short for extended public key, is a master public key used in HD (Hierarchical Deterministic) wallets. It lets you generate an unlimited sequence of child public keys and wallet addresses from a single root key, without ever exposing or requiring access to your private key.
HD wallets, standardized under Bitcoin Improvement Proposals BIP-32 and BIP-44, work like a key tree. Your seed phrase generates a master private key at the root. From that root, the wallet derives child keys, grandchild keys, and so on, each with its own address. Your xPub key is the public counterpart to the master private key at that tree's root.
Because of how elliptic curve cryptography works, anyone with your xPub key can derive every public address your wallet has ever generated or will generate. They cannot spend from those addresses. But they can watch every transaction across all of them.
This is both a feature and a privacy risk. Think of the xPub key as a glass view into your wallet: read-only, but completely transparent.
The xPub key enables several useful workflows that would otherwise require exposing private keys.
Sharing your xPub key is essentially sharing your complete financial history across every address in that wallet. Anyone who has it can see every deposit, withdrawal, and current balance tied to those addresses.
This is a significant risk if your xPub leaks. An attacker who obtains it cannot steal your funds, but they gain a full picture of your wealth and transaction patterns. That information has real value in targeted social engineering, blackmail, and wrench attacks.
Best practice is to treat your xPub key with nearly the same care as your seed phrase. Do not paste it into web services, share it in chat messages, or store it in plain text files on internet-connected devices.
The xPub key format uses a specific derivation path and address type. As Bitcoin address formats evolved, so did the key prefix conventions. A ypub key generates P2SH-wrapped SegWit addresses (starting with 3). A zpub key generates native SegWit addresses (starting with bc1). The underlying cryptographic mechanism is identical. The prefix simply tells compatible wallets which address format to derive.
Most modern wallets handle these distinctions automatically. You typically only need to know the difference when manually importing a key from one wallet application into another.
https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
https://learnmeabitcoin.com/technical/extended-keys