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:
What’s the main reason for the existence of the key pool, especially when the cost of generating a new key is totally negligible?
How does HD wallet affect the role of the key pool?