Bitcoin Forum

Other => Beginners & Help => Topic started by: btcsf on August 19, 2012, 12:43:26 PM



Title: Generating thousands of addresses
Post by: btcsf on August 19, 2012, 12:43:26 PM
Hello

I'm in the process of coding a webshop app, and would like to accept bitcoins.

What I want to do is this:

  • Pre-Generate a few thousand addresses with vanitygen.
  • Import the addresses in a mysql table.
  • Import the private keys in the Bitcoin app so I can easily see the money I've made.
  • Every new user that registers gets a bitcoin address from the mysql table.
  • A bitcoin notification service pings a script on the webserver when someone sends bitcoins to their address.
  • Their balance is updated and they can make purchases.

I'm having a few problems, though:

- Vanitygen is slow (2009 Core 2 Duo)

- Most notification services only support a low number of addresses.

- It's hard to import thousands of bitcoins into the Bitcoin app.

- An internet wallet like Blockchain only supports up to 400 addresses. (is there an alternative that supports more?)

I'd guess someone has done all this before. Is there an easy solution to this? Or am I handling this wrong?


Title: Re: Generating thousands of addresses
Post by: Raoul Duke on August 19, 2012, 12:47:27 PM
Code:
for i in `seq 1 5000`; do bitcoind getnewaddress; done >addresses.txt

That command will generate 5000 addresses on your wallet using bitcoind(no import needed) and save the addresses to a text file.
Change 5000 to any other number you like.


Title: Re: Generating thousands of addresses
Post by: payb.tc on August 19, 2012, 12:58:01 PM
why the need to generate them all at once?

if you're getting 10 customers a day, you just need to generate 11+ addresses a day to keep up and fill your db.

why the need to have them as vanity addresses? how long is the vanity string you have in mind?


Title: Re: Generating thousands of addresses
Post by: btcsf on August 19, 2012, 01:09:49 PM
Code:
for i in `seq 1 5000`; do bitcoind getnewaddress; done >addresses.txt

That command will generate 5000 addresses on your wallet using bitcoind(no import needed) and save the addresses to a text file.
Change 5000 to any other number you like.

Nice, just what I was looking for. Thank you very much.

Edit: I'm on a Mac. How do I install bitcoind? I found this wiki-article, but there's nothing listed under the Mac section.

https://en.bitcoin.it/wiki/Running_bitcoind#Mac


Title: Re: Generating thousands of addresses
Post by: btcsf on August 19, 2012, 01:11:13 PM
why the need to generate them all at once?

if you're getting 10 customers a day, you just need to generate 11+ addresses a day to keep up and fill your db.

why the need to have them as vanity addresses? how long is the vanity string you have in mind?


I would rather just do it once and be done with it.

I was using vanitygen because it was the only tool I knew that could mass-generate bitcoin addresses.


Title: Re: Generating thousands of addresses
Post by: flatfly on August 19, 2012, 02:10:35 PM
Much much easier if you don't have bitcoind: use the clever Bitaddress.org code ("Bulk Wallet" tab)

Just specify how many addresses you want to generate.

https://www.bitaddress.org/bitaddress.org-v1.6-SHA1-162d1ff4fd1e09222cbaca6c282672ee6c195e1b.html


Title: Re: Generating thousands of addresses
Post by: payb.tc on August 19, 2012, 02:13:54 PM
Much much easier if you don't have bitcoind: use the clever Bitaddress.org code ("Bulk Wallet" tab)

Just specify how many addresses you want to generate.

https://www.bitaddress.org/bitaddress.org-v1.6-SHA1-162d1ff4fd1e09222cbaca6c282672ee6c195e1b.html

but then you still have the job of importing them into a wallet, and for the standard client, that will take days.

if you use the bulk address generator of bitaddress.org, your best bet after that is to import into an armory wallet.



Title: Re: Generating thousands of addresses
Post by: btcsf on August 19, 2012, 03:37:26 PM
After googling some more I guess I'm SOL if I have a Mac and want to do business with Bitcoins.

1) Bitcoind apparently doesn't work on Mac OS X.
2) The Armory client is pretty hard to compile.

Guess I have a reason to fire up my Windows partition :-)


Title: Re: Generating thousands of addresses
Post by: rate5 on August 19, 2012, 03:55:09 PM
After googling some more I guess I'm SOL if I have a Mac and want to do business with Bitcoins.

1) Bitcoind apparently doesn't work on Mac OS X.
2) The Armory client is pretty hard to compile.

Guess I have a reason to fire up my Windows partition :-)

The command psy gave is a linux command I would recommend installing Ubuntu in a virtual machine and running it that way :)


Title: Re: Generating thousands of addresses
Post by: Raoul Duke on August 19, 2012, 04:01:00 PM
After googling some more I guess I'm SOL if I have a Mac and want to do business with Bitcoins.

1) Bitcoind apparently doesn't work on Mac OS X.
2) The Armory client is pretty hard to compile.

Guess I have a reason to fire up my Windows partition :-)

The command psy gave is a linux command I would recommend installing Ubuntu in a virtual machine and running it that way :)

This is correct and recommended.


Title: Re: Generating thousands of addresses
Post by: crazylikeafox on November 21, 2012, 06:16:34 PM
Code:
for i in `seq 1 5000`; do bitcoind getnewaddress; done >addresses.txt

