Skip to content

Commit 88e5f99

Browse files
ezegominstagibbs
authored andcommitted
rpc bumpfee: add fee_rate argument
1 parent 1a4c791 commit 88e5f99

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/wallet/feebumper.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,12 @@ Result CreateRateBumpTransaction(CWallet* wallet, const uint256& txid, const CCo
258258
}
259259
}
260260

261-
new_coin_control.m_feerate = EstimateFeeRate(wallet, wtx, new_coin_control, old_fee);
261+
if (coin_control.m_feerate) {
262+
// The user provided a feeRate argument.
263+
} else {
264+
// The user did not provide a feeRate argument
265+
new_coin_control.m_feerate = EstimateFeeRate(wallet, wtx, new_coin_control, old_fee);
266+
}
262267

263268
// Fill in required inputs we are double-spending(all of them)
264269
// N.B.: bip125 doesn't require all the inputs in the replaced transaction to be

src/wallet/rpcwallet.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3290,7 +3290,7 @@ static UniValue bumpfee(const JSONRPCRequest& request)
32903290
"The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.\n"
32913291
"By default, the new fee will be calculated automatically using estimatesmartfee.\n"
32923292
"The user can specify a confirmation target for estimatesmartfee.\n"
3293-
"Alternatively, the user can specify totalFee (DEPRECATED), or use RPC settxfee to set a higher fee rate.\n"
3293+
"Alternatively, the user can specify totalFee (DEPRECATED), or fee_rate (" + CURRENCY_UNIT + " per kB) for the new transaction .\n"
32943294
"At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee\n"
32953295
"returned by getnetworkinfo) to enter the node's mempool.\n",
32963296
{
@@ -3302,6 +3302,9 @@ static UniValue bumpfee(const JSONRPCRequest& request)
33023302
" In rare cases, the actual fee paid might be slightly higher than the specified\n"
33033303
" totalFee if the tx change output has to be removed because it is too close to\n"
33043304
" the dust threshold."},
3305+
{"fee_rate", RPCArg::Type::NUM, /* default */ "fallback to 'confTarget'", "FeeRate (NOT total fee) to pay, in " + CURRENCY_UNIT + " per kB\n"
3306+
" Specify a fee rate instead of relying on the built-in fee estimator.\n"
3307+
" Must be at least 0.0001 BTC per kB higher than the current transaction fee rate.\n"},
33053308
{"replaceable", RPCArg::Type::BOOL, /* default */ "true", "Whether the new transaction should still be\n"
33063309
" marked bip-125 replaceable. If true, the sequence numbers in the transaction will\n"
33073310
" be left unchanged from the original. If false, any input sequence numbers in the\n"
@@ -3343,13 +3346,15 @@ static UniValue bumpfee(const JSONRPCRequest& request)
33433346
{
33443347
{"confTarget", UniValueType(UniValue::VNUM)},
33453348
{"totalFee", UniValueType(UniValue::VNUM)},
3349+
{"fee_rate", UniValueType(UniValue::VNUM)},
33463350
{"replaceable", UniValueType(UniValue::VBOOL)},
33473351
{"estimate_mode", UniValueType(UniValue::VSTR)},
33483352
},
33493353
true, true);
3350-
3351-
if (options.exists("confTarget") && options.exists("totalFee")) {
3352-
throw JSONRPCError(RPC_INVALID_PARAMETER, "confTarget and totalFee options should not both be set. Please provide either a confirmation target for fee estimation or an explicit total fee for the transaction.");
3354+
if (options.exists("confTarget") && (options.exists("totalFee") || options.exists("fee_rate"))) {
3355+
throw JSONRPCError(RPC_INVALID_PARAMETER, "confTarget can't be set with totalFee or fee_rate. Please provide either a confirmation target in blocks for automatic fee estimation, or an explicit fee rate.");
3356+
} else if (options.exists("fee_rate") && options.exists("totalFee")) {
3357+
throw JSONRPCError(RPC_INVALID_PARAMETER, "fee_rate can't be set along with totalFee.");
33533358
} else if (options.exists("confTarget")) { // TODO: alias this to conf_target
33543359
coin_control.m_confirm_target = ParseConfirmTarget(options["confTarget"], pwallet->chain().estimateMaxBlocks());
33553360
} else if (options.exists("totalFee")) {
@@ -3360,6 +3365,12 @@ static UniValue bumpfee(const JSONRPCRequest& request)
33603365
if (totalFee <= 0) {
33613366
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid totalFee %s (must be greater than 0)", FormatMoney(totalFee)));
33623367
}
3368+
} else if (options.exists("fee_rate")) {
3369+
CFeeRate fee_rate(AmountFromValue(options["fee_rate"]));
3370+
if (fee_rate <= 0) {
3371+
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid fee_rate %s (must be greater than 0)", fee_rate.ToString()));
3372+
}
3373+
coin_control.m_feerate = fee_rate;
33633374
}
33643375

33653376
if (options.exists("replaceable")) {

0 commit comments

Comments
 (0)