<p>Check out <code>libbtc</code> (<a href="https://github.com/libbtc/libbtc" rel="nofollow noreferrer">https://github.com/libbtc/libbtc</a>), once compiled, you get a command line application called <code>bitcointool</code>.</p>

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

<p>You can then derive a sub-key from your master with something like...</p>

<pre><code>./bitcointool -command hdderive -keypath m/1 -privkey xprv9s21ZrQH143K3C5hLMq2Upsh8mf9Z1p5C4QuXJkiodSSihp324YnWpFfRjvP7gqocJKz4oakVwZn5cUgRYTHtNRvGqU5DU2Gn8MPM9jHvfC
</code></pre>

<p>(should also work for public key derivation)</p>

<p>Maybe check the docs: <a href="https://github.com/libbtc/libbtc#the-bitcointool-cli" rel="nofollow noreferrer">https://github.com/libbtc/libbtc#the-bitcointool-cli</a></p>

CC BY-SA 3.0
2016-11-08T17:04:42.080Z
2016-11-08T17:04:42.080Z
Jonas Schnelli
<p>I have written two tools that can derive addresses from master public key.  </p>

<p><a href="https://github.com/dan-da/hd-wallet-addrs" rel="nofollow noreferrer">hd-wallet-addrs</a>: 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.</p>

<p><a href="https://github.com/dan-da/hd-wallet-derive" rel="nofollow noreferrer">hd-wallet-derive</a>: 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.</p>

<p><strong>hd-wallet-addrs example for your use case:</strong></p>

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

<pre>
$ ./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     |
+------------------------------------+---------+---------+
</pre>

<p><strong>hd-wallet-derive example for your use case:</strong></p>

<p>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.</p>

<pre>
$ ./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     |
+------------------------------------+---------+
</pre>

<pre>
$ ./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     |
+------------------------------------+---------+
</pre>

CC BY-SA 3.0
2017-08-03T17:23:43.673Z
2017-08-03T17:23:43.673Z
user49396
<p>If related to a BIP32 address (such as generated by Mycelium, Ledger, or Trezor), <a href="https://goochain.net/wallet/" rel="nofollow noreferrer" title="Goochain&#39;s Watch-Only">enter link description here</a> 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.</p>

CC BY-SA 3.0
2016-11-09T11:43:41.367Z
2016-11-09T11:43:41.367Z
cbinrva
<p>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?</p>

<bip32-hd-wallets>
is there a tool to produce addresses given a master public key?
pan
# is there a tool to produce addresses given a master public key?

(Asked by: username_0 on 2016-11-08)

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?

**Tags:** bip32-hd-wallets


---

## 3 answers

### Answer by username_1 on 2016-11-08. Score: 3

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>


---

### Answer by username_2 on 2017-08-03. Score: 3

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

[hd-wallet-addrs](https://github.com/dan-da/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](https://github.com/dan-da/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     |
+------------------------------------+---------+

```


---

### Answer by username_3 on 2016-11-09. Score: 0

If related to a BIP32 address (such as generated by Mycelium, Ledger, or Trezor), [enter link description here](https://goochain.net/wallet/ "Goochain's Watch-Only") 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.


---