That command will generate 5000 addresses on your wallet using bitcoind(no import needed) and save the addresses to a text file.
Change 5000 to any other number you like.

Sorry to bump an old thread, but just thought I'd post a step-by-step equivalent for Windows, since I had a need for it recently.

1) Open a command prompt, go to the bitcoind directory (your bitcoin directory\daemon)

2) Type "bitcoind -daemon".  Keep this window open for as long as the batch below is running.

3) Open another command prompt.  Navigate to the bitcoind directory again.  Enter the code below at the prompt and press enter:
Code:
for /l %x in (1, 1, 5000) do bitcoind getnewaddress >> newaddrs.txt

If you want to put the above code in a batch file, use 2 '%' symbols in front of the x instead of 1.  Replace the 5000 in the code above with the number of addresses you'd like to generate.  All addresses created will be dumped to newaddrs.txt, and bitcoind happily stores them in your official client wallet automatically.  Theoretically you can enter that same command above in multiple command prompts simultaneously and generate new addresses faster.


Title: Re: Generating thousands of addresses
Post by: SgtSpike on November 21, 2012, 06:29:48 PM
Fair warning, running the QT client begins to get sluggish after about 15k addresses, and is nearly unusable after 120k or so.


Title: Re: Generating thousands of addresses
Post by: payb.tc on November 21, 2012, 10:11:27 PM
Fair warning, running the QT client begins to get sluggish after about 15k addresses, and is nearly unusable after 120k or so.

also, armory is extremely slow with 10k addresses. each click takes about 15 minutes... so a small operation involving a few clicks will take hours.



Title: Re: Generating thousands of addresses
Post by: kakobrekla on November 21, 2012, 10:13:57 PM
This is what I use. Same stuff basically. Save and chmod. Pass an int of addresses as first argument.

Code:
#!/bin/bash

FILE=list_$(date +%s).txt

for x in $(eval echo {1..$1})
do
    bitcoind getnewaddress >> $FILE
done



Title: Re: Generating thousands of addresses
Post by: casascius on November 21, 2012, 10:14:31 PM
I bulk load private keys into bitcoind all the time by commenting out one line of code in the source and recompiling. I comment out the line that rescans from the genesis block after doing an importprivkey. After doing so, importprivkey returns immediately.

Bulk load, and then restart bitcoind with -rescan. Works beautifully.


Title: Re: Generating thousands of addresses
Post by: casascius on November 21, 2012, 10:16:32 PM
BTW, parallels does a GREAT job of running Ubuntu on a Mac including full support for GPU and clipboard as well as resizing the desktop.


Title: Re: Generating thousands of addresses
Post by: dpc on November 21, 2012, 11:09:23 PM
Using an address per-customer seems like a waste of resources.

I think using lazy generation of addresses per-transaction is much better idea. Especially that many online customers are one-shots only. They will buy stuff, pay, get it delivered and never return or return next year.

When customer makes a purchase it should get free payment address from a DB for one week (arbitrary time). After this time the address is released to the main pool. Only when weekly transaction rate is getting too big (pool is used for 90%, one generates new addresses and ads them to the DB).


Title: Re: Generating thousands of addresses
Post by: MoonShadow on November 21, 2012, 11:18:33 PM
After googling some more I guess I'm SOL if I have a Mac and want to do business with Bitcoins.

1) Bitcoind apparently doesn't work on Mac OS X.

It works fine, it's just not supported, per se.  I use a iMac.  All of the necessary posix commands should be within reach, once you get to a command line, which is the part Apple doesn't really make easy.  I'm not going to offer to tell you the process, because I don't remember, but my client is set to maintain a buffer of about 2K future addresses via config file arguments, so I know that it's possible.

EDIT: I do remember that the important parts of bitcoind are in strange places on the iMac filesystem, it took me a while to locate them and thus alter the appropriate commands to make it work the way that I wanted.


Title: Re: Generating thousands of addresses
Post by: casascius on November 22, 2012, 12:08:43 AM
Using an address per-customer seems like a waste of resources.

This is only true to the extent that address creation and address maintenance is a waste of resources.  It shouldn't be, and doesn't have to be.  The total resource expenditure of storing an address in a non-wasteful manner is well under 100 bytes.

When implemented properly, the total resources expended in creating and maintaining an address should be significantly less than the resources expended in logging their web visit.  Even in spite of this, simply reassigning addresses that were assigned months ago and never used is a good way to reclaim whatever resources are associated with unused addresses.


Title: Re: Generating thousands of addresses
Post by: crazylikeafox on November 22, 2012, 01:05:18 PM
Fair warning, running the QT client begins to get sluggish after about 15k addresses, and is nearly unusable after 120k or so.

I haven't noticed any sluggishness with the newest version of the QT client, and I now have a wallet with 50K addresses in it.  Also the wallet is only around 7MB.  The real problem with the official client is the amount of time it takes to sync after install.  That by itself will hamper the adoption of bitcoin by the general population.  Although alternatives are available that make the use of the official software unnecessary, a casual user that goes to the bitcoin main site and downloads the software will be immediately turned off and may not bother or even understand that alternatives are available.