Merge pull request #681 from guggero/neutrino-recovery

wallet: wait for chain sync on Neutrino recovery
This commit is contained in:
Olaoluwa Osuntokun 2020-03-23 16:53:26 -07:00 committed by GitHub
commit 015c045a3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -336,10 +336,21 @@ func (w *Wallet) syncWithChain(birthdayStamp *waddrmgr.BlockStamp) error {
return err
}
// Neutrino relies on the information given to it by the cfheader server
// so it knows exactly whether it's synced up to the server's state or
// not, even on dev chains. To recover a Neutrino wallet, we need to
// make sure it's synced before we start scanning for addresses,
// otherwise we might miss some if we only scan up to its current sync
// point.
neutrinoRecovery := chainClient.BackEnd() == "neutrino" &&
w.recoveryWindow > 0
// We'll wait until the backend is synced to ensure we get the latest
// MaxReorgDepth blocks to store. We don't do this for development
// environments as we can't guarantee a lively chain.
if !w.isDevEnv() {
// environments as we can't guarantee a lively chain, except for
// Neutrino, where the cfheader server tells us what it believes the
// chain tip is.
if !w.isDevEnv() || neutrinoRecovery {
log.Debug("Waiting for chain backend to sync to tip")
if err := w.waitUntilBackendSynced(chainClient); err != nil {
return err