Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: gurcani on April 17, 2013, 07:46:18 AM



Title: (bug?) addresses in wallet for which the private keys are not known.
Post by: gurcani on April 17, 2013, 07:46:18 AM
I was using bitcoind 0.8.1, on a wallet.dat that was generated long time ago (probably version 0.3.22).

here is what happens:

Code:
./bitcoin-0.8.1-linux/bin/64/bitcoind getaddressesbyaccount ""
[
    "1Ev4hNhx7XKNyEi9oavr2KGYyd5QJZEpNX",
    "19CCQtViGYfBBhG8v7KcjWHu1McdgNRVhg",
    "16TkF8gpEdbt3vJufBJ6mRoThiaxnVRPvM",
    "1GSanrUFN84tDre3RZepZ3r5PU4JLirE6a",
....
]

Code:
./bitcoin-0.8.1-linux/bin/64/bitcoind dumpprivkey 1Ev4hNhx7XKNyEi9oavr2KGYyd5QJZEpNX
error: {"code":-4,"message":"Private key for address 1Ev4hNhx7XKNyEi9oavr2KGYyd5QJZEpNX is not known"}

however if I try the second address:

Code:
./bitcoin-0.8.1-linux/bin/64/bitcoind dumpprivkey 19CCQtViGYfBBhG8v7KcjWHu1McdgNRVhg
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

it spits out a private key. Similarly the 3rd address works, but the 4th one gives the same error above.

So in other words, in my wallet.dat there are some addresses to which I do not have the private keys. I noticed this when I sent 10 btcs to the address that starts with 1Ev, and could not see the transaction. Well basically, if I understand this right I do not own this address, right?

So why in the hell "getaddressesbyaccount" tells me that I do? Is this a bug? a feature that I misunderstand?

would appreciate any help.


Title: Re: (bug?) addresses in wallet for which the private keys are not known.
Post by: jackjack on April 17, 2013, 08:37:01 AM
You can try pywallet to see what is inside your wallet


Title: Re: (bug?) addresses in wallet for which the private keys are not known.
Post by: memvola on April 17, 2013, 08:58:04 AM
Yep, if you can't access the keys in the old file with pywallet --dumpwallet then it's more likely that the wallet is damaged.

If the keys are there but 0.8.1 is causing the problem, you could try bitcoind -upgradewallet and maybe bitcoind -salvagewallet.

(I also wonder whether bdb incompatibility could be the culprit there.)


Title: Re: (bug?) addresses in wallet for which the private keys are not known.
Post by: jackjack on April 17, 2013, 10:01:47 AM
I don't think so, I had a 0.3.24 wallet that worked fine once upgraded to 0.8.1


Title: Re: (bug?) addresses in wallet for which the private keys are not known.
Post by: gurcani on April 17, 2013, 10:44:42 PM

thanks for your help guys,

Unfortunately my wallet was apparently messed up even though I didn't do anything strange apart from using an old wallet file.

Here is what happened to my understanding:

I apparently sent 0.03419 to the address 1Ev4hNhx7XKNyEi9oavr2KGYyd5QJZEpNX from my wallet in 1 nov 2011. Here is the transaction:

http://blockexplorer.com/tx/738d4bb8031d71dd37bd13277f52bd92cdcd94932277294f9ad38685d812978b

I have the private keys for both of the other addresses involved in this transaction. The destination address 1Ev.. may actually belong to bitcointorrentz (looking at the amount and my usage at the time).

Since the database format is changed several times (0.4->0.6->0.8 ), some of the addresses to which I sent btcs are mixed with my own addresses and "getaddressesbyaccount" somehow reports these as if they were mine. But of course I don't have the private keys for them.

I have a back up of this wallet.dat. I will open the backup using 0.7.1 to see if getaddressesbyaccount still lists those addresses. Because if it doesn't, it means that it is somehow the 0.6->0.8 step that has corrupted my wallet. I can hopefully reduce it to an empty wallet with just the addresses involved in this transaction and run it on 0.8.1 again and see if I can reproduce the corruption.

I'll post my progress.


Title: Re: (bug?) addresses in wallet for which the private keys are not known.
Post by: gurcani on April 17, 2013, 11:13:36 PM
the same behaviour with 0.7.1 with the backup wallet (which was never opened on 0.8.1). So the wallet was already messed up.


Title: Re: (bug?) addresses in wallet for which the private keys are not known.
Post by: memvola on April 18, 2013, 09:18:34 AM
the wallet was already messed up.

Not so sure. Assuming pywallet dump listed the keys correctly (only in "names"), then this can still be a bug in bitcoind.

Also, when were "watch only" addresses introduced in Satoshi client? If there isn't a way to distinguish foreign addresses in a simple getaddressesbyaccount, I would consider that a bug too.


Title: Re: (bug?) addresses in wallet for which the private keys are not known.
Post by: gurcani on April 18, 2013, 09:09:35 PM

in the end, if bitcoind accepts to use a possibly corrupted wallet without warning, I think it would make a lot of sense that "getaddressesbyaccount" list only the addresses for which the wallet contains a private key (i.e. by explicitly checking for that before listing the addresses).

I am not sure if the opposite behaviour would ever be desirable.

then this can still be a bug in bitcoind.

It is a feature, in the M$ sense.