How can you find how many keys you wasted in bitcoinj?

4

Supposed you create a new wallet and pre-populate it with 100 keys (so you don't need to back it up after each transaction).

How do you know, given an instance of Wallet, which keys have been "used up"? Or, in other words, if you want to use a new key for every transaction, how do you which key to use, given only the wallet state?

Are you supposed to save this information elsewhere?

ripper234

Posted 2011-12-28T20:48:52.307

Reputation: 25 192

Answers

1

Wallets contain a pool of 100 unused keys plus every key ever used. You can never run out of unused keys because the client adds new keys to the unused key pool as you use them.

The reason it maintains a pool of unused keys is so that future transactions that happen after a backup can still be recovered.

You should frequently back your wallet.dat up off-site using non-flash media. You should also backup your wallet.dat after every 50 send transactions (receive transactions do not use up unused keys unless you frequently create new addresses to receive coins with, which would also use the key pool up; in that case, every 50 transactions of any kind).

Diablo-D3

Posted 2011-12-28T20:48:52.307

Reputation: 403