wallet/wallet: prompt sanity check upon setting new birthday block within ImportPrivateKey

In this commit, we set the verified bit to false upon setting the new
birthday block to ensure its correctness as it was provided by the caller.
This commit is contained in:
Wilmer Paulino 2018-11-15 18:00:43 -08:00
parent 16ea72e95b
commit bd95bfa6fb
No known key found for this signature in database
GPG key ID: 6DF57B9F9514972F

View file

@ -2684,7 +2684,7 @@ func (w *Wallet) ImportPrivateKey(scope waddrmgr.KeyScope, wif *btcutil.WIF,
// before our current one. Otherwise, if we do, we can // before our current one. Otherwise, if we do, we can
// potentially miss detecting relevant chain events that // potentially miss detecting relevant chain events that
// occurred between them while rescanning. // occurred between them while rescanning.
birthdayBlock, err := w.Manager.BirthdayBlock(addrmgrNs) birthdayBlock, _, err := w.Manager.BirthdayBlock(addrmgrNs)
if err != nil { if err != nil {
return err return err
} }
@ -2696,7 +2696,11 @@ func (w *Wallet) ImportPrivateKey(scope waddrmgr.KeyScope, wif *btcutil.WIF,
if err != nil { if err != nil {
return err return err
} }
return w.Manager.SetBirthdayBlock(addrmgrNs, *bs)
// To ensure this birthday block is correct, we'll mark it as
// unverified to prompt a sanity check at the next restart to
// ensure it is correct as it was provided by the caller.
return w.Manager.SetBirthdayBlock(addrmgrNs, *bs, false)
}) })
if err != nil { if err != nil {
return "", err return "", err