12

I've been using bitcoin for over a year now without issues. It's been a while since I fired up a bitcoin client though, at least a couple months.

When I try running a bitcoin client (bitcoin-qt version 0.6.0-oneiric0) today, I get the error message

Error loading wallet.dat: Wallet corrupted


I generally use GPG to encrypt and decrypt wallet.dat, and I only have backups of the encrypted wallet.dat.gpg file. I encrypt and decrypt the file only while bitcoin is not running.

I tried following https://bitcointalk.org/index.php?topic=11331.0 . The tools appeared to work (dbdump.py --wallet doesn't throw any errors and spits out what looks like proper wallet contents), but after fixing my wallet with fixwallet.py I get the same "Wallet corrupted" error from the bitcoin client.

The bitcoin client works fine if I blow away my ~/.bitcoin directory.

I'm using 32-bit Ubuntu 11.10 desktop.

I also tried installing the latest bitcoin Qt client on Windows, but that also reports wallet.dat is corrupted.

I tried using a Linux binary from bitcoin.org, and I get this error message:

************************
EXCEPTION: 22DbRunRecoveryException
DbEnv::open: DB_RUNRECOVERY: Fatal error, run database recovery
bitcoin in Runaway exception

terminate called after throwing an instance of 'DbRunRecoveryException'
what():  DbEnv::open: DB_RUNRECOVERY: Fatal error, run database recovery
Aborted


This may be related: https://github.com/bitcoin/bitcoin/issues/809

# Update Mon, 30 Apr 2012 21:45:00 -0700

I ended up trying a bunch of older versions of the bitcoin client, and version 0.3.24-beta reads the wallet just fine! What the heck!?! Gotta be a bug in bitcoin. Now I just need to figure out a way to safely "upgrade" my wallet so it works with 0.6, I guess.

# Update Mon, 30 Apr 2012 22:00:00 -0700

Bitcoin 0.4.1 is able to work with everything in my ~/.bitcoin dir. 0.5.4rc3 and 0.6.0 do not work.

Is there some way to serialize the wallet data as plain text? Man, I hate BerkeleyDB.

# Update Wed, 02 May 2012 10:43:19 -0700

Using Bitcoin 0.4.1 with my old wallet (which apparently contains something corrupt), I was able to transfer my balance to a new wallet created from scratch with Bitcoin 0.6.0.

Why do you say it is the wallet itself that is giving the error?

Try using just wallet.dat and, for troubleshooting, a copy of the blockchain. http://eu1.bitcoincharts.com/blockchain

– Stephen Gornick – 2012-04-30T18:46:15.060

@StephenGornick: I've tried starting bitcoin with only wallet.dat in ~/.bitcoin/ and I still get Error loading wallet.dat: Wallet corrupted. Would it help to try the same thing but with a blockchain downloaded from the link you specified? – Adam Monsen – 2012-04-30T18:54:44.063

Having a copy of the blockchain won't help, no. If you get an error message with no blockchain, you'll get the same error after downloading the blockchain. – Chris Moore – 2012-04-30T23:01:41.167

Thanks for going to the effort of documenting what you did to fix the problem – Highly Irregular – 2012-05-02T22:23:43.670

I had the same issue but didn't want to go through the trouble of downgrading, create new wallet, upgrade.. So instead I tried to delete everything except for the 'wallet.dat' file. This worked. Although now it has to reprocess all transactions from start – mikabytes – 2012-08-07T09:00:46.850

6

Version 0.6.0 introduced more strict validity checks on the keys when loading a wallet, to prevent silent further corruption. It seems like you have a wallet where one or more keys are corrupted (the private and public one don't match, for example). You can try moving the funds away using an older version, but there is a chance that will fail.

I intend to add a sort of "recovery mode" in 0.7.0 for situations like this.

1Would "recovery mode" possibly make my old wallet work again with versions of bitcoin later than 0.4.1? – Adam Monsen – 2012-05-01T19:36:46.827

That's not because of the wallet format, but because of BDB. Their database files are not backward-compatible, and some versions ago we upgraded from bdbd 4.7 to 4.8. You can dump/load them to create an identical wallet file that is compatible with older versions though. – Pieter Wuille – 2012-05-01T21:53:21.523

I mean, I want to make my old wallet work with newer versions of bitcoin... I don't care about older versions. :) – Adam Monsen – 2012-05-01T23:49:24.720

In normal cases, an old wallet (even down to the earliest releases) will keep working in new clients, there is no problem with compatibility. If your wallet is corrupted, you'll get into problems anyway with it. – Pieter Wuille – 2012-05-02T23:07:56.977

3

This is kind of obvious, but have you tried going back through your backups, newest first, and using the first one which works?

You'll need to GPG decrypt the backup of course, but I hope that's not a problem.

Edit: I know you said you tried with just wallet.dat in ~/.bitcoin/ but could it be that you left the ~/.bitcoin/database/ directory with logfiles in it? If so, old logfiles could be causing the problem.

That's sound advice, thank you. Actually, I ended up trying a bunch of older versions of the bitcoin client, and version 0.3.24-beta reads the wallet just fine! What the heck!?! Gotta be a bug in bitcoin. Now I just need to figure out a way to safely "upgrade" my wallet so it works with 0.6, I guess. – Adam Monsen – 2012-05-01T04:15:02.543

2Perhaps you would like to create a new wallet using 0.6 and transfer the contents of the old one to the new one using 0.3.24, then make the old one available for test purposes. I don't know if this is a known bug, but I've not heard of it before. You'll lose your transaction history and get a new set of addresses this way, so you'll need to update the people who send you coins. – Chris Moore – 2012-05-01T08:03:48.977

aye, I think that (or waiting for 0.7.0) might be the only straightforward way out of this mess. – Adam Monsen – 2012-05-01T15:04:05.403

say I am able to successfully move my bitcoins to another wallet. What happens if someone tries to send money to one of my old addresses? – Adam Monsen – 2012-05-01T15:11:54.363

1It'll go to the old wallet. That's what I was getting at with "you'll need to update the people who send you coins" - tell them your new address(es). – Chris Moore – 2012-05-01T15:49:07.373

I was able to transfer my balance to a new wallet. Would you like the old (empty) wallet? Or do you know someone who might? Email me at haircut (gmail) if so. – Adam Monsen – 2012-05-02T17:42:55.200

It seems, according to Pieter's answer, that this is a known problem, so I guess it's not necessary. – Chris Moore – 2012-05-02T21:46:35.650

1

I had the same problem but it has only been a few days since I fired up bitcoin and there had been no changes to my computer.

I have found that you can copy out your wallet.dat, delete everything in the bitcoin directory/folder, and bitcoin will run with no error.

Then immediately close bitcoin, copy your wallet back to the folder and restart - wallet.dat reads fine and all my coins are there.

The downside is having to spend a ton of time to download the entire block chain again :(

But it works.

Louis

I use Linux Mint (Like Ubuntu) - Winblows users may not have the same results.