Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: giantdragon on July 18, 2011, 08:33:33 PM



Title: Generate bunch of payment addresses
Post by: giantdragon on July 18, 2011, 08:33:33 PM
I need to generate many Bitcoin addresses that I will give to customers on my website. I tried to use JSON-RPC from PHP with command "getnewaddress" in loop, but speed is not satisfactory (about 1 second for each address). Just few simultaneous requests and my server probably will be down. Another idea is to pre-generate addresses, store them in database and extract when need. Is it possible to speed up address generation process?


Title: Re: Generate bunch of payment addresses
Post by: error on July 18, 2011, 08:36:02 PM
Sure, you can get new addresses in advance and use them later.


Title: Re: Generate bunch of payment addresses
Post by: bitlotto on July 19, 2011, 01:46:25 AM
You COULD use openssl to make the keys. You would then have to import them, but at least when you import them you can do them one at a time. I don't know if it would be any faster though.


Title: Re: Generate bunch of payment addresses
Post by: Alex Beckenham on July 19, 2011, 02:28:57 AM
Is it possible to speed up address generation process?

I'd like to know too... let's say for whatever reason you needed 100000 addresses in your wallet... what would be the quickest way to generate them?


Title: Re: Generate bunch of payment addresses
Post by: bitlotto on July 19, 2011, 03:05:03 AM
Run:
./vanitygen -o addresslist.txt -k 1

For a few hours. You'll have addresses to last a lifetime! Even a few minutes and you'll have a ton of addresses.

vanitygen makes addresses pretty quick if your only requirement is it starts with a 1. (Which they all do)


Title: Re: Generate bunch of payment addresses
Post by: Alex Beckenham on July 19, 2011, 03:34:01 AM
Run:
./vanitygen -o addresslist.txt -k 1

For a few hours. You'll have addresses to last a lifetime! Even a few minutes and you'll have a ton of addresses.

vanitygen makes addresses pretty quick if your only requirement is it starts with a 1. (Which they all do)

So, the above command places the addresses into addresslist.txt, but where do the private keys end up? Does it generate a wallet.dat at the same time?

No point having a list of addresses if you don't own them :)


Title: Re: Generate bunch of payment addresses
Post by: bitlotto on July 19, 2011, 03:40:00 AM
Example output in file:
Quote
Pattern: 1
Address: 12nZ51BtWfb7GEi8JbrrgnVS2kyGQYqpsp
Privkey: 5JaGyzFRLLAkGGzx5tmGo1LP4VLADtiwjVnMpCZQYPnE4kwCM2J
Pattern: 1
Address: 18HL4zJP8K5ffbzAj3fNerc52VAofsgy3d
Privkey: 5KiqGaCcCq715q4xkFBuvaRUWsn4PDPH4QY6E6yrGrbJLnNbjxZ
Pattern: 1
Address: 1GMpun3eb1YPqQntUztF1GbEuDEsZGK6uk
Privkey: 5KC5G6zmsn2uuVD1MCP6HdPdS1Nk3Hms9XuAD7twesC23BKyr8R
Pattern: 1
Address: 19fH7CTchby2MRTsVLV4N3Vs5tRnHRoDLW
Privkey: 5KT7utqYoSbbWAUpCQgctdTo3QZXiCMXmBcS18qHA25UeUuoSfd
Pattern: 1
Address: 19sK6oJYyiWZH5yazghfeihRSc5RRzYqCu
Privkey: 5J18fJ8SeEifdSsetjSm991pU5bAiJsNfXUTtKXHHUsSXbxKXnt
You could make a script to input it all into a database. Then import the keys whenever they are needed as apposed to making one giant wallet.


Title: Re: Generate bunch of payment addresses
Post by: casascius on July 19, 2011, 03:43:27 AM
Isn't there an issue with vanitygen using a poor source of entropy, e.g. the time and date and process number?  If so, taking the 1st address that it provides makes for an easy theft due to a predictable address.


Title: Re: Generate bunch of payment addresses
Post by: bitlotto on July 19, 2011, 03:48:42 AM
Isn't there an issue with vanitygen using a poor source of entropy, e.g. the time and date and process number?  If so, taking the 1st address that it provides makes for an easy theft due to a predictable address.
I don't recall all the details but I think that was before it was discovered the entropy was coming from urandom. So it wouldn't really be an issue... as far as I know. I'm not really an expert on that though.


Title: Re: Generate bunch of payment addresses
Post by: samr7 on July 19, 2011, 05:12:29 AM
Isn't there an issue with vanitygen using a poor source of entropy, e.g. the time and date and process number?  If so, taking the 1st address that it provides makes for an easy theft due to a predictable address.

This myth comes from questionable sources (crypto-noobs?) and has absolutely no credibility.

Vanitygen uses the same random number generator as bitcoin itself -- the OpenSSL RNG.  It is true that OpenSSL uses the time and process number, but most of its entropy comes from /dev/urandom.


Title: Re: Generate bunch of payment addresses
Post by: casascius on July 19, 2011, 06:09:47 AM
This myth comes from questionable sources (crypto-noobs?) and has absolutely no credibility.

There's no need to be a jerk.  The author of vanitygen suggested this himself.  I didn't tear apart his source code so I don't know one way or another.  If this issue has been resolved then so be it.  It's better to be prudent than to be stolen from.


Title: Re: Generate bunch of payment addresses
Post by: samr7 on July 19, 2011, 07:20:39 AM
There's no need to be a jerk.  The author of vanitygen suggested this himself.  I didn't tear apart his source code so I don't know one way or another.  If this issue has been resolved then so be it.  It's better to be prudent than to be stolen from.

You're absolutely right.  I'm sorry.

But, for real, what's the bottom line, is the problem real or not?


Title: Re: Generate bunch of payment addresses
Post by: BkkCoins on July 22, 2011, 06:53:00 AM
It would be quite easy to write a small script that uses vanitygen and pywallet to create and import private keys (and addresses) into wallets. I'm not sure if you can start with an empty wallet (blank template) for this or if you'd have to create a new wallet for each address (assuming you don't want many in one wallet). It seems like creating new wallets would be more time consuming. Unless pywallet can create a wallet file as well - I haven't checked that.

Another thing with vanitygen is you could make all your customer addresses start with a common prefix so they are easily identifiable. eg. 1dog...


Title: Re: Generate bunch of payment addresses
Post by: giantdragon on July 22, 2011, 10:31:44 AM
Generated with default client, took just few hours.