chainntnfs: populate spendsByHeight during historical dispatch
This commit fixes a buggy scenario where: - a spend of the desired outpoint occurs - RegisterSpend is called, not immediately notifying - caller performs a historical dispatch, calling UpdateSpendDetails - caller is notified on the Spend channel - re-org occurs - caller is not notified of the re-org We fix this by correctly populating the spendsByHeight map when dispatchSpendDetails is called. This mirrors the confirmation case.
This commit is contained in:
2 files changed
+105
No files matched your search
@@ -1325,6 +1325,19 @@ func (n *TxNotifier) dispatchSpendDetails(ntfn *SpendNtfn, details *SpendDetail)
|
||||
return ErrTxNotifierExiting
|
||||
}
|
||||
|
||||
spendHeight := uint32(details.SpendingHeight)
|
||||
|
||||
// We also add to spendsByHeight to notify on chain reorgs.
|
||||
reorgSafeHeight := spendHeight + n.reorgSafetyLimit
|
||||
if reorgSafeHeight > n.currentHeight {
|
||||
txSet, exists := n.spendsByHeight[spendHeight]
|
||||
if !exists {
|
||||
txSet = make(map[SpendRequest]struct{})
|
||||
n.spendsByHeight[spendHeight] = txSet
|
||||
}
|
||||
txSet[ntfn.SpendRequest] = struct{}{}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user