mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-20 13:04:28 +02:00
chainntnfs: remove subscriptions when the relevant tx is confirmed
This commit removes the subscribed inputs from mempool notifier when the relevant transaction is confirmed.
This commit is contained in:
@@ -140,6 +140,23 @@ func (m *MempoolNotifier) UnsubscribeEvent(sub *MempoolSpendEvent) {
|
||||
clients.Delete(sub.id)
|
||||
}
|
||||
|
||||
// UnsubsribeConfirmedSpentTx takes a transaction and removes the subscriptions
|
||||
// identified using its inputs.
|
||||
func (m *MempoolNotifier) UnsubsribeConfirmedSpentTx(tx *btcutil.Tx) {
|
||||
Log.Tracef("Unsubscribe confirmed tx %s", tx.Hash())
|
||||
|
||||
// Get the spent inputs of interest.
|
||||
spentInputs := m.findRelevantInputs(tx)
|
||||
|
||||
// Unsubscribe the subscribers.
|
||||
for outpoint := range spentInputs {
|
||||
m.UnsubscribeInput(outpoint)
|
||||
}
|
||||
|
||||
Log.Tracef("Finished unsubscribing confirmed tx %s, found %d inputs",
|
||||
tx.Hash(), len(spentInputs))
|
||||
}
|
||||
|
||||
// ProcessRelevantSpendTx takes a transaction and checks whether it spends any
|
||||
// of the subscribed inputs. If so, spend notifications are sent to the
|
||||
// relevant subscribers.
|
||||
|
Reference in New Issue
Block a user