@@ -472,8 +472,10 @@ class MemPoolAccept
472
472
*/
473
473
std::vector<COutPoint>& m_coins_to_uncache;
474
474
const bool m_test_accept;
475
- /* * Disable BIP125 RBFing; disallow all conflicts with mempool transactions. */
476
- const bool disallow_mempool_conflicts;
475
+ /* * Whether we allow transactions to replace mempool transactions by BIP125 rules. If false,
476
+ * any transaction spending the same inputs as a transaction in the mempool is considered
477
+ * a conflict. */
478
+ const bool m_allow_bip125_replacement{true };
477
479
};
478
480
479
481
// Single transaction acceptance
@@ -619,6 +621,10 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
619
621
{
620
622
const CTransaction* ptxConflicting = m_pool.GetConflictTx (txin.prevout );
621
623
if (ptxConflicting) {
624
+ if (!args.m_allow_bip125_replacement ) {
625
+ // Transaction conflicts with a mempool tx, but we're not allowing replacements.
626
+ return state.Invalid (TxValidationResult::TX_MEMPOOL_POLICY, " bip125-replacement-disallowed" );
627
+ }
622
628
if (!setConflicts.count (ptxConflicting->GetHash ()))
623
629
{
624
630
// Allow opt-out of transaction replacement by setting
@@ -642,7 +648,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
642
648
break ;
643
649
}
644
650
}
645
- if (fReplacementOptOut || args. disallow_mempool_conflicts ) {
651
+ if (fReplacementOptOut ) {
646
652
return state.Invalid (TxValidationResult::TX_MEMPOOL_POLICY, " txn-mempool-conflict" );
647
653
}
648
654
@@ -1151,7 +1157,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
1151
1157
// package to spend. Since we already checked conflicts in the package and we don't allow
1152
1158
// replacements, we don't need to track the coins spent. Note that this logic will need to be
1153
1159
// updated if package replace-by-fee is allowed in the future.
1154
- assert (args.disallow_mempool_conflicts );
1160
+ assert (! args.m_allow_bip125_replacement );
1155
1161
m_viewmempool.PackageAddTransaction (ws.m_ptx );
1156
1162
}
1157
1163
@@ -1185,7 +1191,7 @@ static MempoolAcceptResult AcceptToMemoryPoolWithTime(const CChainParams& chainp
1185
1191
{
1186
1192
std::vector<COutPoint> coins_to_uncache;
1187
1193
MemPoolAccept::ATMPArgs args { chainparams, nAcceptTime, bypass_limits, coins_to_uncache,
1188
- test_accept, /* disallow_mempool_conflicts */ false };
1194
+ test_accept, /* m_allow_bip125_replacement */ true };
1189
1195
1190
1196
assert (std::addressof (::ChainstateActive ()) == std::addressof (active_chainstate));
1191
1197
const MempoolAcceptResult result = MemPoolAccept (pool, active_chainstate).AcceptSingleTransaction (tx, args);
@@ -1222,7 +1228,7 @@ PackageMempoolAcceptResult ProcessNewPackage(CChainState& active_chainstate, CTx
1222
1228
std::vector<COutPoint> coins_to_uncache;
1223
1229
const CChainParams& chainparams = Params ();
1224
1230
MemPoolAccept::ATMPArgs args { chainparams, GetTime (), /* bypass_limits */ false , coins_to_uncache,
1225
- test_accept, /* disallow_mempool_conflicts */ true };
1231
+ test_accept, /* m_allow_bip125_replacement */ false };
1226
1232
assert (std::addressof (::ChainstateActive ()) == std::addressof (active_chainstate));
1227
1233
const PackageMempoolAcceptResult result = MemPoolAccept (pool, active_chainstate).AcceptMultipleTransactions (package, args);
1228
1234
0 commit comments