Merge pull request #569 from wpaulino/import-priv-key-birthday
wallet/wallet: only set new birthday if before current within ImportPrivateKey
This commit is contained in:
commit
69684e9091
1 changed files with 9 additions and 2 deletions
|
@ -23,8 +23,6 @@ import (
|
||||||
"github.com/btcsuite/btcd/rpcclient"
|
"github.com/btcsuite/btcd/rpcclient"
|
||||||
"github.com/btcsuite/btcd/txscript"
|
"github.com/btcsuite/btcd/txscript"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
|
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
"github.com/btcsuite/btcutil/hdkeychain"
|
"github.com/btcsuite/btcutil/hdkeychain"
|
||||||
"github.com/btcsuite/btcwallet/chain"
|
"github.com/btcsuite/btcwallet/chain"
|
||||||
|
@ -33,6 +31,7 @@ import (
|
||||||
"github.com/btcsuite/btcwallet/wallet/txrules"
|
"github.com/btcsuite/btcwallet/wallet/txrules"
|
||||||
"github.com/btcsuite/btcwallet/walletdb"
|
"github.com/btcsuite/btcwallet/walletdb"
|
||||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
"github.com/btcsuite/btcwallet/wtxmgr"
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -2644,6 +2643,14 @@ func (w *Wallet) ImportPrivateKey(scope waddrmgr.KeyScope, wif *btcutil.WIF,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We'll only update our birthday with the new one if it is
|
||||||
|
// before our current one. Otherwise, we won't rescan for
|
||||||
|
// potentially relevant chain events that occurred between them.
|
||||||
|
if newBirthday.After(w.Manager.Birthday()) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return w.Manager.SetBirthday(addrmgrNs, newBirthday)
|
return w.Manager.SetBirthday(addrmgrNs, newBirthday)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue