Skip to content

Commit d1eaa44

Browse files
committed
Merge #481: [0.17] Full RBF support
c00d83f Set walletrbf default to 1 (Gregory Sanders) 0853a23 Make it possible to unconditionally RBF with mempoolreplacement=fee,-optin (Luke Dashjr) d0cccad Recognise temporary REPLACE_BY_FEE service bit (Luke Dashjr) Pull request description: Setting `-mempoolreplacement=fee,-optin` will cause the node to honor any RBF replacements even if they had the opt-out flags set. This also sets the default for the wallet to create bip125-signaling transactions. Tree-SHA512: 04ecc010b6255b5346357f831609702a8a33531fb21e83e061b19945b4a83afe2e5bd82b6602e04394871d9f0c074c54847ff4616930bcd2c17f3c3ddd808fae
2 parents cecfe80 + c00d83f commit d1eaa44

File tree

8 files changed

+26
-2
lines changed

8 files changed

+26
-2
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/protocol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ enum ServiceFlags : uint64_t {
276276
// collisions and other cases where nodes may be advertising a service they
277277
// do not actually support. Other service bits should be allocated via the
278278
// BIP process.
279+
280+
NODE_REPLACE_BY_FEE = (1 << 26),
279281
};
280282

281283
/**

src/qt/guiutil.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,9 @@ QString formatServicesStr(quint64 mask)
835835
case NODE_XTHIN:
836836
strList.append("XTHIN");
837837
break;
838+
case NODE_REPLACE_BY_FEE:
839+
strList.append("REPLACE_BY_FEE?");
840+
break;
838841
default:
839842
strList.append(QString("%1[%2]").arg("UNKNOWN").arg(check));
840843
}

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;

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static const bool DEFAULT_AVOIDPARTIALSPENDS = false;
6060
//! -txconfirmtarget default
6161
static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
6262
//! -walletrbf default
63-
static const bool DEFAULT_WALLET_RBF = false;
63+
static const bool DEFAULT_WALLET_RBF = true;
6464
static const bool DEFAULT_WALLETBROADCAST = true;
6565
static const bool DEFAULT_DISABLE_WALLET = false;
6666

test/bitcoin_functional/functional/test_framework/util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,12 @@ def initialize_datadir(dirname, n, chain):
305305
f.write("discover=0\n")
306306
f.write("listenonion=0\n")
307307
f.write("printtoconsole=0\n")
308+
# Elements:
308309
f.write("con_blocksubsidy=5000000000\n")
309310
f.write("con_connect_coinbase=0\n")
310311
f.write("anyonecanspendaremine=0\n")
311312
f.write("con_blockheightinheader=0\n")
313+
f.write("walletrbf=0\n") # Default is 1 in Elements
312314
f.write("con_bip34height=100000000\n")
313315
f.write("con_bip65height=1351\n")
314316
f.write("con_bip66height=1251\n")

test/functional/test_framework/util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,11 @@ def initialize_datadir(dirname, n, chain):
305305
f.write("discover=0\n")
306306
f.write("listenonion=0\n")
307307
f.write("printtoconsole=0\n")
308+
# Elements:
308309
f.write("con_blocksubsidy=5000000000\n")
309310
f.write("con_connect_coinbase=0\n")
310311
f.write("anyonecanspendaremine=0\n")
312+
f.write("walletrbf=0\n") # Default is 1 in Elements
311313
f.write("con_bip34height=100000000\n")
312314
f.write("con_bip65height=1351\n")
313315
f.write("con_bip66height=1251\n")

0 commit comments

Comments
 (0)