How to generate bitcoin address from XPUB

1.7k Views Asked by At

How to generate bitcoin address from XPUB, I am looking for pointers on how to use an XPUB to generate addresses. I would like to perform address generation offline with the XPUB.

2

There are 2 best solutions below

0
On

An Xpub key can be broken into 2 parts.

The first 32 bytes, is the key and the last 32 bytes is the chaincode.

You can use the key part to create addresses by hashing it with ripemd160(sha256(key)) and then encoding the resulting 20 byte hash with Base58 for legacy P2PKH addresses or Bech32 for Segwit P2WPKH addresses.

0
On

I сreated a library for bitcoin address generation from xpub. After installation you can write: