Commit graph

5 commits

Author SHA1 Message Date
Josh Rickmar
18fb993d0b Implement address rescanning.
When a wallet is opened, a rescan request will be sent to btcd with
all active addresses from the wallet, to rescan from the last synced
block (now saved to the wallet file) and the current best block.

As multi-account support is further explored, rescan requests should
be batched together to send a single request for all addresses from
all wallets.

This change introduces several changes to the wallet, tx, and utxo
files.  Wallet files are still compatible, however, a rescan will try
to start at the genesis block since no correct "last synced to" or
"created at block X" was saved.  The tx and utxo files, however, are
not compatible and should be deleted (or an error will occur on read).
If any errors occur opening the utxo file, a rescan will start
beginning at the creation block saved in the wallet.
2013-11-01 10:06:38 -04:00
Josh Rickmar
4b7f858bee Close() temp files before renaming them.
Fixes syncing dirty wallet files on Windows.
2013-10-23 18:40:02 -04:00
Josh Rickmar
b5b684127c Remove debugging that slipped in. 2013-10-15 17:06:35 -04:00
Josh Rickmar
2782b7815e Sync wallet files to disk as needed, instead of waiting for a timer.
While fixing this code, the dirty flag was also cleared so that
unneeded syncs wouldn't be needed later.  The dirty flag set and sync
was also added for the 'getnewaddress' handler, as it was previously
missing.
2013-10-15 17:00:42 -04:00
Josh Rickmar
284191ec4b Sync wallet, utxo, and tx files to disk.
This runs a syncer once every minute to write any dirty wallet data
structures out to disk.  As currently implemented, dirty wallets will
be lost if not written before btcwallet closes or crashes.
Deterministic wallet help migitate this issue (as private keys can be
created again as long as a previous wallet file was written) but this
can still be a nuisance as a longer rescan will be required to catch
up to chain.
2013-10-15 15:53:49 -04:00