Skip to content

Commit fdb4816

Browse files
committed
[validation] distinguish same txid different wtxid in mempool
Changes behavior.
1 parent 4129134 commit fdb4816

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/validation.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,13 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
587587
if (!CheckFinalTx(m_active_chainstate.m_chain.Tip(), tx, STANDARD_LOCKTIME_VERIFY_FLAGS))
588588
return state.Invalid(TxValidationResult::TX_PREMATURE_SPEND, "non-final");
589589

590-
// is it already in the memory pool?
591-
if (m_pool.exists(hash)) {
590+
if (m_pool.exists(GenTxid(true, tx.GetWitnessHash()))) {
591+
// Exact transaction already exists in the mempool.
592592
return state.Invalid(TxValidationResult::TX_CONFLICT, "txn-already-in-mempool");
593+
} else if (m_pool.exists(GenTxid(false, tx.GetHash()))) {
594+
// Transaction with the same non-witness data but different witness (same txid, different
595+
// wtxid) already exists in the mempool.
596+
return state.Invalid(TxValidationResult::TX_CONFLICT, "txn-same-nonwitness-data-in-mempool");
593597
}
594598

595599
// Check for conflicts with in-memory transactions

0 commit comments

Comments
 (0)