<p>Actually Ive done this.</p>

<p>What I would say is that if you are planning to it your self it requires some amount of time and expertise if you really want to implement a custom solution that can integrate with your web platform. I did some research and in the end this is how I did it.</p>

<p>I use Bitcoind</p>

<p>It runs on a private server well away from the web server.
On the private server there are several encrypted wallets running on different ports under different user accounts each of them runs the RPC deamon that only responds to ssl from the local host.</p>

<p>Users have an account on on the web application, when they are created they are assigned to one of the private wallets and given an account in that wallet. </p>

<p>The web application sends an RPC request for getaddress  using a message queue that a process on the private server listens to. This issues a new address for payment and puts it in the web applications database.</p>

<p>When we want to accept payment we display the new address to the user on the web page</p>

<p>On the private server a deamon runs every minute or so that calls getreceivedbyaddress  -minconf with the addresses we have displayed to users to receive payment.    </p>

<p>when it sees a new payment it updates the webservers database with the record of the payment. </p>

<p>To make it more complicated but secure the communication is also encrypted and the details of the transaction signed using a shared secret between the web server and the wallet daemon process. So for example the web application wont regard the payment as accepted until it sees a signed transaction in its database and the deamon wont put one there until it has seen the minimum number of transactions confirmations on the network.</p>

<p>It took me a couple of days to implement but I had quite a big head start.
The easiest way is to go with one of the payment vendors who have done the hard work for you unless you plan on becoming one of them. </p>

<p>There are several other gotyas you have to be aware of.. for example
Keeping a secure backup of the remote wallets
Keeping the address pool in the remote wallets primed and making sure you have backed up the wallet after priming it.
Storing the wallet pass-phrases so you don't lock your self out 
having a way to change them..</p>

<p>What I do is have a multi signature approach where half the wallet phrase is sotred in the daemon binary so the developer could get hold of it.. The other half entered at run time by the support guy. Neither of them would have the full pass phrase so cant steel the wallet and run away with it easily.</p>

<p>Regarding the problem of creating too many addresses and not being able to remove them.
At them moment this is not a problem for us as our solution will scale as we get more users we can create more wallets.</p>

<p>As for cold storage I'm not completely convinced this offers us any more security than we have now with out giving us more problems associated with managing the cold part of the storage. At the moment its a numbers game. where by if we only have $5000 in a wallet its probably not worth it. If we have $3 million in a wallet then we would firstly be ecstatic our business was that successful, Then probably invest in a more secure private data center some brand new servers and some very clever security people</p>

CC BY-SA 3.0
2014-05-19T12:32:12.927Z
This answer would benefit from some formating and perhaps a TL;DR.
Murch
CC BY-SA 3.0
2014-05-20T12:49:27.340Z
be my guest feel free to edit as you like. Journalism has never been my speciality
Abelgo
CC BY-SA 3.0
2016-12-10T11:45:52.423Z
Awesome answer, still relevant after a couple of years! Any reason why not to use the -notifywallet argument of bitcoind to get notified of new deposits? Also, as of 2016, don't rely on the built in accounting mechanism, it will get deprecated. It's very straightforward to just keep a record of transactions in your db. Just provide ways to backup all the transactions because those are your accounting records.
alexg
CC BY-SA 3.0
2014-05-14T06:48:19.783Z
2014-05-14T08:34:31.563Z
2014-05-14T08:34:31.563Z
Abelgo
<p>How many addresses can bitcoind reasonably manage?</p>

<p>it is not the amount of addresses that matters but the amount of transactions going in and out of those addresses that can stress out the server.</p>

<p>Is it a good idea to create tons of addresses and have bitcoind watch all of them?</p>

<p>If you have it nicely organized in a database or some other file then go for it. </p>

<p>How often should I 'flush' the wallet? It doesn't make sense to me to keep the same wallet all the time since that file will grow huge in time.</p>

<p>someone stated I have a wallet with many transactions. It's around 200M. and each wallet flushing takes 4 seconds and blocks JSON RPC calls. from github. So unless you pass 200M transactions do not worry about flushing.</p>

<p>in regards for your second part why not use an open source bitcoin front end such as coiniv. That way you do not have to worry about the customer generating new bitcoin addresses you just inegrate it with coiniv which already has an api</p>

