<p>I don't know of a solution that works out-of-the-box with the requirements you've set. However, you can do some of what you need using some command-line tools available on github.</p>

<p>Pycoin has a key utility which can be used to derive bip0032 addresses given a root. Here's a quick primer on how to use it:</p>

<pre><code>$ git clone http://github.com/richardkiss/pycoin
$ cd pycoin
$ sudo make
$ ku &lt;your xpub or xprv key&gt; -s 0/1/2/3/4
</code></pre>

<p>This will show you the data on the bip0032 key at the path m/0/1/2/3/4. If you add the <code>-a</code> argument, you can get the address at this path. If you add the <code>-W</code> argument instead (using an xprv key), you get the WIF format. This WIF format can be imported to bitcoind and that in turn can be used to notify you and do what you need afterwards. You can delete that key after payment, which should generally leave the number of addresses being watched lower than it might be (though you'll want to purge every once in a while). This could work, but I would NOT recommend it as it's horrible security. Of course, that's probably why you're forwarding funds to another address right away, so that makes sense.</p>

<p>You're going to have to write some code regardless. bitcore is a fine library for doing HD wallet stuff, but the notification is always the tricky bit.</p>

CC BY-SA 3.0
2015-11-02T10:06:41.527Z
Many thanks, these sound like wise words.  My main concern is about the notification part in that I'd like bitcoind to invoke some node to invoke a websocket layer to speak to the client.  I guess I'm nervous about the scalability of this part, is it feasible for bitcoind to be monitoring 10,000 addresses?
sradforth
CC BY-SA 3.0
2015-11-03T02:50:25.493Z
It's feasible. You'd have to do some testing to find out, though.
Jimmy Song
CC BY-SA 3.0
2015-10-29T21:32:22.160Z
2015-10-29T21:32:22.160Z
Jimmy Song
<p>I want to setup a REST API service that does 3 simple things.  </p>

<ol>
<li>Ask it to generate a new address (ideally from a BIP32 xpub key tree)</li>
<li>Notify my server application when a deposit and confirmation X happens.</li>
<li>Once the deposit is confirmed, forward the funds to another address and invoke a script in PHP or node.</li>
</ol>

<p>I was originally going down the <strong><code>bitcoind walletnotify</code></strong> route but a few issues popped up (namely no HD support, scalability of having 10000's of addresses being monitored on a bitcoind is apparently a bad idea??  Is this true?).</p>

<p>I've therefore been setting up Ubuntu as a server and looking at <code>bitcore + bitcoind</code> with node.js to solve this which is painful on v14.04 for some reason... am I barking up the wrong tree and/or is there an easier approach?  I can't believe I'm the only one who's needing this so feel like I'm missing an obvious trick here as it's like pulling teeth.</p>

<p>I don't want to rely on a 3rd party server because if they disappeared I don't want to risk my business collapsing overnight.  I am happy using 3rd party code base or servers if they are open source though.  I've used blockchain.info's API previously which was excellent but really want an in house solution.</p>

<bitcoind><bitcore><node.js><wallet-notify>
Bitcoin HD wallet forwarder without depending on a 3rd party?
sradforth
# Bitcoin HD wallet forwarder without depending on a 3rd party?

(Asked by: username_0 on 2015-10-27)

I want to setup a REST API service that does 3 simple things.

1. Ask it to generate a new address (ideally from a BIP32 xpub key tree)
2. Notify my server application when a deposit and confirmation X happens.
3. Once the deposit is confirmed, forward the funds to another address and invoke a script in PHP or node.

I was originally going down the **`bitcoind walletnotify`** route but a few issues popped up (namely no HD support, scalability of having 10000's of addresses being monitored on a bitcoind is apparently a bad idea?? Is this true?).

I've therefore been setting up Ubuntu as a server and looking at `bitcore + bitcoind` with node.js to solve this which is painful on v14.04 for some reason... am I barking up the wrong tree and/or is there an easier approach? I can't believe I'm the only one who's needing this so feel like I'm missing an obvious trick here as it's like pulling teeth.

I don't want to rely on a 3rd party server because if they disappeared I don't want to risk my business collapsing overnight. I am happy using 3rd party code base or servers if they are open source though. I've used blockchain.info's API previously which was excellent but really want an in house solution.

**Tags:** bitcoind, bitcore, node.js, wallet-notify


---

## 1 answers

### Answer by username_1 on 2015-10-29. Score: 2

I don't know of a solution that works out-of-the-box with the requirements you've set. However, you can do some of what you need using some command-line tools available on github.

Pycoin has a key utility which can be used to derive bip0032 addresses given a root. Here's a quick primer on how to use it:

```
$ git clone http://github.com/richardkiss/pycoin
$ cd pycoin
$ sudo make
$ ku <your xpub or xprv key> -s 0/1/2/3/4

```

This will show you the data on the bip0032 key at the path m/0/1/2/3/4. If you add the `-a` argument, you can get the address at this path. If you add the `-W` argument instead (using an xprv key), you get the WIF format. This WIF format can be imported to bitcoind and that in turn can be used to notify you and do what you need afterwards. You can delete that key after payment, which should generally leave the number of addresses being watched lower than it might be (though you'll want to purge every once in a while). This could work, but I would NOT recommend it as it's horrible security. Of course, that's probably why you're forwarding funds to another address right away, so that makes sense.

You're going to have to write some code regardless. bitcore is a fine library for doing HD wallet stuff, but the notification is always the tricky bit.

> **Comments:**
> **username_0**: Many thanks, these sound like wise words.  My main concern is about the notification part in that I'd like bitcoind to invoke some node to invoke a websocket layer to speak to the client.  I guess I'm nervous about the scalability of this part, is it feasible for bitcoind to be monitoring 10,000 addresses?  
> **username_1**: It's feasible. You'd have to do some testing to find out, though.  

---

