Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Staring Owl on December 09, 2013, 01:47:32 PM



Title: which operations require the bitcoind wallet to be unlocked?
Post by: Staring Owl on December 09, 2013, 01:47:32 PM
Say the wallet is encrypted, for which operations we should unlock it before doing them?
Sending money is understandable, what else?


Title: Re: which operations require the bitcoind wallet to be unlocked?
Post by: wumpus on December 09, 2013, 02:59:01 PM
* dumpprivkey
* dumpwallet
* importwallet
* keypoolrefill
* sendfrom
* sendmany
* sendtoaddress
* signmessage
* signrawtransaction (if keys are not provided on command line)

(just look where EnsureWalletIsUnlocked is used)


Title: Re: which operations require the bitcoind wallet to be unlocked?
Post by: flatfly on December 09, 2013, 08:37:56 PM
This wiki page has it (last column in the table):

https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list


Title: Re: which operations require the bitcoind wallet to be unlocked?
Post by: Staring Owl on December 11, 2013, 04:50:14 PM
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?


Title: Re: which operations require the bitcoind wallet to be unlocked?
Post by: DeathAndTaxes on December 11, 2013, 04:52:27 PM
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.


Title: Re: which operations require the bitcoind wallet to be unlocked?
Post by: Staring Owl on December 11, 2013, 07:39:44 PM
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?



Title: Re: which operations require the bitcoind wallet to be unlocked?
Post by: DeathAndTaxes on December 11, 2013, 07:46:24 PM
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






Title: Re: which operations require the bitcoind wallet to be unlocked?
Post by: Staring Owl on December 11, 2013, 08:41:50 PM
very very useful info! thank you big time.

I suppose this isn't documented?