<blockquote>
  <p>What is the maximum number of keys/addresses that can be created for a single wallet? Phrased another way, what is the largest value one can safely put for the <code>keypool</code> option in <code>bitcoin.conf</code>?</p>
</blockquote>

<p>The type of that parameter is <code>int64_t</code> so the maximum value is 2^(64-1)-1. In practice, you can put any number you want and it should not make the software break. However having a lot of keys (hundreds of thousands) will result in a very large wallet and potentially slow down the wallet loading phase.</p>

<blockquote>
  <p>If I generate some keys with <code>bitcoind keypoolrefill</code> then generate some new addresses and then call <code>keypoolrefill</code> again, will the original addresses still work, </p>
</blockquote>

<p>Yes. Everything is stored in the wallet and keys are never deleted.</p>

<blockquote>
  <p>and will my private key now work for all addresses I've ever created?</p>
</blockquote>

<p>That's not how private keys work. Each address has a private key, so if you have one private key, it corresponds to one address. Each address that is generated in the keypool will have its own private key which is stored in the wallet file.</p>

<blockquote>
  <p>Is there some way to determine how many keys are left in the current key pool?</p>
</blockquote>

<p><code>bitcoin-cli getwalletinfo</code> will tell you how many keys are left in the keypool. The keypool is automatically refilled when your wallet is unlocked.</p>

<blockquote>
  <p>The Bitcoin documentation says that this feature is actively being phased out. When will this happen and what will the new system be?</p>
</blockquote>

<p>This system with the keypool is still in use and making periodic backups is still recommended as the wallet contains transaction data that is not backed up by deterministic wallets. The "new system" is to use BIP 32 Hierarchical Deterministic key derivation instead of randomly generated private keys. A seed is first randomly generated and then all private keys are derived from that seed. This means that only one backup is necessary in order to backup all of your private keys, but periodic backups are still recommended as stated above.</p>

<p>This feature was added to Bitcoin Core in Bitcoin Core 0.13.0. Most other modern wallets use BIP 32 HD wallets.</p>

CC BY-SA 3.0
2017-10-20T04:16:04.367Z
2017-10-20T04:16:04.367Z
Ava Chow
<p>I'm wondering about what the best practices are around generating and maintaining key pools for a wallet.</p>
<ul>
<li><p>What is the maximum number of keys/addresses that can be created for a single wallet? Phrased another way, what is the largest value one can safely put for the <code>keypool</code> option in <code>bitcoin.conf</code>?</p>
</li>
<li><p>If I generate some keys with <code>bitcoind keypoolrefill</code> then generate some new addresses and then call <code>keypoolrefill</code> again, will the original addresses still work, and will my private key now work for all addresses I've ever created?</p>
</li>
<li><p>Is there some way to determine how many keys are left in the current key pool?</p>
</li>
<li><p>The <a href="https://bitcoin.org/en/developer-guide#storing-root-seeds" rel="nofollow noreferrer">Bitcoin documentation</a> says that this feature is actively being phased out. When will this happen and what will the new system be?</p>
<blockquote>
<p>This wallet type is being actively phased out and discouraged from being used due to the backup hassle.</p>
</blockquote>
</li>
</ul>
<p>Answers to any of these questions is greatly appreciated.</p>
<hr />
<p>Gavin Andresen (Bitcoin's Chief Scientist) has to say on the <a href="https://bitcointalk.org/index.php?topic=1414.0" rel="nofollow noreferrer">topic</a>:</p>
<blockquote>
<p>Backup every 30 sendtoaddress or generatenewaddress and you'll be fine-- you should always have at least 3 backup copies of all your keys.</p>
<p>If you're running a very busy service so backing up every 30 is too often, then run with -keypool=1000 and backup at least every 300 sends/generates.</p>
</blockquote>

CC BY-SA 3.0
2015-11-17T17:48:56.880Z
The new system is Hierarchical Deterministic Wallets, [BIP 32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).
Nayuki
<address><private-key><address-generation><keypool>
Key Pools and best practices
Loourr
# Key Pools and best practices

(Asked by: username_0 on 2014-08-09)

I'm wondering about what the best practices are around generating and maintaining key pools for a wallet.

* What is the maximum number of keys/addresses that can be created for a single wallet? Phrased another way, what is the largest value one can safely put for the `keypool` option in `bitcoin.conf`?
* If I generate some keys with `bitcoind keypoolrefill` then generate some new addresses and then call `keypoolrefill` again, will the original addresses still work, and will my private key now work for all addresses I've ever created?
* Is there some way to determine how many keys are left in the current key pool?
* The [Bitcoin documentation](https://bitcoin.org/en/developer-guide#storing-root-seeds) says that this feature is actively being phased out. When will this happen and what will the new system be?

  > This wallet type is being actively phased out and discouraged from being used due to the backup hassle.

Answers to any of these questions is greatly appreciated.

---

Gavin Andresen (Bitcoin's Chief Scientist) has to say on the [topic](https://bitcointalk.org/index.php?topic=1414.0):

> Backup every 30 sendtoaddress or generatenewaddress and you'll be fine-- you should always have at least 3 backup copies of all your keys.
>
> If you're running a very busy service so backing up every 30 is too often, then run with -keypool=1000 and backup at least every 300 sends/generates.

**Tags:** address, private-key, address-generation, keypool

> **Comments:**
> **username_1**: The new system is Hierarchical Deterministic Wallets, [BIP 32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).  

---

## 1 answers

### Answer by username_2 on 2017-10-20. Score: 2

> What is the maximum number of keys/addresses that can be created for a single wallet? Phrased another way, what is the largest value one can safely put for the `keypool` option in `bitcoin.conf`?

The type of that parameter is `int64_t` so the maximum value is 2^(64-1)-1. In practice, you can put any number you want and it should not make the software break. However having a lot of keys (hundreds of thousands) will result in a very large wallet and potentially slow down the wallet loading phase.

> If I generate some keys with `bitcoind keypoolrefill` then generate some new addresses and then call `keypoolrefill` again, will the original addresses still work,

Yes. Everything is stored in the wallet and keys are never deleted.

> and will my private key now work for all addresses I've ever created?

That's not how private keys work. Each address has a private key, so if you have one private key, it corresponds to one address. Each address that is generated in the keypool will have its own private key which is stored in the wallet file.

> Is there some way to determine how many keys are left in the current key pool?

`bitcoin-cli getwalletinfo` will tell you how many keys are left in the keypool. The keypool is automatically refilled when your wallet is unlocked.

> The Bitcoin documentation says that this feature is actively being phased out. When will this happen and what will the new system be?

This system with the keypool is still in use and making periodic backups is still recommended as the wallet contains transaction data that is not backed up by deterministic wallets. The "new system" is to use BIP 32 Hierarchical Deterministic key derivation instead of randomly generated private keys. A seed is first randomly generated and then all private keys are derived from that seed. This means that only one backup is necessary in order to backup all of your private keys, but periodic backups are still recommended as stated above.

This feature was added to Bitcoin Core in Bitcoin Core 0.13.0. Most other modern wallets use BIP 32 HD wallets.


---

