<blockquote>
<p><strong>Does anyone know of a good api or library that can be used to derive all addresses from an xpub key?</strong></p>
</blockquote>
<p>I suspect you can do this using the <a href="https://cypherpunks-core.github.io/bitcoinbook/appdx-bx.html" rel="nofollow noreferrer"><code>bx</code></a> tool.</p>
<p>The linked page describes how to create hd public keys and convert those to addresses.</p>
<pre><code>bx seed &gt; seed
bx hd-new &lt; seed &gt; master
bx hd-private --hard &lt; master &gt; account
bx hd-public --index 0 &lt; account | bx hd-to-ec | bx ec-to-address
bx hd-public --index 1 &lt; account | bx hd-to-ec | bx ec-to-address
bx hd-public --index 2 &lt; account | bx hd-to-ec | bx ec-to-address
</code></pre>
<p>The above seems to work for me.</p>
<p>Since <code>bx</code> is supplied as part of <a href="https://github.com/libbitcoin/libbitcoin-explorer" rel="nofollow noreferrer"><code>libbitcoin</code></a>, I imagine that library can be used to produce addresses.</p>
<blockquote>
<p>The libbitcoin toolkit is a set of cross platform C++ libraries for building bitcoin applications. The toolkit consists of several libraries, most of which depend on the foundational libbitcoin library. Each library's repository can be cloned and built using common Automake instructions.</p>
</blockquote>

CC BY-SA 4.0
2022-09-10T10:50:20.470Z
2022-09-10T20:52:24.200Z
2022-09-10T20:52:24.200Z
RedGrittyBrick
<p>Hi I am trying to implement a feature where a user can enter their xpub key and get a list of their transactions and their balance. To do this I think I need to get all the wallet addresses from the xpub key and then loop over them using an api like chain.so</p>
<p>Does anyone know of a good api or library that can be used to derive <em>all</em> addresses from an xpub key?</p>
<p>Also for context I use node js on the server.</p>
<p>Thank you!</p>

<address><xpub>
Is there a way to get all addresses from an xpub key?
user136352
# Is there a way to get all addresses from an xpub key?

(Asked by: username_0 on 2022-09-09)

Hi I am trying to implement a feature where a user can enter their xpub key and get a list of their transactions and their balance. To do this I think I need to get all the wallet addresses from the xpub key and then loop over them using an api like chain.so

Does anyone know of a good api or library that can be used to derive *all* addresses from an xpub key?

Also for context I use node js on the server.

Thank you!

**Tags:** address, xpub


---

## 1 answers

### Answer by username_1 on 2022-09-10. Score: 1

> **Does anyone know of a good api or library that can be used to derive all addresses from an xpub key?**

I suspect you can do this using the [`bx`](https://cypherpunks-core.github.io/bitcoinbook/appdx-bx.html) tool.

The linked page describes how to create hd public keys and convert those to addresses.

```
bx seed > seed
bx hd-new < seed > master
bx hd-private --hard < master > account
bx hd-public --index 0 < account | bx hd-to-ec | bx ec-to-address
bx hd-public --index 1 < account | bx hd-to-ec | bx ec-to-address
bx hd-public --index 2 < account | bx hd-to-ec | bx ec-to-address

```

The above seems to work for me.

Since `bx` is supplied as part of [`libbitcoin`](https://github.com/libbitcoin/libbitcoin-explorer), I imagine that library can be used to produce addresses.

> The libbitcoin toolkit is a set of cross platform C++ libraries for building bitcoin applications. The toolkit consists of several libraries, most of which depend on the foundational libbitcoin library. Each library's repository can be cloned and built using common Automake instructions.


---

