some of my private keys are missing #4178

issue dooglus opened this issue on May 12, 2014
  1. dooglus commented at 5:48 PM on May 12, 2014: contributor

    I've never seen this before.

    I just loaded up an old testnet wallet and found that some of the private keys I used to own have vanished:

    $ bitcoind walletpassphrase x 3600
    error: {"code":-15,"message":"Error: running with an unencrypted wallet, but walletpassphrase was called."}
    
    $ bitcoind getaddressesbyaccount ''
    [
        "n3rgfbvt2myWMK6gtekn6KSyJrNgDWfF5H",
        "n21TdXU5n8mTdnc7uFrA4pbs6QKormZsUA",
        "moz7nZfeZ7pQGSS4n1CNSFMYbrEGtBvLFd",
        "mnBRLvDQMkG9NDvuzuN22xdUVUxMzBcyHG",
        "moqxRhczUYbXEwymbG4wZVSfyfkiWbRr31",
        "muuCbD5LBmcMcUnAzGMkoXR6sjH6jf9m1f",
        "mykSB9TDksJiSZoXYyqsFzARTri8h6Ync7",
        "msCfFPupThiNebaGmLsT8LMnFRByTwGwRW",
        "n34mhLjFfrb6ZRdYD9QbTy8P5tVVBy4kYQ"
    ]
    
    $ bitcoind dumpprivkey n34mhLjFfrb6ZRdYD9QbTy8P5tVVBy4kYQ
    error: {"code":-4,"message":"Private key for address n34mhLjFfrb6ZRdYD9QbTy8P5tVVBy4kYQ is not known"}
    
    $ bitcoind dumpprivkey n21TdXU5n8mTdnc7uFrA4pbs6QKormZsUA
    cT[...]28
    

    Any idea what has happened here?

    I built from commit c63b2e25a59c602de182a376313ad5d3d62d5045.

  2. gmaxwell commented at 5:53 PM on May 12, 2014: contributor

    Are they all gone? Any chance you've salvagewallet-ed this wallet? I have a testnet wallet that loses all its private keys after going through a salvage wallet.

  3. dooglus commented at 5:58 PM on May 12, 2014: contributor

    I think what may have happened is that getaddressesbyaccount is now listing addresses from my address book, and not just my own addresses. I checked the transaction history in this wallet, and it appears that I still have the private key for any address that has received coins. So perhaps the ones which are missing private keys never had them.

    I think getaddressesbyaccount used to only list addresses I owned. Has that behaviour recently changed?

    I don't think I've ever run salvagewallet.

  4. dooglus commented at 6:13 PM on May 12, 2014: contributor

    Are they all gone?

    No, the last 2 lines I pasted shows one of the addresses still has its privkey available. I replaced most of the output with [...], but the full privkey was reported.

    I also have a bunch of change addresses which have their privkeys available even though they're not listed in the getaddressbyaccount output.

  5. laanwj commented at 4:37 AM on May 13, 2014: member

    @dooglus Using the account system together with labels in the GUI can result in confused output by some commands, that has always been the case. They use the same underlying data structures in different ways. I'd strongly suggest you don't mix these usages. You can't lose keys that way, though.

    Change addresses are never listed in getaddressesbyaccount output, as they are not assigned to an account.

  6. dooglus commented at 2:55 PM on May 13, 2014: contributor

    My initial confusion was a result of just using bitcoind. I wasn't running the gui at all at that point.

    The thing I still don't understand is:

    $ bitcoind validateaddress n34mhLjFfrb6ZRdYD9QbTy8P5tVVBy4kYQ
    {
        "isvalid" : true,
        "address" : "n34mhLjFfrb6ZRdYD9QbTy8P5tVVBy4kYQ",
        "ismine" : false,
        "account" : ""
    }
    

    what does it mean for an address to have an 'account' when it's not 'mine'? Is that meant to ever happen?

  7. laanwj commented at 3:06 PM on May 13, 2014: member

    If you used the GUI and edited address book labels, it can happen (as I said - labels and accounts use the same internal data structures), if you never used the GUI it shouldn't happen.

  8. dooglus commented at 3:08 PM on May 13, 2014: contributor

    Oh, I see. That's probably it then. Thanks.

  9. 7queue commented at 9:42 PM on May 16, 2014: none

    Expected results versus observed results from linux command line, no gui used?

    ./bitcoin-cli listaccounts { "" : 0.00000000 }

    Is that an account?

    ./bitcoin-cli getaccountaddress "" myujLNaDastQdGvuqcxUBhvi5HqRcGeFya

    Using getaccountaddress with "" as returned by listaccounts creates an account """"?

    ./bitcoin-cli listaccounts { "" : 0.00000000, """" : 0.00000000 }

    If I then issue getaccountaddress with '' another account is created

    ./bitcoin-cli getaccountaddress '' mmRKyfinHRMNx3Jzmn2xq5EeEChEkb35DA

    ./bitcoin-cli listaccounts { "" : 0.00000000, """" : 0.00000000, "''" : 0.00000000 }

    To me it doesn't look like any keys have been lost, only that the name/label for "" can't be accessed from the command line?

    So, is "" an account? Or is it used internal to contain the spent balance?

    I guess looking at the code will answer my question. I was wondering the same thing about the keys.

    8 )

    On Tue, May 13, 2014 at 11:08 AM, Chris Moore notifications@github.comwrote:

    Oh, I see. That's probably it then. Thanks.

    — Reply to this email directly or view it on GitHubhttps://github.com/bitcoin/bitcoin/issues/4178#issuecomment-42967549 .

  10. laanwj closed this on Jul 31, 2014

  11. MarcoFalke 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-16 00:15 UTC

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