Salvaging a broken wallet.dat with 3M leafs!!Ok, I had done something wrong and I broke my original wallet.dat, and original leafcoin-qt client would not salvage it. So after a bit of googling I tried pywallet[1] and after a bit of experimentation I came up with the following solution and it worked!!
1. Copy the broken wallet.dat onto a usb stick or sd card or whatever you like (but not an encrypted filesystem!), in my case, it's on a 8GB USB stick on /dev/sdc1.
2. As root type:
# ./pywallet.py --recover --recov_device=/dev/sdc --recov_size 8Gio --recov_outputdir=.
Enter the passphrase for the wallet that will contain all the recovered keys: <passphrase in the new recovered key>
Enter the possible passphrases used in your deleted wallets.
Don't forget that more passphrases = more time to test the possibilities.
Write one passphrase per line and end with an empty line.
Possible passphrase: <passphrase in the old broken key>
Possible passphrase:
Starting recovery.
0.10 Go read
0.20 Go read
0.30 Go read
0.40 Go read
...
...
7.70 Go read
7.80 Go read
7.90 Go read
8.00 Go read
Read 8.1 Go in 4.9 minutes
Found 1 possible wallets
Found 235 possible encrypted keys
Found 0 possible unencrypted keys
Possible wallet #1
with passphrase #1 .......................
All the found encrypted private keys have been decrypted.
The wallet is encrypted and the passphrase is correct
Importing:
Importing key 1/201:
Address (Bitcoin): 14FBb4iZLKx9w9wR1QJNR3j8kWQAwobrEf
Privkey (Bitcoin): 5KBbWoUhRdAQxJnYSwKX42398TcnxpFUCmeFTQR5u3drFQrxabbHgz
Hexprivkey: b414caf874f1fe48bd5455157c6e4238470b2180b46efc95a9df59f19ec3b043036
Hash160: 239709e5902e64bd50a1ad6c8288edb434978624661087
Pubkey: 04d9b3d76d790e62977d7410fbd705ea791c147308189c4323f69ff3ecd1d0d625d907143aaf86eedecc469bb12c240343e7d1853ac12bf3b5c254e250d5252450d
Address (Bitcoin): 1ChU83UyeczXHknQmtVARdC4323Z1N47LRE
Privkey (Bitcoin): L3Fm3424DRgcYj7W1oUko16LUysM654789x3QoYMJcideNcKWCxBAFif
Hexprivkey: b414caf874f1fe48bd5455157c6e60b0b21834546efc95a9df59f19ec3b043036
Hash160: 8050a973a30c2a347242ed5424d8446847239b3fed739
Pubkey: 03d9b3d76d790e62977d7410fb42325ea791c487087308189c64fef69ff3ecd1d0d625
...
...
The new wallet ./recovered_wallet_1390767057.dat contains the 201 recovered keys
This *should* work and keep all your lost coins!
3. Change ownership of the recovered_wallet_*.dat file and copy it into your ~/.leafcoin/wallet.dat (
MAKE A BACKUP COPY OF THE EXISTING ONE IF YOU HAVE ONE).
# chown <user> recovered_wallet_*.dat
# su - <user>
$ cp ./recovered_wallet_1390767057.dat /home/<user>/.leafcoin/
Now as the user:
$ cd .leafcoin/
$ cp wallet.dat wallet.dat.bak
$ cp ./recovered_wallet_1390767057.dat wallet.dat
$ leafcoin --salvagewallet
(Note: I'm using leafcoin in the leafcoin-qt Debian package that I made public, otherwise, leafcoin-qt should work).
Voila! leafcoin scans the wallet again and displays 3M Leafs as available again!
4. Now all I have to do is send them over to my new wallet (for some reason it doesn't accept the passphrase I gave it above, but I hope to figure this out soon, good news is that I didn't lose 0.3 BTC worth of Leafs