BitShares Forum

Other => Graveyard => BitShares PTS => Topic started by: dacer on December 21, 2013, 02:03:54 pm

Title: Wallet got corrupted
Post by: dacer on December 21, 2013, 02:03:54 pm
I really need help now, especially from 3I engineers.

For some reason, my original wallet (wallet1) only shows 2 addresses, but their balance doesn't add up. So I think maybe there are a third 'change address'. And yes, I verified by looking into the transaction information online (btsblock.com). So I decided to aggregate all balance into one of the 2 address shown.

What I did is to quit the client, move my wallet.dat file into another place (wallet1_backup), restart client, copy the new address (Addr1) in the new wallet (wallet2), then switch back to wallet1(by "cp wallet_backup wallet.dat"), transferred all my PTS (~1000) into the new address. Then I probably did something very stupid. I just "mv wallet2_backup wallet.dat" WHILE the client is still open. Then when I quit the client, I got "wallet.dat corrupt, salvage failed", and I got something like wallet.1387632779.bak.

After I restarted the client, I found I have a fresh new address Addr2 which is not the one I sent all my PTS to.

Is there a way I can restore wallet.1387632779.bak somehow? I eagerly wait for help from the community.
Title: Re: Wallet got correpted
Post by: arubi on December 21, 2013, 02:41:07 pm
Clone pyWallet
https://github.com/jackjack-jj/pywallet (https://github.com/jackjack-jj/pywallet)

Run this from /pywallet :

Code: [Select]
python pywallet.py --wallet=wallet.dat --datadir=$HOME/.protoshares/ --otherversion=56 --dumpwallet >> wallet-recovery.txtpyWallet does a better job at recovering wallets than the satoshi client.
Good luck !
Title: Re: Wallet got correpted
Post by: dacer on December 21, 2013, 03:08:50 pm


Thanks arubi, but I got error when I run this command
Code: [Select]
python pywallet/pywallet.py --wallet=a/wallet.1387632456.bak --datadir=/Users/dong/.protoshares --otherversion=56 --dumpwallet

I got this error:

Code: [Select]
ERROR:root:Couldn't open wallet.dat/main. Try quitting Bitcoin and running this again.

Maybe I used he wrong 'otherversion' value?
Title: Re: Wallet got correpted
Post by: arubi on December 21, 2013, 03:10:36 pm
No the version is fine, I used it on test wallet.

Is your wallet encrypted?
Also, are protosharesd or protoshares-qt running?
Title: Re: Wallet got correpted
Post by: dacer on December 21, 2013, 03:21:27 pm
No the version is fine, I used it on test wallet.

Is your wallet encrypted?
Also, are protosharesd or protoshares-qt running?

It's not encrypted and neither protosharesd nor protoshares-qt is running.
Title: Re: Wallet got correpted
Post by: arubi on December 21, 2013, 03:25:18 pm
No the version is fine, I used it on test wallet.

Is your wallet encrypted?
Also, are protosharesd or protoshares-qt running?

It's not encrypted and neither protosharesd nor protoshares-qt is running.

It says
Code: [Select]
--wallet=a/wallet.1387632456.bak
That's not right, notice the /a
Title: Re: Wallet got corrupted
Post by: dacer on December 21, 2013, 03:33:53 pm
The leading 'a/' is the directory I backuped my wallet files. It's not the problem.

I now successfully dumped a lot of data into a output file using this command:

Code: [Select]
python pywallet/pywallet.py --wallet=/Users/dong/.protoshares/wallet.dat  --datadir=/Users/dong/.protoshares/ --otherversion=56 --dumpwallet >> ~/Desktop/wallet-recovery3.txt

I'm not sure this 'wallet.dat' file has anything to do with the address I sent my PTS to.

In the dump output file, however, I cannot find the address information for the particular address I sent all my PTS to. Is it because I haven't ever used that fresh address to send out PTS? Where does all these address information saved? I noticed there are several db files. What are they?

Code: [Select]
-rw-r-----   1 dong  macports   24576 Dec 21 23:24 __db.001
-rw-r-----   1 dong  macports  237568 Dec 21 23:24 __db.002
-rw-r-----   1 dong  macports  270336 Dec 21 23:24 __db.003
-rw-r-----   1 dong  macports   98304 Dec 21 23:24 __db.004
-rw-r-----   1 dong  macports  729088 Dec 21 23:24 __db.005
Title: Re: Wallet got corrupted
Post by: arubi on December 21, 2013, 03:43:38 pm
Isn't this the name of the corrupt wallet?

wallet.1387632456.bak

Why dump the new wallet.dat?

pywallet has more options. Try using --dumpwithbalance instead of --dumpwallet to see the balances.

I don't really know about the __db.00# files

 
Title: Re: Wallet got corrupted
Post by: dacer on December 21, 2013, 03:52:55 pm
I tried each and every wallet.xxxxxxxx.bak files, but they all give me this same error:

Code: [Select]
ERROR:root:Couldn't open wallet.dat/main. Try quitting Bitcoin and running this again.
Title: Re: Wallet got corrupted
Post by: arubi on December 21, 2013, 04:06:02 pm
Well, this doesn't look good, maybe try a file recovery program like testdisk?
Title: Re: Wallet got corrupted
Post by: dacer on December 21, 2013, 04:28:53 pm
I wonder what are the information inside those wallet.xxxxxx.bak files, if non of them can be parsed correctly, then they might just be different than the wallet files. What are these bak file designed for? There must be someway to use them...
Title: Re: Wallet got corrupted
Post by: arubi on December 21, 2013, 04:31:54 pm
try using :

