Misleading error on dumppriv while wallet is locked #3210

issue gwern opened this issue on November 5, 2013
  1. gwern commented at 11:49 PM on November 5, 2013: none

    Usability issue: bitcoind gives an incorrect error message when one tries to dumppriv a key while the wallet is still locked. Unlike the other commands I've tried which immediately point to the lock as the reason for the failure, dumppriv emits a frightening message that the private key does not exist (implying one has completely lost the funds at that address). The relevant code should do the same check for lock as the other commands.

    Installed version (Debian testing):

    $ apt-cache show bitcoind
    Package: bitcoind
    Status: install ok installed
    Priority: optional
    Section: utils
    Installed-Size: 2648
    Maintainer: Debian Bitcoin Packaging Team <pkg-bitcoin-devel@lists.alioth.debian.org>
    Architecture: amd64
    Source: bitcoin
    Version: 0.8.3-1
    Depends: libboost-filesystem1.49.0 (>= 1.49.0-1), libboost-program-options1.49.0 (>= 1.49.0-1), libboost-system1.49.0 (>= 1.49.0-1), libboost-thread1.49.0 (>= 1.49.0-1), libc6 (>= 2.15), libdb5.1++, libgcc1 (>= 1:4.1.1), libleveldb1, libminiupnpc5, libssl1.0.0 (>= 1.0.0), libstdc++6 (>= 4.6), zlib1g (>= 1:1.1.4)
    Suggests: db-util, db4.8-util
    ...
    

    The problem:

    $ # normal, helpful, meaningful error message with a locked wallet:
    $ bitcoind sendfrom 1AZvaBEJMiK8AJ5GvfvLWgHjWgL59TRPGy 1BWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW 1
    error: {"code":-13,"message":"Error: Please enter the wallet passphrase with walletpassphrase first."}
    
    $ # problematic error message with dumpprivkey:
    $ bitcoind dumpprivkey 1AZvaBEJMiK8AJ5GvfvLWgHjWgL59TRPGy
    error: {"code":-4,"message":"Private key for address 1AZvaBEJMiK8AJ5GvfvLWgHjWgL59TRPGy is not known"}
    
    $ # don't give me a heart attack like that - the private key *is* known! we just need to unlock the wallet:
    $   bitcoind walletpassphrase XXXXXXXXXXXXXXXXXXXX 60
    $ bitcoind dumpprivkey 1AZvaBEJMiK8AJ5GvfvLWgHjWgL59TRPGy
    KwpYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
    
  2. sipa commented at 1:41 AM on November 6, 2013: member

    Fixed in head.

  3. sipa closed this on Nov 6, 2013

  4. sipa commented at 1:42 AM on November 6, 2013: member

    Also, unrelated comment: the first argument to sendfrom is an account name to debit the send from; it doesn't take an address (or at least, if you do, it doesn't change which coins are used to construct the transaction).

  5. bitcoin locked this on Sep 8, 2021
Contributors

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-05-20 06:55 UTC