CC BY-SA 3.0
2014-07-02T15:26:39.970Z
2014-07-02T15:26:39.970Z
Marat Arguinbaev
<p>bitcoind is a very huge app</p>

<p>You should test this by yourself before. I'm currently trying to test dictionary attack. 100k addresses made my <code>wallet.dat</code> to <strong>50mb</strong>. After first 50k speed of adding new address radically decreased.</p>

<p>There is no option to remove address from wallet.dat for secure reason, to preventing loss.</p>

<p>You might look at <a href="https://github.com/joric/pywallet" rel="nofollow">pywallet</a>, This little python script can dump you <code>wallet.dat</code> in plain-text. Probably, wrapping back from plain to binary not a hard task, for even a young programmer.</p>

<p>Looks like side api, what @mulllhausen has mentioned, is the best, light solution.</p>

<p>Look at <a href="https://github.com/samr7/vanitygen" rel="nofollow">vanitygen</a>, you can generate vanity addresses by ajax+cgi user's request and check by <code>blockchain.info api</code> confirmation, and send e-mail to your work-box with <code>privkey</code>.</p>

<p>However, I don't know what kind of obfuscation exchanges used, like cryptsy or mtgox. Anyway, looks like keeping alive default bitcoind daemon on the webserver not a good idea.</p>

CC BY-SA 3.0
2014-02-06T10:01:15.777Z
2014-02-06T10:01:15.777Z
user2496
<p>I was able to get this working with some outside help (I paid him with Bitcoin).</p>

<p><a href="http://www.bitcoinmonitor.net/" rel="nofollow">http://www.bitcoinmonitor.net/</a></p>

<p>It monitors the block chain for payments to an address you provide (I use a cold storage address so it is never exposed to hackers). When a payment comes in it sends the details and then I can process the data received.</p>

CC BY-SA 3.0
2013-12-24T23:34:51.080Z
why not just use the blockchain.info api?
mulllhausen
CC BY-SA 3.0
2014-03-16T17:51:17.513Z
Free 3rd party services are a trade-off: On the one hand, they are cheap and quick to get started. But on the other hand, your business is incurring risk that they might suddenly stop, get overloaded, provide inaccurate information, etc. The more serious you are about Bitcoin, the less you want to rely on free 3rd party services.
BraveNewCurrency
CC BY-SA 3.0
2013-12-24T23:01:43.627Z
2013-12-24T23:01:43.627Z
user2180634
<p>If you really want to use bitcoind instead of a payment processor and you have a volume that a single instance of bitcoind can't handle (say, 5 figures of addresses) then you're going to have to build a cluster. Use a database to keep track of which addresses are on which bitcoind instance. </p>

<p>A vanitygen app might be useful for creating addresses and waiting for a payment before committing the address to a bitcoind wallet to save yourself from filling up servers with unused wallets.</p>

<p>There are a few tools out there to check balances of Bitcoin addresses without having to import them into bitcoind (and without revealing the private key to the tools).</p>

CC BY-SA 3.0
2014-07-01T01:10:21.997Z
2014-07-01T01:10:21.997Z
George
<p>You should check out <a href="http://bitpay.com" rel="nofollow">http://bitpay.com</a> or <a href="http://coinbase.com" rel="nofollow">http://coinbase.com</a>. They host the payment processor for you.</p>

CC BY-SA 3.0
2014-02-05T02:10:43.283Z
This off-topic for the question, question is about Bitcoin payments via Bitcoind.
John T
CC BY-SA 3.0
2014-02-04T13:01:00.803Z
2014-02-04T13:01:00.803Z
SimplePi
<p>I am trying to design a system that lets me accept Bitcoins on my website. I would like to use bitcoind, or bitcoinj. However, I have many questions regarding this setup.</p>

<p>FYI, I already read similar questions on this website and haven't gotten my answer.</p>

<p>Bitcoinj:</p>

<ul>
<li>Seems tricky. I wasn't able to find any example code that works for me. Don't take it as a sign of incompetence or laziness on my end. The examples on their site didn't work properly because they renamed many of their classes and I can't get it to work. If you have a piece of code working with the latest version, please point me to that direction.</li>
</ul>

<p>Bitcoind:</p>

