key pool inside Qt wallet / reddcoind

As I finalise the implementation of Electrum hierarchical deterministic wallet inside Qt / reddcoind, I come cross an interesting technical detail. As you may already know, inside your wallet.dat file is sth called a key pool which by defaults holds 100 private/public key pairs. When you request a new key, the wallet returns one from the pool instead of generating it on the fly. When your wallet is unlocked, the key pool is topped up. The size of the key pool can be set.

This feature was added by Satoshi himself back in 2010. I’d like to start a discussion by asking two questions:

  1. What’s the main reason for the existence of the key pool, especially when the cost of generating a new key is totally negligible?

  2. How does HD wallet affect the role of the key pool?

laudney I’m not exactly an expert, but after some googling:

*A key pool allows to create backups in bigger intervals

Every time you create a transaction, the remainder of the input balance is sent to a new address in your own wallet. If addresses were generated only then, you would have to create a new backup after each transaction, or be at risk to lose any funds associated with that new address if your wallet got lost. *

Would HD wallets eliminate the key pool altogether since keys are generated by a seed?


laudney said:


stop writing this, it’s “something”.

I don’t really see a point in the key pool when one can be generated quickly on the fly, although if for some reason it could not generate one at that point where would the change go without it, maybe it was a back up plan.

  1. In my point of view is for safety reasons… and backup reasons as livefromheaven said.

  2. second If we were only to depend on seed implementation those 100 adresses will be generated when the wallet was created, instead of being stored in a .dat file…

I haven’t research nothing in this area, though.

livefromheaven I’m no expert either but you hit the nail on the head with this one. The only reason this was for was to help prevent user errors (not backing up after a new key was created and losing change/funds). HD eliminates this issue completely as you have 1 phrase to backup forever. It might be beneficial to remove this as having a list of priv keys can’t be good for security.

livefromheaven You’ve said it all. With Electrum, the key pool will be completely eliminated and all keys will be generated on the fly.

1 Like

laudney Awesome, looking forward to getting my hands on it

laudney Sweet, love how involved the community has been feeling with the launch on reddcointalk. Keep up the good vibes guys :smiley:

1 Like