hd-wallet-derive
hd-wallet-derive is a command-line tool that derives bip32 addresses and private keys for Bitcoin and many altcoins. Derivation reports show privkey (wif encoded), xprv, xpub, and address.
- hd-wallet-derive
- Path Preset examples.
-
Custom Path examples.
- using a private (xprv) key, with default columns
- Deriving change addresses and showing all columns.
- Derive addresses from bip39 mnemonic seed words.
<li> <a rel="nofollow noopener" target="_blank" href="#derive-addresses-from-xpub-key">Derive addresses from xpub key</a> </li> <li> <a rel="nofollow noopener" target="_blank" href="#we-can-derive-segwit-keys">We can derive segwit keys</a></p> <ul dir="auto"> <li> <a rel="nofollow noopener" target="_blank" href="#ypub---p2sh">ypub / p2sh</a> </li> <li> <a rel="nofollow noopener" target="_blank" href="#zpub---bech32">zpub / bech32</a> </li> <li> <a rel="nofollow noopener" target="_blank" href="#derive-addresses-for-a-bitcoin-core-wallet">Derive addresses for a bitcoin-core wallet.</a> </li> </ul> </li> <li> <a rel="nofollow noopener" target="_blank" href="#we-can-easily-change-up-the-columns-in-whatever-order-we-want">We can easily change up the columns in whatever order we want.</a> </li> <li> <a rel="nofollow noopener" target="_blank" href="#let-s-find-what-altcoins-are-supported">Let’s find what altcoins are supported.</a> </li> <li> <a rel="nofollow noopener" target="_blank" href="#we-can-view-altcoin-addresses">We can view altcoin addresses.</a> </li> <li> <a rel="nofollow noopener" target="_blank" href="#we-can-easily-generate-a-new-random-master-key--seed-and-extended-keys-for-any-coin">We can easily generate a new random master key, seed and extended keys for any coin.</a> </li> <li> <a rel="nofollow noopener" target="_blank" href="#key-generation-includes-segwit-keys-and-their-paths">Key generation includes segwit keys and their paths.</a> </li> <li> <a rel="nofollow noopener" target="_blank" href="#we-can-get-results-in-a-variety-of-additional-formats">We can get results in a variety of additional formats</a></p> <ul dir="auto"> <li> <a rel="nofollow noopener" target="_blank" href="#simple-list">simple list</a> </li> <li> <a rel="nofollow noopener" target="_blank" href="#json">json</a> </li> <li> <a rel="nofollow noopener" target="_blank" href="#csv">csv</a> </li> </ul> </li> </ul>
- How address derivation works
- Path Presets
- Path variables
- Segwit notes
- Litecoin notes
- Privacy and Security implications
- Use at your own risk.
- Output formats
- Usage
- Installation and Running.
- Thanks
- Todos
hd-wallet-derive
A command-line tool that derives bip32 addresses and private keys for Bitcoin and many altcoins.
As of version 0.3.2, over 300 altcoins are available, 97 with bip44 path information.
Bitcoin Cash “CashAddr” and Ethereum address types are supported.
As of version 0.4.0, segwit keys and addresses are supported for Bitcoin as
ypub keys with p2sh style addresses and zpub keys with bech32 addresses.
As of version 0.4.1, Bitcoin-core style key derivation is supported.
See here.
As of version 0.4.3, Preset paths are available for common wallet software.
Derivation reports show privkey (wif encoded), xprv, xpub, and address.
Input can be a xprv key, xpub key, or bip39 mnemonic string (eg 12 words) with
optional password.
This tool can be used in place of your wallet software if it is misbehaving or
if you just want to see more information about your wallet addresses, including
private keys and addresses you haven’t even used yet.
Reports are available in json, plaintext, and html. Columns can be changed or
re-ordered via command-line.
See also: hd-wallet-addrs — a tool for finding hd-wallet addresses that have received funds.
Path Preset examples.
Obtaining a list of preset paths.
Let’s say we want to derive addresses for bitcoin-core software. First, we need to find out the preset
identifier for this software.
$ ./hd-wallet-derive.php --help-presets | head -n 7
+-------------------------+----------------------+-------------------------+------------------+---------------------------+
| id | path | wallet | version | note |
+-------------------------+----------------------+-------------------------+------------------+---------------------------+
| bip44 | m/44'/c'/a'/v/x | Bip44 Compat | n/a | Bip44 |
| bip49 | m/49'/c'/a'/v/x | Bip49 Compat | n/a | Bip49 |
| bip84 | m/84'/c'/a'/v/x | Bip84 Compat | n/a | Bip84 |
| bitcoincore | m/a'/v'/x' | Bitcoin Core | v0.13 and above. | Bip32 fully hardened |
See Path Presets.
If we want only the ids, we could use the command:
$ ./hd-wallet-derive.php --help-presets --format=list
bip44
bip49
bip84
bitcoincore
bither
breadwallet
coinomi
coinomi_bech32
coinomi_p2sh
copay
copay_hardware_multisig
copay_legacy
electrum
electrum_multi
hive
jaxx
ledgerlive
multibit_hd
multibit_hd_44
mycelium
samourai
samourai_bech32
samourai_p2sh
trezor
wasabi
Deriving addresses for bitcoin-core using preset path.
Using a preset means that we do not need to know the bip32 path. We can do:
$ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c --numderive=3 --preset=bitcoincore --cols=path,address
+------------+------------------------------------+
| path | address |
+------------+------------------------------------+
| m/0'/0'/0' | 1JsH5tzm2bphJySSLJ13AbFGP8KqJBYvG7 |
| m/0'/0'/1' | 19in8KwQy2waqzogwnVRvh2gt7EkHDGtwg |
| m/0'/0'/2' | 1CMc7jzi6ewKRzBNSCMkYzY3PU13ck6bxQ |
+------------+------------------------------------+
Deriving Change addresses for bitcoin-core using preset path.
We can use the –path-change flag for this. requires a preset
with variable ‘v’ present in the path.
$ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c --numderive=3 --preset=bitcoincore --cols=path,address --path-change
+------------+------------------------------------+
| path | address |
+------------+------------------------------------+
| m/0'/1'/0' | 1B6q1KTyaa9yLHV2HTZC1rZaSKMG8KNqsp |
| m/0'/1'/1' | 15RF1R9ZaSqgtaTVBDm1ySU5MQ6dZeTpZf |
| m/0'/1'/2' | 1DpzhgrgWuRSnQjvLiZHMG2TAjs86znvjj |
+------------+------------------------------------+
Notice that that 2nd field has changed from 0′ to 1′.
Custom Path examples.
using a private (xprv) key, with default columns
Here we do not specify a bip32 path or a preset, so addresses will be derived directly from
this key.
$ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c --numderive=3
+------+------------------------------------+------------------------------------------------------+
| path | address | privkey |
+------+------------------------------------+------------------------------------------------------+
| m/0 | 1A9X6wjnER55GMpCCsTjn973y56u3zviDe | L4mgN3QEzR9PT6zPeKXGk3xNiGxxkHu4575W9YwBSRV2sRiyjV4g |
| m/1 | 192oE3o29AAoBPQiTYe65kRU2zoBLpEnUm | L1xYoR7VS6vuvkmfRM4ubaH84vRkWKUS2PmYj9DPTS76NQ4NtZP9 |
| m/2 | 1BbtRW5sua3Ewhm8jHAURUiz9t4bw8TQo9 | L21sVq8wutBSQWTzVJVBTeCdkfTgw41dK3PPViZ3Ds2xnMq8RMbK |
+------+------------------------------------+------------------------------------------------------+
Deriving change addresses and showing all columns.
Typically, wallets provide xprv and xpub keys at the wallet root level (eg
m/0/0/0) and then receive addresses and change addresses are available at the
relative paths /0 and /1 respectively.
If this is the case with your wallet, then a command like the following should
work to derive change addresses. Note the –path=1 arg. Change it to –path=0 to
derive receive addresses. In the results below, the addresses are different than
above. This is because the path is different.
Notice also that the first xprv matches the –key argument and has “/” for the
relpath. This row is included because of the –includeroot flag. In this way, we
can easily obtain the xpub key for our xprv key.
$ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c --path=m/1 --cols=all --includeroot...