From bd95bfa6fb67bfa230e0398eafae0516b8712bab Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Thu, 15 Nov 2018 18:00:43 -0800 Subject: [PATCH] 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. --- wallet/wallet.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wallet/wallet.go b/wallet/wallet.go index f5abdf5..a50dbcf 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -2684,7 +2684,7 @@ func (w *Wallet) ImportPrivateKey(scope waddrmgr.KeyScope, wif *btcutil.WIF, // before our current one. Otherwise, if we do, we can // potentially miss detecting relevant chain events that // occurred between them while rescanning. - birthdayBlock, err := w.Manager.BirthdayBlock(addrmgrNs) + birthdayBlock, _, err := w.Manager.BirthdayBlock(addrmgrNs) if err != nil { return err } @@ -2696,7 +2696,11 @@ func (w *Wallet) ImportPrivateKey(scope waddrmgr.KeyScope, wif *btcutil.WIF, if err != nil { 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 { return "", err