]> Git Repo - VerusCoin.git/commit - src/wallet.cpp
Handle corrupt wallets gracefully.
authorGavin Andresen <[email protected]>
Tue, 18 Sep 2012 18:30:47 +0000 (14:30 -0400)
committerGavin Andresen <[email protected]>
Mon, 8 Oct 2012 21:46:45 +0000 (17:46 -0400)
commiteed1785f701be93ac2464e854c2a7de1f748ef84
tree012b0bae35dfc7f35c10d341e50dd31fb88c6cf1
parent8d5f461cb6d4bb954fef5c3deebe2b2a7bdbfe27
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.

2) 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).

3) 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)
src/db.cpp
src/db.h
src/init.cpp
src/key.cpp
src/wallet.cpp
src/wallet.h
src/walletdb.cpp
src/walletdb.h
This page took 0.026357 seconds and 4 git commands to generate.