<ul>
<li>How many addresses can bitcoind reasonably manage? Is it a good idea to create tons of addresses and have bitcoind watch all of them?</li>
<li>How often should I 'flush' the wallet? It doesn't make sense to me to keep the same wallet all the time since that file will grow huge in time.</li>
<li><p>I am planning on doing the following:</p>

<p>1) User generates the address on my website, sends BTC.</p>

<p>2) I start polling 'listunspent' every X minutes. When I see that the TX got N confirmations, I send the money to the cold storage. I also put money down on the sender's account on my website.</p>

<p>3) Now how do I get rid of this address? It sounds like these addresses will accumulate and break bitcoind after some point.</p></li>
</ul>

<p>I have read a lot about this but nobody explains this aspect. They just revolve around the problem.</p>

<wallet><bitcoind><bitcoinj>
Accepting Bitcoin payments on my website using bitcoind? Many questions... no apparent answers
Can Selcik
# Accepting Bitcoin payments on my website using bitcoind? Many questions... no apparent answers

(Asked by: username_0 on 2013-12-23)

I am trying to design a system that lets me accept Bitcoins on my website. I would like to use bitcoind, or bitcoinj. However, I have many questions regarding this setup.

FYI, I already read similar questions on this website and haven't gotten my answer.

Bitcoinj:

* Seems tricky. I wasn't able to find any example code that works for me. Don't take it as a sign of incompetence or laziness on my end. The examples on their site didn't work properly because they renamed many of their classes and I can't get it to work. If you have a piece of code working with the latest version, please point me to that direction.

Bitcoind:

* How many addresses can bitcoind reasonably manage? Is it a good idea to create tons of addresses and have bitcoind watch all of them?
* How often should I 'flush' the wallet? It doesn't make sense to me to keep the same wallet all the time since that file will grow huge in time.
* I am planning on doing the following:

  1) User generates the address on my website, sends BTC.

  2) I start polling 'listunspent' every X minutes. When I see that the TX got N confirmations, I send the money to the cold storage. I also put money down on the sender's account on my website.

  3) Now how do I get rid of this address? It sounds like these addresses will accumulate and break bitcoind after some point.

I have read a lot about this but nobody explains this aspect. They just revolve around the problem.

**Tags:** wallet, bitcoind, bitcoinj


---

## 6 answers

### Answer by username_1 on 2014-05-14. Score: 3

Actually Ive done this.

What I would say is that if you are planning to it your self it requires some amount of time and expertise if you really want to implement a custom solution that can integrate with your web platform. I did some research and in the end this is how I did it.

I use Bitcoind

It runs on a private server well away from the web server.
On the private server there are several encrypted wallets running on different ports under different user accounts each of them runs the RPC deamon that only responds to ssl from the local host.

Users have an account on on the web application, when they are created they are assigned to one of the private wallets and given an account in that wallet.

The web application sends an RPC request for getaddress using a message queue that a process on the private server listens to. This issues a new address for payment and puts it in the web applications database.

When we want to accept payment we display the new address to the user on the web page

On the private server a deamon runs every minute or so that calls getreceivedbyaddress -minconf with the addresses we have displayed to users to receive payment.

when it sees a new payment it updates the webservers database with the record of the payment.

To make it more complicated but secure the communication is also encrypted and the details of the transaction signed using a shared secret between the web server and the wallet daemon process. So for example the web application wont regard the payment as accepted until it sees a signed transaction in its database and the deamon wont put one there until it has seen the minimum number of transactions confirmations on the network.

It took me a couple of days to implement but I had quite a big head start.
The easiest way is to go with one of the payment vendors who have done the hard work for you unless you plan on becoming one of them.

There are several other gotyas you have to be aware of.. for example
Keeping a secure backup of the remote wallets
Keeping the address pool in the remote wallets primed and making sure you have backed up the wallet after priming it.
Storing the wallet pass-phrases so you don't lock your self out
having a way to change them..

What I do is have a multi signature approach where half the wallet phrase is sotred in the daemon binary so the developer could get hold of it.. The other half entered at run time by the support guy. Neither of them would have the full pass phrase so cant steel the wallet and run away with it easily.

Regarding the problem of creating too many addresses and not being able to remove them.
At them moment this is not a problem for us as our solution will scale as we get more users we can create more wallets.

