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. eu1.bitcoincharts.com/blockchain – Stephen Gornick Apr 30 '12 at 18:46
  • @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 Apr 30 '12 at 18:54
  • 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 Apr 30 '12 at 23:01
  • Thanks for going to the effort of documenting what you did to fix the problem – Highly Irregular May 2 '12 at 22:23
  • 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 Aug 7 '12 at 9:00
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.

  • 1
    Would "recovery mode" possibly make my old wallet work again with versions of bitcoin later than 0.4.1? – Adam Monsen May 1 '12 at 19:36
  • 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 May 1 '12 at 21:53
  • I mean, I want to make my old wallet work with newer versions of bitcoin... I don't care about older versions. :) – Adam Monsen May 1 '12 at 23:49
  • 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 May 2 '12 at 23:07
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 May 1 '12 at 4:15
  • 2
    Perhaps 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 May 1 '12 at 8:03
  • aye, I think that (or waiting for 0.7.0) might be the only straightforward way out of this mess. – Adam Monsen May 1 '12 at 15:04
  • 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 May 1 '12 at 15:11
  • 1
    It'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 May 1 '12 at 15:49
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.