mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-26 21:51:27 +02:00
chainntnfs: use spent height as height hint if found
Previously when deciding whether a UTXO is spent or not, we accept a height hint as the starting block to look for the spending tx in the rescan process. When it's already found spent before the rescan starts, we will update the height hint to be the spent height, only if the latter is greater. This means if the user-specified hint is greater than the actual spending height, this UTXO will never be found as spent. We now fix it by always using the spent height as the hint.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
a806323035
commit
732cd717bf
@@ -837,7 +837,11 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||
chainntnfs.Log.Debugf("Outpoint(%v) has spent at height %v",
|
||||
outpoint, spentHeight)
|
||||
|
||||
if spentHeight > ntfn.HistoricalDispatch.StartHeight {
|
||||
// Since the tx has already been spent at spentHeight, the
|
||||
// heightHint specified by the caller is no longer relevant. We
|
||||
// now update the starting height to be the spent height to make
|
||||
// sure we won't miss it in the rescan.
|
||||
if spentHeight != ntfn.HistoricalDispatch.StartHeight {
|
||||
ntfn.HistoricalDispatch.StartHeight = spentHeight
|
||||
}
|
||||
}
|
||||
|
@@ -937,7 +937,11 @@ func (b *BtcdNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||
chainntnfs.Log.Debugf("Outpoint(%v) has spent at height %v",
|
||||
outpoint, spentHeight)
|
||||
|
||||
if spentHeight > ntfn.HistoricalDispatch.StartHeight {
|
||||
// Since the tx has already been spent at spentHeight, the
|
||||
// heightHint specified by the caller is no longer relevant. We
|
||||
// now update the starting height to be the spent height to make
|
||||
// sure we won't miss it in the rescan.
|
||||
if spentHeight != ntfn.HistoricalDispatch.StartHeight {
|
||||
startHash, err = b.chainConn.GetBlockHash(
|
||||
int64(spentHeight),
|
||||
)
|
||||
|
Reference in New Issue
Block a user