Skip to content

Commit 0c0c63f

Browse files
committed
Introduce WALLET_INCREMENTAL_RELAY_FEE
Have wallet's default bump value be higher than the default incrementalRelayFee to future proof against changes to incremental relay fee. Only applies when not setting the fee rate directly.
1 parent e8021ec commit 0c0c63f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,11 +2786,19 @@ UniValue bumpfee(const JSONRPCRequest& request)
27862786
CFeeRate nOldFeeRate(nOldFee, txSize);
27872787
CAmount nNewFee;
27882788
CFeeRate nNewFeeRate;
2789+
// The wallet uses a conservative WALLET_INCREMENTAL_RELAY_FEE value to
2790+
// future proof against changes to network wide policy for incremental relay
2791+
// fee that our node may not be aware of.
2792+
CFeeRate walletIncrementalRelayFee = CFeeRate(WALLET_INCREMENTAL_RELAY_FEE);
2793+
if (::incrementalRelayFee > walletIncrementalRelayFee) {
2794+
walletIncrementalRelayFee = ::incrementalRelayFee;
2795+
}
27892796

27902797
if (totalFee > 0) {
27912798
CAmount minTotalFee = nOldFeeRate.GetFee(maxNewTxSize) + ::incrementalRelayFee.GetFee(maxNewTxSize);
27922799
if (totalFee < minTotalFee) {
2793-
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid totalFee, must be at least %s (oldFee %s + relayFee %s)", FormatMoney(minTotalFee), nOldFeeRate.GetFee(maxNewTxSize), ::incrementalRelayFee.GetFee(maxNewTxSize)));
2800+
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Insufficient totalFee, must be at least %s (oldFee %s + incrementalFee %s)",
2801+
FormatMoney(minTotalFee), FormatMoney(nOldFeeRate.GetFee(maxNewTxSize)), FormatMoney(::incrementalRelayFee.GetFee(maxNewTxSize))));
27942802
}
27952803
nNewFee = totalFee;
27962804
nNewFeeRate = CFeeRate(totalFee, maxNewTxSize);
@@ -2806,9 +2814,9 @@ UniValue bumpfee(const JSONRPCRequest& request)
28062814

28072815
nNewFeeRate = CFeeRate(nNewFee, maxNewTxSize);
28082816

2809-
// new fee rate must be at least old rate + minimum incremental relay rate
2810-
if (nNewFeeRate.GetFeePerK() < nOldFeeRate.GetFeePerK() + ::incrementalRelayFee.GetFeePerK()) {
2811-
nNewFeeRate = CFeeRate(nOldFeeRate.GetFeePerK() + ::incrementalRelayFee.GetFeePerK());
2817+
// New fee rate must be at least old rate + minimum incremental relay rate
2818+
if (nNewFeeRate.GetFeePerK() < nOldFeeRate.GetFeePerK() + walletIncrementalRelayFee.GetFeePerK()) {
2819+
nNewFeeRate = CFeeRate(nOldFeeRate.GetFeePerK() + walletIncrementalRelayFee.GetFeePerK());
28122820
nNewFee = nNewFeeRate.GetFee(maxNewTxSize);
28132821
}
28142822
}

src/wallet/wallet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ static const CAmount DEFAULT_TRANSACTION_FEE = 0;
4848
static const CAmount DEFAULT_FALLBACK_FEE = 20000;
4949
//! -mintxfee default
5050
static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
51+
//! minimum recommended increment for BIP 125 replacement txs
52+
static const CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000;
5153
//! target minimum change amount
5254
static const CAmount MIN_CHANGE = CENT;
5355
//! final minimum change amount after paying for fees

0 commit comments

Comments
 (0)