Skip to content

Commit 0853a23

Browse files
luke-jrinstagibbs
authored andcommitted
Make it possible to unconditionally RBF with mempoolreplacement=fee,-optin
1 parent d0cccad commit 0853a23

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/init.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,8 +1153,16 @@ bool AppInitParameterInteraction()
11531153
// Minimal effort at forwards compatibility
11541154
std::string strReplacementModeList = gArgs.GetArg("-mempoolreplacement", ""); // default is impossible
11551155
std::vector<std::string> vstrReplacementModes;
1156-
boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(","));
1156+
boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(",+"));
11571157
fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end());
1158+
if (fEnableReplacement) {
1159+
fReplacementHonourOptOut = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "-optin") == vstrReplacementModes.end());
1160+
if (!fReplacementHonourOptOut) {
1161+
nLocalServices = ServiceFlags(nLocalServices | NODE_REPLACE_BY_FEE);
1162+
}
1163+
} else {
1164+
fReplacementHonourOptOut = true;
1165+
}
11581166
}
11591167

11601168
return true;

src/validation.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ size_t nCoinCacheUsage = 5000 * 300;
233233
uint64_t nPruneTarget = 0;
234234
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
235235
bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT;
236+
bool fReplacementHonourOptOut = DEFAULT_REPLACEMENT_HONOUR_OPTOUT;
236237

237238
uint256 hashAssumeValid;
238239
arith_uint256 nMinimumChainWork;
@@ -623,6 +624,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
623624
bool fReplacementOptOut = true;
624625
if (fEnableReplacement)
625626
{
627+
if (fReplacementHonourOptOut) {
626628
for (const CTxIn &_txin : ptxConflicting->vin)
627629
{
628630
if (_txin.nSequence <= MAX_BIP125_RBF_SEQUENCE)
@@ -631,6 +633,9 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
631633
break;
632634
}
633635
}
636+
} else {
637+
fReplacementOptOut = false;
638+
}
634639
}
635640
if (fReplacementOptOut) {
636641
return state.Invalid(false, REJECT_DUPLICATE, "txn-mempool-conflict");

src/validation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100;
122122
static const bool DEFAULT_PERSIST_MEMPOOL = true;
123123
/** Default for -mempoolreplacement */
124124
static const bool DEFAULT_ENABLE_REPLACEMENT = true;
125+
static const bool DEFAULT_REPLACEMENT_HONOUR_OPTOUT = true;
125126
/** Default for using fee filter */
126127
static const bool DEFAULT_FEEFILTER = true;
127128

@@ -169,6 +170,7 @@ extern CAmount maxTxFee;
169170
/** If the tip is older than this (in seconds), the node is considered to be in initial block download. */
170171
extern int64_t nMaxTipAge;
171172
extern bool fEnableReplacement;
173+
extern bool fReplacementHonourOptOut;
172174

173175
/** Block hash whose ancestors we will assume to have valid scripts without checking them. */
174176
extern uint256 hashAssumeValid;

0 commit comments

Comments
 (0)