Skip to content

Commit 152f45b

Browse files
petertoddlaanwj
authored andcommitted
Add option to opt into full-RBF when sending funds
1 parent 6583737 commit 152f45b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/wallet/wallet.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE);
4040
unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET;
4141
bool bSpendZeroConfChange = DEFAULT_SPEND_ZEROCONF_CHANGE;
4242
bool fSendFreeTransactions = DEFAULT_SEND_FREE_TRANSACTIONS;
43+
bool fOptIntoFullRbf = DEFAULT_OPT_INTO_FULL_RBF;
4344

4445
const char * DEFAULT_WALLET_DAT = "wallet.dat";
4546
const uint32_t BIP32_HARDENED_KEY_LIMIT = 0x80000000;
@@ -2355,11 +2356,11 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
23552356

23562357
// Fill vin
23572358
//
2358-
// Note how the sequence number is set to max()-1 so that the
2359-
// nLockTime set above actually works.
2359+
// Note how the sequence number is set to non-maxint so that
2360+
// the nLockTime set above actually works.
23602361
BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins)
23612362
txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(),
2362-
std::numeric_limits<unsigned int>::max()-1));
2363+
std::numeric_limits<unsigned int>::max() - (fOptIntoFullRbf ? 2 : 1)));
23632364

23642365
// Sign
23652366
int nIn = 0;
@@ -3240,6 +3241,7 @@ std::string CWallet::GetWalletHelpString(bool showDebug)
32403241
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE));
32413242
strUsage += HelpMessageOpt("-txconfirmtarget=<n>", strprintf(_("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET));
32423243
strUsage += HelpMessageOpt("-usehd", _("Use hierarchical deterministic key generation (HD) after BIP32. Only has effect during wallet creation/first start") + " " + strprintf(_("(default: %u)"), DEFAULT_USE_HD_WALLET));
3244+
strUsage += HelpMessageOpt("-optintofullrbf", strprintf(_("Send transactions with full-RBF opt-in enabled (default: %u)"), DEFAULT_OPT_INTO_FULL_RBF));
32433245
strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format on startup"));
32443246
strUsage += HelpMessageOpt("-wallet=<file>", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), DEFAULT_WALLET_DAT));
32453247
strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), DEFAULT_WALLETBROADCAST));
@@ -3480,6 +3482,7 @@ bool CWallet::ParameterInteraction()
34803482
nTxConfirmTarget = GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET);
34813483
bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);
34823484
fSendFreeTransactions = GetBoolArg("-sendfreetransactions", DEFAULT_SEND_FREE_TRANSACTIONS);
3485+
fOptIntoFullRbf = GetBoolArg("-optintofullrbf", DEFAULT_OPT_INTO_FULL_RBF);
34833486

34843487
return true;
34853488
}

src/wallet/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extern CFeeRate payTxFee;
3737
extern unsigned int nTxConfirmTarget;
3838
extern bool bSpendZeroConfChange;
3939
extern bool fSendFreeTransactions;
40+
extern bool fOptIntoFullRbf;
4041

4142
static const unsigned int DEFAULT_KEYPOOL_SIZE = 100;
4243
//! -paytxfee default
@@ -53,6 +54,8 @@ static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
5354
static const bool DEFAULT_SEND_FREE_TRANSACTIONS = false;
5455
//! -txconfirmtarget default
5556
static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 2;
57+
//! -optintofullrbf default
58+
static const bool DEFAULT_OPT_INTO_FULL_RBF = false;
5659
//! Largest (in bytes) free transaction we're willing to create
5760
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000;
5861
static const bool DEFAULT_WALLETBROADCAST = true;

0 commit comments

Comments
 (0)