BIP32 (Bitcoin HD Wallets)

5.0.0 · active · verified Mon Apr 13

BIP32 is a minimalistic Python implementation of the Bitcoin HD wallet (Hierarchical Deterministic Wallet) specification. The current version is 5.0.0, released in November 2025. The library maintains an active development cycle, with occasional major releases that often introduce breaking changes, typically driven by updates to Python versions or the implementation of stricter sanity checks.

Warnings

Install

Imports

Quickstart

Initializes a BIP32 wallet from a seed and demonstrates deriving extended private and public keys using both list and string-based derivation paths. It also shows how to instantiate from an extended public key for public-only derivation.

from bip32 import BIP32, HARDENED_INDEX

# Create a BIP32 instance from a seed
seed = bytes.fromhex("000102030405060708090a0b0c0d0e0f")
bip32_wallet = BIP32.from_seed(seed)

# Derive a hardened private child key using a list of indices
xpriv_path_list = bip32_wallet.get_xpriv_from_path([1, HARDENED_INDEX, 9998])
print(f"Derived XPRIV (list path): {xpriv_path_list}")

# Derive a hardened private child key using a string path
xpriv_path_str = bip32_wallet.get_xpriv_from_path("m/1/0'/9998")
print(f"Derived XPRIV (string path): {xpriv_path_str}")

# Derive an extended public key (xpub) from a non-hardened path
xpub = bip32_wallet.get_xpub_from_path("m/0/0/0")
print(f"Derived XPUB: {xpub}")

# Instantiate from an existing extended public key (xpub) (can only derive unhardened children)
public_wallet = BIP32.from_xpub(xpub)
child_xpub = public_wallet.get_xpub_from_path("m/0/1")
print(f"Derived child XPUB from XPUB: {child_xpub}")

view raw JSON →