From 35d80eec1cca0d9d3d1795d0f6e4f518661f5af5 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Tue, 6 Jun 2023 11:01:01 -0400 Subject: [PATCH] Fix multiple mined RBF replacements of the same tx --- backend/src/api/common.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/api/common.ts b/backend/src/api/common.ts index 37b09a417..07a724f0c 100644 --- a/backend/src/api/common.ts +++ b/backend/src/api/common.ts @@ -91,6 +91,14 @@ export class Common { if (replaced.size) { matches[tx.txid] = { replaced: Array.from(replaced), replacedBy: tx }; } + // remove this tx from the spendMap + // prevents the same tx being replaced more than once + for (const vin of tx.vin) { + const key = `${vin.txid}:${vin.vout}`; + if (spendMap.get(key)?.txid === tx.txid) { + spendMap.delete(key); + } + } } return matches; }