Author

Topic: Understanding keypool in Bitcoin Core (Read 329 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
February 13, 2018, 01:57:52 PM
#5
The default keypool is set to 1000. What does it mean exactly? That I have a pool of 1000 keys/address to use?
It means that 1000 keys have been pre-generated and added to your wallet. If you restore a wallet backup, any keys that you had used that weren't marked as used in your backup are likely still in your backup's keypool. So when you restore it, the keys are already there and it knows to look for transactions related to those keys.

Even though Bitcoin Core uses BIP 32 HD wallets, it is not guaranteed that the software will be able to find all of your transactions if they keys are not in the keypool. Thus it is better to have a larger keypool to make sure that all transactions are caught during a restore.

The keypool also lets you get keys (specifically public keys and their associated address) without having to unlock your wallet. If there were no keypool, every time you wanted a new address, you would need to unlock your wallet in order for new keys to be added.

If I reduce the -keekpool to say 20 the wallet size is drastically reduced from 1.5M  to 50k. and loads much faster?
In theory yes since less data needs to be loaded.

Will I be able to add more keys later? or after I finish the 20 pool I must re-use addresses?
The keypool automatically regenerates keys when it is able to.

Is there any danger in a keypol of 20?
If you use more than 20 keys and then you restore an old backup, Bitcoin Core may not catch all of your transactions during a rescan. It is advised to keep the keypool larger than what you expect to use between backups.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
February 13, 2018, 09:18:38 AM
#4
Thanks for a clear answer. just to make it sure, if my wallet(s) are HD (which I do by default) I should not mind about keypool size and I can use 10 of 20 for that matter?
Yes. The existence for the keypool previously is mainly to ensure that the backups that the user makes will be at least valid for 100 or 1000 transactions by default. With the introduction of HD wallet, they don't matter anymore since the keys generated will be consistent across every of your wallet files, no matter how many transactions. This is correct only if you haven't changed your password after saving the wallet files.
jr. member
Activity: 39
Merit: 3
February 13, 2018, 09:07:38 AM
#3
The default keypool is set to 1000. What does it mean exactly? That I have a pool of 1000 keys/address to use?
If you have a HD wallet (check the icon on the bottom-right corner in Bitcoin Core), it doesn't matter.

Thanks for a clear answer. just to make it sure, if my wallet(s) are HD (which I do by default) I should not mind about keypool size and I can use 10 of 20 for that matter?

Also I made a mistake:

Quote
and loads much faster?

Should have been a fact, not a question.
When I tried to load/create 100 wallets (in multi-wallet mode), they were loaded/created in no time. as opposed when using the default 1000 keypool.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
February 13, 2018, 06:57:03 AM
#2
The default keypool is set to 1000. What does it mean exactly? That I have a pool of 1000 keys/address to use?
If you have a HD wallet (check the icon on the bottom-right corner in Bitcoin Core), it doesn't matter.

If you've created your wallet in an older version of Bitcoin Core, it's not an HD wallet. If that's the case, your keypool is important for backups: your backup has the same 1000 keys, which means you only need to make a new backup after using many different new addresses.
If you would limit the keypool size to 20, you'll quickly run out of addresses, and you need to make new backups very often. That's the reason the keypool was increased from 100 to 1000.
I highly doubt it will load faster with a smaller keypool, other factors ("Loading block index") take much longer.
jr. member
Activity: 39
Merit: 3
February 13, 2018, 06:27:03 AM
#1
The default keypool is set to 1000. What does it mean exactly? That I have a pool of 1000 keys/address to use?
If I reduce the -keekpool to say 20 the wallet size is drastically reduced from 1.5M  to 50k. and loads much faster?
Will I be able to add more keys later? or after I finish the 20 pool I must re-use addresses? Is there any danger in a keypol of 20?

Any will help be appreciated.
Jump to: