Author

Topic: which operations require the bitcoind wallet to be unlocked? (Read 2226 times)

member
Activity: 90
Merit: 10
very very useful info! thank you big time.

I suppose this isn't documented?
donator
Activity: 1218
Merit: 1079
Gerald Davis
so bitcoind generates the new 100 addresses at once when the last one of the existing ones is used or it always keeps 100 unused ones in advance?

Neither.  
If the wallet is unlocked the wallet will create as many new addresses to refill the pool back to 100 anytime it is less than 100 (default).
If the wallet is locked the wallet will not be able to refill the keypool and the number of addresses in the keypool will decline.
If the keypool has 0 addresses and you call getnewaddress it will fail.

Calling getinfo will show the number of keys remaining in the keypool.  Try experimenting with getnewaddress, getinfo, and walletpassphrase so observe how the keypool behaves.

Example:
Wallet has a keypool of 100

Lock Wallet. Keypool = 100
GetNewAddress. Keypool = 99
GetNewAddress. Keypool = 98
GetNewAddress. Keypool = 97
GetNewAddress. Keypool = 96
GetNewAddress. Keypool = 95
UnlockWallet. Keypool = 100
GetNewAddress. Keypool = 100 (generated as soon as used)
GetNewAddress. Keypool = 100
GetNewAddress. Keypool = 100
GetNewAddress. Keypool = 100
GetNewAddress. Keypool = 100
LockWallet. Keypool = 100
GetNewAddress. Keypool = 99
GetNewAddress. Keypool = 98
GetNewAddress. Keypool = 97
...
GetNewAddress. Keypool = 1
GetNewAddress. Keypool = 0
GetNewAddress. FAILURE. No address provided, keypool exhausted.
UnlockWallet. Keypool = 100




member
Activity: 90
Merit: 10
so bitcoind generates the new 100 addresses at once when the last one of the existing ones is used or it always keeps 100 unused ones in advance?

donator
Activity: 1218
Merit: 1079
Gerald Davis
getnewaddress will fail if the keypool (default 100 keys) is exhausted when you call it.  The keypool can only be refilled when the wallet is unlocked.  You can raise the size of the keypool if you anticipate this being a problem.
member
Activity: 90
Merit: 10
Thank you guys, that was very helpful.

Just one more thing, so I'm sure.

getnewaddress  is not supposed to require unlocking

but all GUI clients require the encryption password when creating new address, even bitcoin-qt which is supposed to create 100 addresses in advance.
why is that?

any chance the bitcoind will want unlocking password when it uses up the pre-generated 100 addresses?
legendary
Activity: 1106
Merit: 1016
090930
hero member
Activity: 812
Merit: 1022
No Maps for These Territories
* dumpprivkey
* dumpwallet
* importwallet
* keypoolrefill
* sendfrom
* sendmany
* sendtoaddress
* signmessage
* signrawtransaction (if keys are not provided on command line)

(just look where EnsureWalletIsUnlocked is used)
member
Activity: 90
Merit: 10
Say the wallet is encrypted, for which operations we should unlock it before doing them?
Sending money is understandable, what else?
Jump to: