From a01336d8ac96dfb339a4fe80eb51620b8e0cd090 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Tue, 11 Jul 2023 11:44:30 +0900 Subject: [PATCH] Fix mined rbf conflict prevention --- backend/src/api/common.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/src/api/common.ts b/backend/src/api/common.ts index 9836559ae..735e240c1 100644 --- a/backend/src/api/common.ts +++ b/backend/src/api/common.ts @@ -86,19 +86,19 @@ export class Common { const match = spendMap.get(`${vin.txid}:${vin.vout}`); if (match && match.txid !== tx.txid) { replaced.add(match); + // remove this tx from the spendMap + // prevents the same tx being replaced more than once + for (const replacedVin of match.vin) { + const key = `${replacedVin.txid}:${replacedVin.vout}`; + spendMap.delete(key); + } } + const key = `${vin.txid}:${vin.vout}`; + spendMap.delete(key); } 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; }