Keep walletpassphrase until the next api call it's used in #3714

pull chjj wants to merge 4 commits into bitcoin:master from bitpay:unlock-time changing 4 files +52 −4
  1. chjj commented at 3:55 AM on February 21, 2014: none

    This patch will allow -1 to be passed to walletpassphrase as the timeout. A timeout of -1 will hold the passphrase in memory until the next api call is made that requires it.

    Example:

    $ bitcoind walletpassphrase hunter2 -1
    $ bitcoind getaccountaddress ''
    1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd
    $ bitcoind signmessage 1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd foo
    H5UQlcIJjSWbNK/MFaP0LDGt8CSkbe9D8FbdGUFHM/hAQ0avEchg2sJ8v2db8ynOD2PqQwYuR/5tbbKl7LiMUEE=
    $ bitcoind signmessage 1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd foo
    error: {"code":-13,"message":"Error: Please enter the wallet passphrase with walletpassphrase first."}
    

    I realize something similar is doable with:

    $ bitcoind walletpassphrase hunter2 60
    $ bitcoind signmessage 1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd foo
    H5UQlcIJjSWbNK/MFaP0LDGt8CSkbe9D8FbdGUFHM/hAQ0avEchg2sJ8v2db8ynOD2PqQwYuR/5tbbKl7LiMUEE=
    $ bitcoind walletlock
    

    The former just seems like it might be more convenient for some situations.

  2. rpc: make an nWalletUnlockTime of -1 to mean "until next api call". 6e9f308429
  3. minor: conform to style conventions. 09ee034170
  4. rpc: add new argument info to walletpassphrase help. f6bf3987dd
  5. rpc: lock wallet on -1 timeout even when an existing private key is imported. cb31ac84e5
  6. BitcoinPullTester commented at 4:47 AM on February 21, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/cb31ac84e50f6ae99033c8de5de540345b434eb0 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  7. laanwj commented at 6:33 AM on February 21, 2014: member

    NACK. This introduces a statefulness that wouldn't work together with concurrent use of the API:

    For example if we have two client, A and B.

    A> walletpassphrase hunter2 -1
    B> walletpassphrase hunter2 -1
    A> sendtoaddress ...
    B> sendtoaddress ...
    error: {"code":-13,"...")
    
  8. luke-jr commented at 6:38 AM on February 21, 2014: member

    Suggestion: This might be more reasonable if it only worked with a batch request...

  9. rebroad commented at 11:23 PM on February 22, 2014: contributor

    @laanwj - can it be implemented such that the wallet is only unlocked per client?

  10. laanwj commented at 8:21 AM on February 23, 2014: member

    @rebroad I've also though about it but that's not possible. JSON RPC (as it is now) is stateless. A future RPC protocol with persistent connections could (probably: should) have wallet-decryption-state per client.

  11. chjj commented at 4:51 AM on February 26, 2014: none

    NACK. This introduces a statefulness that wouldn't work together with concurrent use of the API: @laanwj, you're right. I didn't even think of that. I was shortsightedly focused on solo commandline use. For now, I figure this can still be useful in situations where an assumption like this can be made though.

  12. laanwj commented at 8:23 AM on March 7, 2014: member

    For solo command-line use you could make a script that wraps bitcoin-cli and does a walletlock immediately after every command. No need to make server-side changes.

  13. laanwj closed this on Mar 7, 2014

  14. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-29 03:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me