<p>Wallets contain a pool of 100 unused keys <em>plus</em> 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.</p>

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

<p>You should frequently back your wallet.dat up <a href="http://adterrasperaspera.com/blog/2006/10/30/how-to-choose-cddvd-archival-media" rel="nofollow">off-site using non-flash media</a>. 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).</p>

CC BY-SA 3.0
2012-03-30T11:27:07.023Z
2012-03-30T11:27:07.023Z
Diablo-D3
<p>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).</p>

<p>How do you know, given an instance of <code>Wallet</code>, 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?</p>

<p>Are you supposed to save this information elsewhere?</p>

<development><bitcoinj>
How can you find how many keys you wasted in bitcoinj?
ripper234
# How can you find how many keys you wasted in bitcoinj?

(Asked by: username_0 on 2011-12-28)

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?

**Tags:** development, bitcoinj


---

## 1 answers

### Answer by username_1 on 2012-03-30. Score: 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](http://adterrasperaspera.com/blog/2006/10/30/how-to-choose-cddvd-archival-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).


---

