From 1205f87d36e70a29f30b2d05ddb80ac19d8ce398 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 28 Jan 2016 05:09:29 +0000 Subject: [PATCH 1/6] Rename permitrbf to replacebyfee "permit" is currently used to configure transaction filtering, whereas replacement is more to do with the memory pool state than the transaction itself. --- src/init.cpp | 4 ++-- src/main.cpp | 4 ++-- src/main.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 363575f2364..a7428531a79 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -367,7 +367,6 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-onion=", strprintf(_("Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)"), "-proxy")); strUsage += HelpMessageOpt("-onlynet=", _("Only connect to nodes in network (ipv4, ipv6 or onion)")); strUsage += HelpMessageOpt("-permitbaremultisig", strprintf(_("Relay non-P2SH multisig (default: %u)"), DEFAULT_PERMIT_BAREMULTISIG)); - strUsage += HelpMessageOpt("-permitrbf", strprintf(_("Permit transaction replacement (default: %u)"), DEFAULT_PERMIT_REPLACEMENT)); strUsage += HelpMessageOpt("-peerbloomfilters", strprintf(_("Support filtering of blocks and transaction with bloom filters (default: %u)"), 1)); if (showDebug) strUsage += HelpMessageOpt("-enforcenodebloom", strprintf("Enforce minimum protocol version to limit use of bloom filters (default: %u)", 0)); @@ -487,6 +486,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-bytespersigop", strprintf(_("Minimum bytes per sigop in transactions we relay and mine (default: %u)"), DEFAULT_BYTES_PER_SIGOP)); strUsage += HelpMessageOpt("-datacarrier", strprintf(_("Relay and mine data carrier transactions (default: %u)"), DEFAULT_ACCEPT_DATACARRIER)); strUsage += HelpMessageOpt("-datacarriersize", strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY)); + strUsage += HelpMessageOpt("-replacebyfee", strprintf(_("Enable transaction replacement in the memory pool (default: %u)"), DEFAULT_ENABLE_REPLACEMENT)); strUsage += HelpMessageGroup(_("Block creation options:")); strUsage += HelpMessageOpt("-blockminsize=", strprintf(_("Set minimum block size in bytes (default: %u)"), DEFAULT_BLOCK_MIN_SIZE)); @@ -1016,7 +1016,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (GetBoolArg("-peerbloomfilters", true)) nLocalServices |= NODE_BLOOM; - fPermitReplacement = GetBoolArg("-permitrbf", DEFAULT_PERMIT_REPLACEMENT); + fEnableReplacement = GetBoolArg("-replacebyfee", DEFAULT_ENABLE_REPLACEMENT); // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log diff --git a/src/main.cpp b/src/main.cpp index d1b0fbac2c0..265d7849008 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,7 +75,7 @@ bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED; size_t nCoinCacheUsage = 5000 * 300; uint64_t nPruneTarget = 0; bool fAlerts = DEFAULT_ALERTS; -bool fPermitReplacement = DEFAULT_PERMIT_REPLACEMENT; +bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT; /** Fees smaller than this (in satoshi) are considered zero fee (for relaying, mining and transaction creation) */ CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE); @@ -866,7 +866,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C // unconfirmed ancestors anyway; doing otherwise is hopelessly // insecure. bool fReplacementOptOut = true; - if (fPermitReplacement) + if (fEnableReplacement) { BOOST_FOREACH(const CTxIn &txin, ptxConflicting->vin) { diff --git a/src/main.h b/src/main.h index d3137c371d6..1618194c2a0 100644 --- a/src/main.h +++ b/src/main.h @@ -106,8 +106,8 @@ static const bool DEFAULT_TXINDEX = false; static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100; static const bool DEFAULT_TESTSAFEMODE = false; -/** Default for -permitrbf */ -static const bool DEFAULT_PERMIT_REPLACEMENT = true; +/** Default for -replacebyfee */ +static const bool DEFAULT_ENABLE_REPLACEMENT = true; /** Maximum number of headers to announce when relaying blocks with headers message.*/ static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8; @@ -139,7 +139,7 @@ extern bool fCheckpointsEnabled; extern size_t nCoinCacheUsage; extern CFeeRate minRelayTxFee; extern bool fAlerts; -extern bool fPermitReplacement; +extern bool fEnableReplacement; /** Best header we've seen so far (used for getheaders queries' starting points). */ extern CBlockIndex *pindexBestHeader; From e8d19ab79f9367d3adb43fb041b26f78f0f38eb3 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 28 Jan 2016 05:27:25 +0000 Subject: [PATCH 2/6] Accept replacebyfee=opt-in for turning on opt-in RBF Basic forward-compatibility with more flexible parameters like fss --- src/init.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index a7428531a79..291487a9509 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -47,8 +47,10 @@ #include #endif +#include #include #include +#include #include #include #include @@ -1017,6 +1019,18 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) nLocalServices |= NODE_BLOOM; fEnableReplacement = GetBoolArg("-replacebyfee", DEFAULT_ENABLE_REPLACEMENT); + if ((!fEnableReplacement) && mapArgs.count("-replacebyfee")) { + // Minimal effort at forwards compatibility + std::string strReplacementModeList = GetArg("-replacebyfee", ""); // default is impossible + std::vector vstrReplacementModes; + boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(",")); + BOOST_FOREACH(const std::string& strReplacementMode, vstrReplacementModes) { + if (strReplacementMode == "opt-in") { + fEnableReplacement = true; + break; + } + } + } // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log From 5f456a65467417629e104ea412b98aeabfaae1f8 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 29 Jan 2016 01:28:54 +0000 Subject: [PATCH 3/6] Simplify check for replacebyfee=opt-in --- src/init.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 291487a9509..078fdda34dd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1024,12 +1024,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) std::string strReplacementModeList = GetArg("-replacebyfee", ""); // default is impossible std::vector vstrReplacementModes; boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(",")); - BOOST_FOREACH(const std::string& strReplacementMode, vstrReplacementModes) { - if (strReplacementMode == "opt-in") { - fEnableReplacement = true; - break; - } - } + fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "opt-in") != vstrReplacementModes.end()); } // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log From b2287a7e01d9ac803132d777df424115b9a66243 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 29 Jan 2016 01:33:50 +0000 Subject: [PATCH 4/6] release-notes: Update for permitrbf->replacebyfee rename --- doc/release-notes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/release-notes.md b/doc/release-notes.md index 661f943d76b..1495a31c0c2 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -144,13 +144,13 @@ accepted when it pays sufficient fee, as described in [BIP 125] (https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki). Transaction replacement can be disabled with a new command line option, -`-permitrbf=false`. Transactions signaling replacement under BIP125 will still +`-replacebyfee=0`. Transactions signaling replacement under BIP125 will still be allowed into the mempool in this configuration, but replacements will be rejected. This option is intended for miners who want to continue the transaction selection behavior of previous releases. -The `-permitrbf` option is *not recommended* for wallet users seeking to avoid -receipt of unconfirmed opt-in transactions, because this option does not +The `-replacebyfee` option is *not recommended* for wallet users seeking to +avoid receipt of unconfirmed opt-in transactions, because this option does not prevent transactions which are replaceable under BIP 125 from being accepted (only subsequent replacements, which other nodes on the network that implement BIP 125 are likely to relay and mine). Wallet users wishing to detect whether From 4ad418bc9b056c22a23ed8f35f96190d7a4eb055 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 1 Feb 2016 19:30:37 +0000 Subject: [PATCH 5/6] Rename replacebyfee=opt-in to mempoolreplacement=fee --- src/init.cpp | 10 +++++----- src/main.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 078fdda34dd..c962a5f82dd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -488,7 +488,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-bytespersigop", strprintf(_("Minimum bytes per sigop in transactions we relay and mine (default: %u)"), DEFAULT_BYTES_PER_SIGOP)); strUsage += HelpMessageOpt("-datacarrier", strprintf(_("Relay and mine data carrier transactions (default: %u)"), DEFAULT_ACCEPT_DATACARRIER)); strUsage += HelpMessageOpt("-datacarriersize", strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY)); - strUsage += HelpMessageOpt("-replacebyfee", strprintf(_("Enable transaction replacement in the memory pool (default: %u)"), DEFAULT_ENABLE_REPLACEMENT)); + strUsage += HelpMessageOpt("-mempoolreplacement", strprintf(_("Enable transaction replacement in the memory pool (default: %u)"), DEFAULT_ENABLE_REPLACEMENT)); strUsage += HelpMessageGroup(_("Block creation options:")); strUsage += HelpMessageOpt("-blockminsize=", strprintf(_("Set minimum block size in bytes (default: %u)"), DEFAULT_BLOCK_MIN_SIZE)); @@ -1018,13 +1018,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (GetBoolArg("-peerbloomfilters", true)) nLocalServices |= NODE_BLOOM; - fEnableReplacement = GetBoolArg("-replacebyfee", DEFAULT_ENABLE_REPLACEMENT); - if ((!fEnableReplacement) && mapArgs.count("-replacebyfee")) { + fEnableReplacement = GetBoolArg("-mempoolreplacement", DEFAULT_ENABLE_REPLACEMENT); + if ((!fEnableReplacement) && mapArgs.count("-mempoolreplacement")) { // Minimal effort at forwards compatibility - std::string strReplacementModeList = GetArg("-replacebyfee", ""); // default is impossible + std::string strReplacementModeList = GetArg("-mempoolreplacement", ""); // default is impossible std::vector vstrReplacementModes; boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(",")); - fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "opt-in") != vstrReplacementModes.end()); + fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end()); } // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log diff --git a/src/main.h b/src/main.h index 1618194c2a0..17ac550cf7b 100644 --- a/src/main.h +++ b/src/main.h @@ -106,7 +106,7 @@ static const bool DEFAULT_TXINDEX = false; static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100; static const bool DEFAULT_TESTSAFEMODE = false; -/** Default for -replacebyfee */ +/** Default for -mempoolreplacement */ static const bool DEFAULT_ENABLE_REPLACEMENT = true; /** Maximum number of headers to announce when relaying blocks with headers message.*/ From af9f564267b1ef7e523834675fb8bc447fc435e6 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 1 Feb 2016 19:32:54 +0000 Subject: [PATCH 6/6] release-notes: Update for replacebyfee->mempoolreplacement rename --- doc/release-notes.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/release-notes.md b/doc/release-notes.md index 1495a31c0c2..2b0ee886bb5 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -144,14 +144,14 @@ accepted when it pays sufficient fee, as described in [BIP 125] (https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki). Transaction replacement can be disabled with a new command line option, -`-replacebyfee=0`. Transactions signaling replacement under BIP125 will still -be allowed into the mempool in this configuration, but replacements will be -rejected. This option is intended for miners who want to continue the +`-mempoolreplacement=0`. Transactions signaling replacement under BIP125 will +still be allowed into the mempool in this configuration, but replacements will +be rejected. This option is intended for miners who want to continue the transaction selection behavior of previous releases. -The `-replacebyfee` option is *not recommended* for wallet users seeking to -avoid receipt of unconfirmed opt-in transactions, because this option does not -prevent transactions which are replaceable under BIP 125 from being accepted +The `-mempoolreplacement` option is *not recommended* for wallet users seeking +to avoid receipt of unconfirmed opt-in transactions, because this option does +not prevent transactions which are replaceable under BIP 125 from being accepted (only subsequent replacements, which other nodes on the network that implement BIP 125 are likely to relay and mine). Wallet users wishing to detect whether a transaction is subject to replacement under BIP 125 should instead use the