Rescan and track sync status of imported addresses.

The private key import codepath (called when handling the
importprivkey RPC method) was not triggering rescans for the imported
address.  This change begins a new rescan for each import and adds
additional logic to the wallet file to keep track of unsynced imported
addresses.  After a rescan on an imported address completes, the
address is marked as in sync with the rest of wallet and future
handshake rescans will start from the last seen block, rather than the
import height of the unsynced address.

While here, improve the logging for not just import rescans, but
rescanning on btcd connect (part of the handshake) as well.

Fixes .
This commit is contained in:
Josh Rickmar 2014-03-17 09:24:14 -05:00
parent e358da905a
commit 089fa9de18
5 changed files with 255 additions and 37 deletions

View file

@ -643,7 +643,7 @@ func ImportPrivKey(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
// Import the private key, handling any errors.
bs := &wallet.BlockStamp{}
switch _, err := a.ImportPrivateKey(pk, compressed, bs); err {
switch _, err := a.ImportPrivateKey(pk, compressed, bs, cmd.Rescan); err {
case nil:
// If the import was successful, reply with nil.
return nil, nil