Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: MrKain on June 16, 2013, 12:07:17 AM



Title: A new address for each transaction ?
Post by: MrKain on June 16, 2013, 12:07:17 AM

 I've finally accepted that creating a new address for each
transaction is kind of a good idea..
 
 Am I correct in thinking - that for each customer that comes to my shop
I generate/give to them a unique bitcoin address , so that I know that
if the address in question receives money , then it's surely from the
person I gave the address to..

 This is fine, - but that could end being hundreds or even thousands of
addresses being generated everyday..

 I understand that generating a new address is not a big deal, but the
housekeeping of my bitcoin server becomes an issue..

 How can I delete addresses from the database when I am done with them
( for example, once an address receives coins, I make a note of it in my
mysql for example, and 'move' the coins to one central internal bitcoin address).

If I have thousands of addresses/accounts , anytime I do a listaccounts or
getbalance I'm going to get a really long list..

 So , that's my query - can I delete bitcoin addresses and/or accounts from
bitcoind to keep everything running smooth..




Title: Re: A new address for each transaction ?
Post by: SwiftHF on June 16, 2013, 12:48:10 AM
Keeping in mind that each address has essentially it's own balance, you would need to transfer the balance to one central address before deleting it. To delete them, you could probably design a script based from pywallet, it wouldn't be hard.


Title: Re: A new address for each transaction ?
Post by: grue on June 16, 2013, 02:28:38 AM
pywallet can delete addresses from your wallet. But you don't need to clean your wallet at all. Bitcoin will run fine even with tens of thousands of addresses. Also, instead of polling for transactions, consider using "walletnotify" to get instant notification of transactions.


Title: Re: A new address for each transaction ?
Post by: niko on June 16, 2013, 02:45:22 AM
I would never delete private keys from a wallet, unless I backed them up first. There is no good reason to destroy a key, and there are good reasons to keep them.


Title: Re: A new address for each transaction ?
Post by: redtwitz on June 16, 2013, 03:41:57 AM
There is no good reason to destroy a key, and there are good reasons to keep them.

Exactly. Imagine a user sending his payment from several different wallets (e.g., a hot and a cold one) and your script already purged the address after the first incoming transaction...


Title: Re: A new address for each transaction ?
Post by: RagnarDanneskjold on June 16, 2013, 05:48:28 AM
I believe there is possibly a solution for what you describe using HD wallets. Not sure what or how.
https://en.bitcoin.it/wiki/BIP_0032


Title: Re: A new address for each transaction ?
Post by: odolvlobo on June 16, 2013, 05:58:17 AM
Instead, could you reuse addresses from a large pool to limit the total number?


Title: Re: A new address for each transaction ?
Post by: SgtSpike on June 16, 2013, 06:00:56 AM
For what it's worth, I did begin to run in to some significant slowdowns when I hit 75,000-100,000 addresses in a single wallet.  There IS a practical limit to the number of addresses that can/should be kept.

Bitpay, for example, reuses their addresses.  I don't know how large a pool of addresses they keep, but I've noticed that payments I have made through bitpay are sent to addresses that have previously received coins already.


Title: Re: A new address for each transaction ?
Post by: Sukrim on June 16, 2013, 07:33:49 AM
I personally would use BIP32 keys and keep the last X (depending on the business) last used keys in the wallet, the rest can be purged and regenerated on demand anyways.

MtGox claims to have several million private keys (most probably in cold storage) afair.


Title: Re: A new address for each transaction ?
Post by: Remember remember the 5th of November on June 16, 2013, 07:47:43 AM
pywallet can delete addresses from your wallet. But you don't need to clean your wallet at all. Bitcoin will run fine even with tens of thousands of addresses. Also, instead of polling for transactions, consider using "walletnotify" to get instant notification of transactions.
It will indeed run fine, but it will take waay more time to load up. I am talking from experience, with a 200k address wallet.


Title: Re: A new address for each transaction ?
Post by: grau on June 16, 2013, 07:21:02 PM
HD (Hierarchical Deterministic) key generation as designed in https://en.bitcoin.it/wiki/BIP_0032 will solve this for good as you may use a large number of addresses but only need to back up the master key.


Title: Re: A new address for each transaction ?
Post by: jackjack on June 17, 2013, 12:33:04 PM
pywallet can delete addresses from your wallet. But you don't need to clean your wallet at all. Bitcoin will run fine even with tens of thousands of addresses. Also, instead of polling for transactions, consider using "walletnotify" to get instant notification of transactions.
It will indeed run fine, but it will take waay more time to load up. I am talking from experience, with a 200k address wallet.
If you think something in pywallet can be improved, you can post in its thread, that's the point of it
For example someone reported a similar problem (time-consuming transaction deletions) https://bitcointalk.org/index.php?topic=34028.msg2206558#msg2206558 and it was fixed


Title: Re: A new address for each transaction ?
Post by: Sukrim on June 17, 2013, 01:49:24 PM
I guess he/she is talking about bitcoin-qt taking long to load up with >200k private keys, not pywallet.


Title: Re: A new address for each transaction ?
Post by: jackjack on June 17, 2013, 01:53:20 PM
I guess he/she is talking about bitcoin-qt taking long to load up with >200k private keys, not pywallet.
Oh, indeed it looks like I misunderstood, sorry... Post deleted
Now that I'm here, if pywallet be some help here just tell me


Title: Re: A new address for each transaction ?
Post by: DannyHamilton on June 20, 2013, 07:39:32 PM
I'd be tempted to use a new temporary wallet each day.

At the end of the day, you empty the entire balance of the temporary wallet by sending it all to some other wallet where you consolidate your funds. Then you change the name of the temporary wallet.dat to yyyymmdd.dat and archive it off somewhere safe.  You start the new day with a brand new wallet.dat.

If you ever need to, you can still retrieve private keys from the archived off wallets, but you have no need to clutter up your daily wallet with addresses that you don't intend to ever use again.