HomePhabricator

Handle corrupt wallets gracefully.
eed1785f701bUnpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

Handle corrupt wallets gracefully.

Corrupt wallets used to cause a DB_RUNRECOVERY uncaught exception and a
crash. This commit does three things:

  1. Runs a BDB verify early in the startup process, and if there is a

low-level problem with the database:

+ Moves the bad wallet.dat to wallet.timestamp.bak
+ Runs a 'salvage' operation to get key/value pairs, and
  writes them to a new wallet.dat
+ Continues with startup.
  1. Much more tolerant of serialization errors. All errors in deserialization

are reported by tolerated EXCEPT for errors related to reading keypairs
or master key records-- those are reported and then shut down, so the user
can get help (or recover from a backup).

  1. Adds a new -salvagewallet option, which: + Moves the wallet.dat to wallet.timestamp.bak + extracts ONLY keypairs and master keys into a new wallet.dat + soft-sets -rescan, to recreate transaction history

This was tested by randomly corrupting testnet wallets using a little
python script I wrote (https://gist.github.com/3812689)

Details

Provenance
Gavin Andresen <gavinandresen@gmail.com>Authored on Sep 18 2012, 18:30
deadalnixPushed on May 14 2017, 22:04
Parents
rABC8d5f461cb6d4: Handle incompatible BDB environments
Branches
Unknown
Tags
Unknown

Event Timeline

Gavin Andresen <gavinandresen@gmail.com> committed rABCeed1785f701b: Handle corrupt wallets gracefully. (authored by Gavin Andresen <gavinandresen@gmail.com>).Oct 8 2012, 21:46