Code: [Select]
xxd wallet.xxxxxx.bak wallet.hex
and see if it shows any public keys in that text
Title: Re: Wallet got corrupted
Post by: dacer on December 21, 2013, 05:01:26 pm
xxd is just some command I guess, right?
Title: Re: Wallet got corrupted
Post by: arubi on December 21, 2013, 05:33:29 pm
xxd is used for performing a hex dump of the wallet files
if we can see public keys in there, then we know there are probably private keys too
Title: Re: Wallet got corrupted
Post by: dacer on December 21, 2013, 06:28:44 pm
I used this command to recover my lost pub/pri keys:
Code: [Select]
python ~/Desktop/pywallet/pywallet.py --recover --recov_device=tmp/wallet.1387632779.bak  --recov_size 2Mo --recov_outputdir=. --otherversion=56
  614 
And I got output like this:
Code: [Select]
Importing key   92/101:
Address (Bitcoin): 1FpiFBir5dWYPs8jgPWPQmL2buVVLpDH
Privkey (Bitcoin): 5KGKxM4w4SkM63YrFswNADT7bmvdf7JotG7sQ2NT2xygk1H
Hexprivkey: bed341dcfd51c3ab55eeece4ad681788b9e6ed276bbcea529e394a01c09909
Hash160: a297bd8b537dab2b82259c94b9f55e7a480260bc
Pubkey: 04cefe4dd00d2b10b5f879b41ec328ab8c3ff800d796d9ca6c9426b32853175ce8b0c835142778c72b2da1b1d6ad7b6fc91ff7d63f9d17ba5332eb66fbcbaed
Address (Bitcoin): 1P1Z999H9D5tqgdCEZ9Kwju9FE67yCZ
Privkey (Bitcoin): L3cefTdaMcCeVdfFaQfpxRnVxG8VHoCqbwFKSd4qwuYvUcX9F
Hexprivkey: bed341dcfd5123ab55eeece4ad681788a9e6ed276bbcea529e394a01c09909
Hash160: f16d98ae3eb037efc32eefcb4cb45f3a75db4f
Pubkey: 03cefe4dd0d2b1c0b5f879b41ec28ab80c3ff800d796d9ca6c9426b32853175c

But I noticed all addresses start with "1" instead of "P" as seen in my protoshares client. Does anyone know how I can right this?
Title: Re: Wallet got corrupted
Post by: dacer on December 21, 2013, 06:29:46 pm
I'll give out 10% to people who helped recover my PTS :)
Title: Re: Wallet got corrupted
Post by: arubi on December 21, 2013, 07:07:25 pm
I used this command to recover my lost pub/pri keys:
Code: [Select]
python ~/Desktop/pywallet/pywallet.py --recover --recov_device=tmp/wallet.1387632779.bak  --recov_size 2Mo --recov_outputdir=. --otherversion=56
  614 
And I got output like this:
Code: [Select]
Importing key   92/101:
Address (Bitcoin): 1FpiFBir5dWYPs8jgPWPQmL2buVVLpDH
Privkey (Bitcoin): 5KGKxM4w4SkM63YrFswNADT7bmvdf7JotG7sQ2NT2xygk1H
Hexprivkey: bed341dcfd51c3ab55eeece4ad681788b9e6ed276bbcea529e394a01c09909
Hash160: a297bd8b537dab2b82259c94b9f55e7a480260bc
Pubkey: 04cefe4dd00d2b10b5f879b41ec328ab8c3ff800d796d9ca6c9426b32853175ce8b0c835142778c72b2da1b1d6ad7b6fc91ff7d63f9d17ba5332eb66fbcbaed
Address (Bitcoin): 1P1Z999H9D5tqgdCEZ9Kwju9FE67yCZ
Privkey (Bitcoin): L3cefTdaMcCeVdfFaQfpxRnVxG8VHoCqbwFKSd4qwuYvUcX9F
Hexprivkey: bed341dcfd5123ab55eeece4ad681788a9e6ed276bbcea529e394a01c09909
Hash160: f16d98ae3eb037efc32eefcb4cb45f3a75db4f
Pubkey: 03cefe4dd0d2b1c0b5f879b41ec28ab80c3ff800d796d9ca6c9426b32853175c

But I noticed all addresses start with "1" instead of "P" as seen in my protoshares client. Does anyone know how I can right this?

try to use the --otherversion=56 flag before the other ones

Quote
I'll give out 10% to people who helped recover my PTS (https://bitsharestalk.org/Smileys/aaron/smiley.gif)
only me here that i can see right now :)
Title: Re: Wallet got corrupted
Post by: dacer on December 22, 2013, 09:19:45 am
OK, I think the pywallet script is still buggy, I'll spend sometime on it first.
Title: Re: Wallet got corrupted
Post by: dacer on December 24, 2013, 09:41:41 am
xxd is just some command I guess, right?

@arubi, PM me your PTS address, I'll give you some PTS for helping me out here.
Title: Re: Wallet got corrupted
Post by: arubi on December 24, 2013, 09:42:54 am
xxd is just some command I guess, right?

@arubi, PM me your PTS address, I'll give you some PTS for helping me out here.

Okay :)