Protocols

BIP49: nested SegWit (P2WPKH-in-P2SH)

Last reviewed 1 December 2026.

Safety: Never type or paste a real recovery phrase, passphrase, or wallet backup into a website, chat, or any tool you do not fully control and trust. Address examples on this page come from published official test vectors.

BIP49 is the derivation scheme for Bitcoin accounts that use P2WPKH nested in P2SH — often called nested SegWit or P2SH-SegWit. These addresses typically start with 3 on Bitcoin mainnet. They pay to a SegWit script, but wrap it inside a familiar P2SH output so older software can still send to them.

The path shape is the same as BIP44. Only the purpose number, the way the address is built, and the extended-key prefix change.

The path

BIP49 uses:

m / 49' / coin_type' / account' / change / address_index

Purpose is 49'. Coin type, account, change, and index follow BIP44: coin type and account are hardened, change 0 is the external (receiving) chain, change 1 is internal (change), and addresses are numbered from 0. For Bitcoin mainnet the first receiving address of the first account is therefore m/49'/0'/0'/0/0.

A wallet that only scans purpose 44' will not discover a BIP49 account. The two trees do not overlap, which is the point of the BIP43 purpose field. If you previously used nested SegWit and then restore in a wallet that only looks for legacy or native SegWit addresses, the BIP49 funds will appear to be missing until the wallet scans 49'.

How the address is built

After the public key is derived along that path, BIP49 wraps it as defined in BIP141:

  • The witness program is a P2WPKH spend of the 20-byte key hash
  • The scriptSig is 0 <20-byte-key-hash>
  • The scriptPubKey is HASH160 <20-byte-script-hash> EQUAL

The result is a P2SH address. On Bitcoin mainnet that usually means an address starting with 3. The same prefix is also used for other P2SH outputs, including many multisig addresses that are not BIP49. Seeing a 3… address does not, by itself, prove that the key was derived with purpose 49'.

Extended keys: ypub and yprv

When serializing extended keys for this scheme, BIP49 uses different version bytes from BIP32's xpub and xprv:

  • Mainnet public: 0x049d7cb2 (ypub)
  • Mainnet private: 0x049d7878 (yprv)
  • Testnet public: 0x044a5262 (upub)
  • Testnet private: 0x044a4e28 (uprv)

BIP49 points to SLIP-0132 for additional registered version bytes. The ypub prefix is a convention that tells a consumer "treat these keys as BIP49 nested SegWit," which avoids having to scan both the P2PKH and P2WPKH-in-P2SH address spaces for the same key.

An xpub and a ypub can represent the same underlying key material with different version bytes. They are not casual labels you can swap without changing how a wallet interprets the script type. Mixing them is a common reason a watch-only restore looks empty.

Official test vector

SLIP-0132 publishes a worked example using the public BIP39 test mnemonic abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about with no passphrase. Under that vector:

  • The BIP49 account node is m/49'/0'/0'
  • The first receiving address, at m/49'/0'/0'/0/0, is:

Public test vector, never use for funds.

37VucYSaXLCAsxYyAPfbSi9eh4iEcbShgf

That mnemonic and address are public test data. They are not a wallet for storing funds, and they are not an invitation to type a real recovery phrase into a website.

Why nested SegWit has its own purpose

SegWit introduced a more efficient way to spend a key, but not every wallet and service could send to a native Bech32 address on day one. Nested SegWit was the compatibility compromise: the spend is a witness spend, yet the address still looks like P2SH, which older senders already understood.

Without a dedicated purpose, a wallet given only an account xpub would not know whether to build a legacy P2PKH address or a P2SH-wrapped SegWit address from the same key. BIP49's answer is a new purpose (49') and a new extended-key prefix (ypub), so accounts used for this script type can be detected and handled on their own.

The scheme is less visible in new wallets than it used to be, because native SegWit and Taproot are now widely supported. It remains important for restores. Plenty of existing funds still sit on 3… nested-SegWit addresses derived under 49'.

SLIP-0132 also publishes the account extended keys for the same test mnemonic: the ypub and yprv at m/49'/0'/0' are part of that official vector, alongside the first address quoted above.

Restore pitfalls

Because BIP49 accounts live under a different purpose than BIP44 or BIP84, a complete Bitcoin restore from a seed often has to look in more than one place. A wallet may default to native SegWit today and still need to scan nested SegWit and legacy paths if you used those addresses in the past.

The gap-limit and account-discovery rules of BIP44 still apply to the BIP49 tree. Generating many unused receiving addresses and then restoring in software that stops after 20 gaps can hide later funds, just as it can under BIP44.

FAQ

Is every address that starts with 3 a BIP49 address? No. Plain P2SH, including many multisig setups, also uses that prefix and may use different paths and scripts.

If I have an xpub for a BIP49 account, can I just rename it to ypub? Changing the prefix changes the version bytes a wallet sees. Some tools will then assume a different script type. Use the prefix the scheme specifies, or a descriptor that states the script explicitly.

Will a BIP44-only wallet find my nested SegWit coins? No. It is looking under purpose 44'. BIP49 accounts are under 49'.

How is this different from native SegWit? Native SegWit (BIP84) uses a bc1q Bech32 address and an empty scriptSig. BIP49 wraps the same witness program in P2SH so the on-chain address looks like older P2SH.

See also

Related lesson

Sources