There was an issue raised this week where unfortunately the user lost 53 BTC.
It is here:
https://github.com/jim618/multibit/issues/173It was caused by a combination of:
+ the laptop completely run out of juice multiple times (this eventually foiled the rolling wallet backups)
+ having the wallet unencrypted (i.e. no automatic private key exports available)
+ no manually created wallet backups
+ no manually created private key exports
I have been thinking of how to improve the MultiBit wallet/ private key backups and thought I would write up what I plan to do.
Current file structureSay your wallet is called 'savings'. The timestamps below are just examples.
There is currently stored:
+ savings.wallet (The main wallet, private keys + transactions etc)
+ savings.info (Labelling info)
+ savings-20130605111604.wallet (Rolling wallet backup)
+ savings-20130605111203.key (Encrypted wallets only. Encrypted private key export, created when new keys added or password changes)
New file structureI am thinking of changing it to:
+ savings.wallet
+ savings.info
+ savings-data (A directory. The name of the wallet suffixed with '-data')
+ savings-data/rolling-backup (A directory to store rolling backups)
+ savings-data/key-backup (A directory to store the private key exports for encrypted wallets)
+ savings-data/wallet-backup (A directory to store wallet backups for encrypted wallets)
+ savings-data/wallet-unenc-backup (A directory to store wallet backups for unencrypted wallets)
The rolling backups and the private key exports would be the same.
in addition both encrypted and unencrypted wallets would be backed up into their respective directories in the format:
"name of wallet"-"timestamp".wallet e.g. savings-20130505120617.wallet
New wallet backups would be made when the wallet is first created, new keys are added to the wallets or when the password changes.
They are stored in separate directories because when you encrypt an unencrypted wallet you want to make sure there are no unencrypted keys left on disk. When an unencrypted wallet is encrypted, all the wallets in the saving-data/wallet-unenc-backup directory will be AES 256 encrypted using the wallet password you are using. The unencrypted backups will be secure deleted.
There will be a maximum number of wallets in the backup directories, say, 60. Once the limit is reached new wallet backups will 'thin out' the existing backups. The backup that is most quickly replaced by a later backup will be deleted. Delete will be a secure delete. (I might always keep the first few backups and last few as
aglets).
When a password is changed with this scheme you still have encrypted wallets and private key exports using the old password(s). I'll put a warning message up to mention this but am reluctant to delete them automatically - deleting stuff like this is a good way of losing your private keys. Very secure minded users will have to delete these manually.
I think this scheme offers more protection to the user (especially when they have unencrypted wallets as they will have some automatic backups now) without complicating matters too much (complicated things have a habit of breaking just when you need them).
The new 'per-wallet' directory in which the backups are stored would also tidy things up. It would also be a good location to store other wallet specific things in the future (eg a per-wallet blockstore which would speed up resyncs).
edit: Changed wallet backup replacement algorithm to 'thinning out' from 'median deleting'.
edit: Changed example wallet name, backup directory names, number of backups to match what is actually implemented.