I have master public key of my wallet and I want to generate addresses but without using my current wallet. Is there a tool that does that?


Check out libbtc (https://github.com/libbtc/libbtc), once compiled, you get a command line application called bitcointool.

libbtc compiles without external dependencies (compile it with --disable-net if you don't need libevent based p2p network features).

You can then derive a sub-key from your master with something like...

./bitcointool -command hdderive -keypath m/1 -privkey xprv9s21ZrQH143K3C5hLMq2Upsh8mf9Z1p5C4QuXJkiodSSihp324YnWpFfRjvP7gqocJKz4oakVwZn5cUgRYTHtNRvGqU5DU2Gn8MPM9jHvfC

(should also work for public key derivation)

Maybe check the docs: https://github.com/libbtc/libbtc#the-bitcointool-cli


I have written two tools that can derive addresses from master public key.

hd-wallet-addrs: aimed at finding all addresses that have actually been used (received coins). But it can also also do simple derivation from xpub by using the --gen-only flag. This tool will automatically find both receive and change addresses.

hd-wallet-derive: aimed at simple xprv/xpub derivation. This tool is best for when you have a master xprv and you want to find all derived xprv, privkey/wif, xpub, addresses, or you need to use a custom derivation path.

hd-wallet-addrs example for your use case:

note: --gen-only=3 flag is used, to prevent blockchain lookups and generate 3 receive addresses and 3 change addresses.

$ ./hd-wallet-addrs.php -g --xpub=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --gen-only=3

| addr                               | type    | relpath |
| 1Ge6rDuyCdYVGhXZjcK4251q67GXMKx6xK | Receive | 0/0     |
| 1NVsB73WmDGXSxv77sh9PZENH2x3RRnkDY | Receive | 0/1     |
| 1BkgqiHcvfnQ2wrPN5D2ycrvZas3nibMjC | Receive | 0/2     |
| 12SisoiXLUEbkytL5Pzia1jBY8gJP5XN8D | Change  | 1/0     |
| 1CkvACVpFwkPnMG13w9kXXE9YcsiyL4pcY | Change  | 1/1     |
| 18EmV6cYjVmK3SQshZc92CdD9ByHDdf39v | Change  | 1/2     |

hd-wallet-derive example for your use case:

note: we run the script twice, once for receive addrs and once for change addrs. The --path arg controls this. The --cols arg is used to hide columns we don't care about.

$ ./hd-wallet-derive.php -g --key=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --cols=address,relpath --path=0 --numderive=3
| address                            | relpath |
| 1Ge6rDuyCdYVGhXZjcK4251q67GXMKx6xK | 0/0     |
| 1NVsB73WmDGXSxv77sh9PZENH2x3RRnkDY | 0/1     |
| 1BkgqiHcvfnQ2wrPN5D2ycrvZas3nibMjC | 0/2     |
$ ./hd-wallet-derive.php -g --key=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --cols=address,relpath --path=1 --numderive=3
2017-08-03T10:19:04-07:00 [pid: 28708] [info] -- Generating addresses
| address                            | relpath |
| 12SisoiXLUEbkytL5Pzia1jBY8gJP5XN8D | 1/0     |
| 1CkvACVpFwkPnMG13w9kXXE9YcsiyL4pcY | 1/1     |
| 18EmV6cYjVmK3SQshZc92CdD9ByHDdf39v | 1/2     |

If related to a BIP32 address (such as generated by Mycelium, Ledger, or Trezor), enter link description here wallet service allows you to use your xpub address to derive previously used addresses, although not addresses that haven't seen an on-chain transaction yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.