From 5ae8243d0d95b4f60de2e2447cb2caa7820cd7e8 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 3 Oct 2018 13:47:26 -0700 Subject: [PATCH] chainntnfs/tx_notifier: remove cached conf details on reorg In this commit, we address a small bug where it's possible to deliver a confirmation notification with stale confirmation details upon registration. This can happen if a transaction has confirmed but was reorged out of the chain later on, and a subsequent notification is registered. --- chainntnfs/txconfnotifier.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chainntnfs/txconfnotifier.go b/chainntnfs/txconfnotifier.go index 72f023e55..8d2196220 100644 --- a/chainntnfs/txconfnotifier.go +++ b/chainntnfs/txconfnotifier.go @@ -687,7 +687,15 @@ func (tcn *TxConfNotifier) DisconnectTip(blockHeight uint32) error { // clients is always non-blocking. for initialHeight, txHashes := range tcn.txsByInitialHeight { for txHash := range txHashes { + // If the transaction has been reorged out of the chain, + // we'll make sure to remove the cached confirmation + // details to prevent notifying clients with old + // information. confSet := tcn.confNotifications[txHash] + if initialHeight == blockHeight { + confSet.details = nil + } + for _, ntfn := range confSet.ntfns { // First, we'll attempt to drain an update // from each notification to ensure sends to the