Author

Topic: How does salvagewallet work? (Read 939 times)

staff
Activity: 3374
Merit: 6530
Just writing some code
August 13, 2017, 01:57:58 PM
#9
How does it find private keys if the wallet.dat is encrypted?.
The encryption used in Bitcoin Core is not a wallet file encryption. It does not encrypt the whole file. Rather it encrypts individual keys and stores those encrypted keys. So only the keys are encrypted, and they have a record type of ckey. This individual key encryption is what allows you to get new addresses and see your transactions and wallet balance even when your wallet is not unlocked.
full member
Activity: 217
Merit: 109
August 13, 2017, 05:00:53 AM
#8
How does it find private keys if the wallet.dat is encrypted?.
staff
Activity: 3374
Merit: 6530
Just writing some code
August 12, 2017, 06:22:01 PM
#7
At what stage does de encryption take place
None. Wallets are not decrypted or encrypted during the salvage wallet process; there is no need to do that.

and what is usually left in a wallet. bak file when salvage has failed. Thanks.
The .bak files are backup files that are produced before salvagewallet begins the actual salvage. The .bak files are a copy of the original wallet file.
full member
Activity: 217
Merit: 109
August 12, 2017, 03:43:43 PM
#6
At what stage does de encryption take place and what is usually left in a wallet. bak file when salvage has failed. Thanks.
staff
Activity: 3374
Merit: 6530
Just writing some code
August 10, 2017, 01:50:31 PM
#5
The Bitcoin Core wallet is a Berkeley DB database. It consists of key-value pairs.

Salvage wallet calls BDB DB->verify() function with the DB_AGGRESSIVE flag which will result in it outputting any and all key-value pairs that it can find, even ones that were deleted or corrupted. This means that -salvagewallet can find key-value pairs that normally wouldn't be in your wallet.

These key value pairs are then scanned. Anything that has a key that begins with the strings key, ckey, wkey, or mkey will be pulled out and written to a new database file. It is important to note that those records are not checked for consistency. They are simply passed through. If the rest of the key (which usually contains a public key) or the value of the pair (which may contain the private key) is corrupted, salvagewallet will not detect it and will not be able to do anything to fix it. salvagewallet is only for recovering key type key-value pairs from a badly corrupted wallet. It cannot help you if the public or private keys themselves are corrupted. Lastly, using savagewallet on an non-corrupted wallet may result in that wallet becoming corrupted.
HCP
legendary
Activity: 2086
Merit: 4316
August 10, 2017, 06:33:18 AM
#4
It makes a copy of a wallet.dat (typically one that has been corrupted) and then crawls through your wallet.dat, which is essentially a "database" file... and attempts to find private keys. I suspect by looking for particular byte sequences, but I'm not 100% sure on that.

I believe it just dumps any "detected" private keys into a a text file... detected does not necessarily mean your actual private keys... just sequences of bytes that match the length and format of a private key.
member
Activity: 77
Merit: 10
August 10, 2017, 05:37:50 AM
#3
I am not @OP, but I used google and found the suggested link BEFORE I found this thread, and many many others. And I have yet to find anything that really explains in detail what salvagewallet does, and how you actually get old coins out of a corrupt wallet with it, and into a fresh wallet. I'll keep searching but most of what you get with a google search is "i tried salvagewallet and it didn't work, now what?"
full member
Activity: 158
Merit: 113
newbie
Activity: 55
Merit: 0
July 03, 2017, 10:54:22 AM
#1
How does salvagewallet work?
What is salvagewallet?
What it's benefits of salvagewallet?
Thank You.
Jump to: