Repair a Bitcoin or Aurumcoin Wallet
    My Aurumcoin Wallet (running on Windows) has made errors and I have found this "how to" in the Bitcoin Forum after a long search.
    A second Aurum Wallet is running on Linux Raspbian on a raspberry pi 2. Raspbian includes Python so i had no problems to use this "how to".
    For repair a Wallet on a Windows PC i dont have found a usable solution.

    Thanks to the Bitcoin Forum User (cant find the article again...) who made this HowTo.


    Guide:
    • 1. BACKUP YOUR ENTIRE .bitcoin FOLDER Period, even corrupted wallets will still have useful data in them and the database folder may have enough BDB logs for a real BDB expert to fix your wallet if all of this fails.  Also, several points in the guide require you to restore the original corrupted wallet.dat, so you have to have it.
    • 2. Often times the BDB logs or other DBs get corrupted and Bitcoin refuses to start.  Delete all the files in your .bitcoin directory except for your wallet.dat and try Bitcoin again.  This should solve 90% of the corrupted DB errors you see with Bitcoin.  If this doesn't work, the corruption lies in your wallet, but don't worry, it should still be fixable.
    • 3. Grab yourself a copy of Gavin's excellent bitcointools either by using git clone https://github.com/gavinandresen/bitcointools.git or by using the download tar.gz from https://github.com/gavinandresen/bitcointools.  Untar it to a directory of your choice and cd /path/to/that/directory in your Terminal application.
    • 4. First, lets do a basic sanity check on the wallet.  Call ./dbdump.py --wallet once you have cd'd to the bitcointools directory.  You should get some out put that looks like
      Quote
      PubKey 0402...de94 1XXXXXXXXXXXXXXXXXXXXXXXXXX: PriKey 3082...de94
      some that looks like
      Quote
      ADDRESS 11XXXXXXXXXXXXXXXXXXXXXXXXXX :
      Quote
      Change Pool key 1: 1XXXXXXXXXXXXXXXXXXXXXXXXXX (Time: Fri May 27 16:27:28 2011)
      and finally some settings like
      Quote
      fUseUPnP: True
      If some of those are missing, dont worry, all that really matter is the first type, which contains your bitcoin private keys. As long as you dont see any errors along the lines of ERROR parsing wallet.dat, type key, ekey, or wkey, and you have several lines of the first type, you should have no problem getting access to your bitcoins. If you dont have any lines that look like the first then you are going to have to work a bit harder to get your keys back, which is outside of the scope of this post.
    • 5. Now that you know your wallet still has your private keys in a readable state, its time to recover.  Run ./fixwallet.py and replace your old wallet.dat with walletNEW.dat that bitcointools just created in your bitcoin folder.  If you see several ERROR messages that are of a type other than key, you know it is working.  Try to open Bitcoin, you may find that it opens perfectly now, or you may find several issues in this wallet wrt your settings, accounts, etc which you may need to re-enter.  If you want to clear your accounts, transactions, settings, etc or Bitcoin still isnt working for you, keep reading.
    • 6. This involves some trial-and-error.  The goal here is to run ./fixwallet.py with options to drop the corrupted parts of your wallet.  The options are --noaccounts, --nosettings, --notxes and --nopubkeys.  First off, replace the wallet.dat you created in step 5 with the original, corrupted, one.  Then run ./fixwallet.py --noaccounts --nosettings --notxes --nopubkeys; replace your wallet.dat in your .bitcoin folder with walletNEW.dat and see if Bitcoin opens (note that your transactions and balance will be gone when you use --notxes, this is intentional, read on for instructions on how to get them back).  If Bitcoin doesnt open, the recovery of your wallet falls outside the scope of this guide; you might try asking an expert who you trust to see if they can get further.  If it does work, however, repeat this step with less and less flags until Bitcoin refuses to open.
      If you used --notxes, open Bitcoin with -rescan to repopulate them from the block database. DO NOT use the --notxes option if you had transactions in your wallet which are not yet in a block.
      If you used --noaccounts, you will need to recreate your accounts.
      If you used --nopubkeys your list of public keys in your address book may be cleared, note that your old addresses will still work, however you may wish to change your publicized addresses to those which you can add to your address book so that they appear properly in your client.
      If you used --nosettings, please go back to the Options dialog and re-enter all your settings.  

    Comments, suggestions, sticky?