From 1ad0dbade93657f138119d6fd099b33e10cdf16f Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Mon, 19 Oct 2020 13:57:30 -0700 Subject: [PATCH] btcwallet: return chain best timestamp while backend is syncing A while back, changes were made to the wallet such that it waits for the backend to be synced before beginning to store the latest 10,000 blocks of the chain. This inherently broke sync progress implementations based on the best_header_timestamp result from the GetInfo RPC for neutrino-based nodes as the wallet is no longer tracking all blocks in the chain. To work around this, we now make sure to return the backend's best header timestamp instead of the wallet's, allowing said sync progress implementations to work again. --- lnwallet/btcwallet/btcwallet.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index d98e08ef..9c737fb2 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -875,9 +875,19 @@ func (b *BtcWallet) IsSynced() (bool, int64, error) { return false, 0, err } + // Make sure the backing chain has been considered synced first. + if !b.wallet.ChainSynced() { + bestHeader, err := b.cfg.ChainSource.GetBlockHeader(bestHash) + if err != nil { + return false, 0, err + } + bestTimestamp = bestHeader.Timestamp.Unix() + return false, bestTimestamp, nil + } + // If the wallet hasn't yet fully synced to the node's best chain tip, // then we're not yet fully synced. - if syncState.Height < bestHeight || !b.wallet.ChainSynced() { + if syncState.Height < bestHeight { return false, bestTimestamp, nil }