lnwallet: modify IsSynced() for neutrino backend to ensure filter headers are synced
This commit is contained in:
parent
2d71b5a0d5
commit
293a377edd
@ -9,8 +9,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
@ -21,6 +19,8 @@ import (
|
||||
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||
base "github.com/btcsuite/btcwallet/wallet"
|
||||
"github.com/btcsuite/btcwallet/walletdb"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -745,8 +745,24 @@ func (b *BtcWallet) IsSynced() (bool, int64, error) {
|
||||
return false, 0, err
|
||||
}
|
||||
|
||||
// If the timestamp no the best header is more than 2 hours in the
|
||||
// If the timestamp on the best header is more than 2 hours in the
|
||||
// past, then we're not yet synced.
|
||||
minus24Hours := time.Now().Add(-2 * time.Hour)
|
||||
return !blockHeader.Timestamp.Before(minus24Hours), bestTimestamp, nil
|
||||
if blockHeader.Timestamp.Before(minus24Hours) {
|
||||
return false, bestTimestamp, nil
|
||||
}
|
||||
|
||||
// If this is neutrino, then we'll also want to wait until the set of
|
||||
// filter headers also match
|
||||
if neutrinoNode, ok := b.chain.(*chain.NeutrinoClient); ok {
|
||||
filterDB := neutrinoNode.CS.RegFilterHeaders
|
||||
_, filterHeaderTip, err := filterDB.ChainTip()
|
||||
if err != nil {
|
||||
return false, 0, err
|
||||
}
|
||||
|
||||
return filterHeaderTip == uint32(bestHeight), bestTimestamp, nil
|
||||
}
|
||||
|
||||
return true, bestTimestamp, nil
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ type BlockChainIO interface {
|
||||
// GetUtxo attempts to return the passed outpoint if it's still a
|
||||
// member of the utxo set. The passed height hint should be the "birth
|
||||
// height" of the passed outpoint. The script passed should be the
|
||||
// script that the oupoint creates. In the case that the output is in
|
||||
// script that the outpoint creates. In the case that the output is in
|
||||
// the UTXO set, then the output corresponding to that output is
|
||||
// returned. Otherwise, a non-nil error will be returned.
|
||||
GetUtxo(op *wire.OutPoint, pkScript []byte,
|
||||
|
Loading…
Reference in New Issue
Block a user