I am doing some test, and am getting weird behavior with keypool.
In the 0.4.0rc1 bitcoin client:
If I set keypool=1, how many times should I be able to do getnewaddress?
Are there any resources where I can read about keypool, and how it works?
You can do
The keypool is a collection of unused addresses in your wallet. The keypool parameter tells the client how many unused addresses to keep in its pool.
Almost every time you send a Bitcoin payment, some change is generated and sent to a previously unused address. If you have a keypool, then each time a new address is needed one of the keypool addresses is used, and a new address is created and placed in the keypool to replace the one that was just used.
The purpose of the keypool is to allow you to backup your wallet file less frequently and still have access to all your funds in the event of a hard drive failure. If you didn't have a keypool, and made a backup of your wallet, then made a payment, and then suffered a disk crash, you would lose the change which came from that payment because it would have been sent to a new address that wasn't in the backup.
With a keypool of 100 addresses, you can make up to 100 payments between backups and still be able to access all your funds.