From 9ca9802d9c669ff7591ccb7cb08c135a51b89ad8 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Tue, 13 Nov 2018 20:08:54 -0800 Subject: [PATCH] lnwallet/btcwallet: check wallet rescan is complete within IsSynced In this commit, we add an additional check to btcwallet's IsSynced method to ensure that it is not currently undergoing a rescan. We do this to block upon starting the server and all other dependent subsystems until the rescan is complete. --- lnwallet/btcwallet/btcwallet.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index b60ccb545..2341ba5de 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -714,6 +714,11 @@ func (b *BtcWallet) SubscribeTransactions() (lnwallet.TransactionSubscription, e // // This is a part of the WalletController interface. func (b *BtcWallet) IsSynced() (bool, int64, error) { + // First, we'll ensure the wallet is not currently undergoing a rescan. + if !b.wallet.ChainSynced() { + return false, 0, nil + } + // Grab the best chain state the wallet is currently aware of. syncState := b.wallet.Manager.SyncedTo()