As for cold storage I'm not completely convinced this offers us any more security than we have now with out giving us more problems associated with managing the cold part of the storage. At the moment its a numbers game. where by if we only have $5000 in a wallet its probably not worth it. If we have $3 million in a wallet then we would firstly be ecstatic our business was that successful, Then probably invest in a more secure private data center some brand new servers and some very clever security people

> **Comments:**
> **username_2**: This answer would benefit from some formating and perhaps a TL;DR.  
> **username_1**: be my guest feel free to edit as you like. Journalism has never been my speciality  
> **username_3**: Awesome answer, still relevant after a couple of years! Any reason why not to use the -notifywallet argument of bitcoind to get notified of new deposits? Also, as of 2016, don't rely on the built in accounting mechanism, it will get deprecated. It's very straightforward to just keep a record of transactions in your db. Just provide ways to backup all the transactions because those are your accounting records.  

---

### Answer by username_4 on 2014-07-02. Score: 1

How many addresses can bitcoind reasonably manage?

it is not the amount of addresses that matters but the amount of transactions going in and out of those addresses that can stress out the server.

Is it a good idea to create tons of addresses and have bitcoind watch all of them?

If you have it nicely organized in a database or some other file then go for it.

How often should I 'flush' the wallet? It doesn't make sense to me to keep the same wallet all the time since that file will grow huge in time.

someone stated I have a wallet with many transactions. It's around 200M. and each wallet flushing takes 4 seconds and blocks JSON RPC calls. from github. So unless you pass 200M transactions do not worry about flushing.

in regards for your second part why not use an open source bitcoin front end such as coiniv. That way you do not have to worry about the customer generating new bitcoin addresses you just inegrate it with coiniv which already has an api


---

### Answer by username_5 on 2014-02-06. Score: 0

bitcoind is a very huge app

You should test this by yourself before. I'm currently trying to test dictionary attack. 100k addresses made my `wallet.dat` to **50mb**. After first 50k speed of adding new address radically decreased.

There is no option to remove address from wallet.dat for secure reason, to preventing loss.

You might look at [pywallet](https://github.com/joric/pywallet), This little python script can dump you `wallet.dat` in plain-text. Probably, wrapping back from plain to binary not a hard task, for even a young programmer.

Looks like side api, what @username_7 has mentioned, is the best, light solution.

Look at [vanitygen](https://github.com/samr7/vanitygen), you can generate vanity addresses by ajax+cgi user's request and check by `blockchain.info api` confirmation, and send e-mail to your work-box with `privkey`.

However, I don't know what kind of obfuscation exchanges used, like cryptsy or mtgox. Anyway, looks like keeping alive default bitcoind daemon on the webserver not a good idea.


---

### Answer by username_6 on 2013-12-24. Score: 0

I was able to get this working with some outside help (I paid him with Bitcoin).

<http://www.bitcoinmonitor.net/>

It monitors the block chain for payments to an address you provide (I use a cold storage address so it is never exposed to hackers). When a payment comes in it sends the details and then I can process the data received.

> **Comments:**
> **username_7**: why not just use the blockchain.info api?  
> **username_8**: Free 3rd party services are a trade-off: On the one hand, they are cheap and quick to get started. But on the other hand, your business is incurring risk that they might suddenly stop, get overloaded, provide inaccurate information, etc. The more serious you are about Bitcoin, the less you want to rely on free 3rd party services.  

---

### Answer by username_9 on 2014-07-01. Score: 0

If you really want to use bitcoind instead of a payment processor and you have a volume that a single instance of bitcoind can't handle (say, 5 figures of addresses) then you're going to have to build a cluster. Use a database to keep track of which addresses are on which bitcoind instance.

A vanitygen app might be useful for creating addresses and waiting for a payment before committing the address to a bitcoind wallet to save yourself from filling up servers with unused wallets.

There are a few tools out there to check balances of Bitcoin addresses without having to import them into bitcoind (and without revealing the private key to the tools).


---

### Answer by username_10 on 2014-02-04. Score: -1

You should check out <http://bitpay.com> or <http://coinbase.com>. They host the payment processor for you.

> **Comments:**
> **username_11**: This off-topic for the question, question is about Bitcoin payments via Bitcoind.  

---

