Skip to content

Commit c606e6f

Browse files
committed
Merge #15996: rpc: Deprecate totalfee argument in bumpfee
2f7eb77 Add RPC bumpfee totalFee deprecation test (Jon Atack) a92d9ce deprecate totalFee argument in bumpfee RPC call (Gregory Sanders) Pull request description: totalFee argument is of questionable use, and should be removed in favor of feerate-based features. I first moved IsDeprecatedRPCEnabled because `bitcoin-wallet` doesn't link `libbitcoin_server`. ACKs for top commit: ryanofsky: utACK 2f7eb77. Only change since last review is leaving IsDeprecatedRPCEnabled in its happy home, and switching to rpcEnableDeprecated instead. (Thanks!) jonatack: ACK 2f7eb77. Built locally, manually tested rpc bumpfee, help output ([gist](https://gist.github.com/jonatack/863673eacc02f9da39ff6d6712f9d837)), all tests pass. Travis failures appears to be unrelated, the [bitcoin builds are green](https://bitcoinbuilds.org/index.php?build=121). meshcollider: Code Review ACK 2f7eb77 Tree-SHA512: c97465205ee59575df37894bcbb6c4ecf8858dd8fe9d89503f9342b226768c1dcb553153bc9eb3055f7bf5eb41573e48b8efa57e083cd255793cbe5280f0026a
2 parents dbf4f3f + 2f7eb77 commit c606e6f

File tree

4 files changed

+62
-3
lines changed

4 files changed

+62
-3
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,20 +3263,20 @@ static UniValue bumpfee(const JSONRPCRequest& request)
32633263
"\nBumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B.\n"
32643264
"An opt-in RBF transaction with the given txid must be in the wallet.\n"
32653265
"The command will pay the additional fee by reducing change outputs or adding inputs when necessary. It may add a new change output if one does not already exist.\n"
3266-
"If `totalFee` is given, adding inputs is not supported, so there must be a single change output that is big enough or it will fail.\n"
3266+
"If `totalFee` (DEPRECATED) is given, adding inputs is not supported, so there must be a single change output that is big enough or it will fail.\n"
32673267
"All inputs in the original transaction will be included in the replacement transaction.\n"
32683268
"The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.\n"
32693269
"By default, the new fee will be calculated automatically using estimatesmartfee.\n"
32703270
"The user can specify a confirmation target for estimatesmartfee.\n"
3271-
"Alternatively, the user can specify totalFee, or use RPC settxfee to set a higher fee rate.\n"
3271+
"Alternatively, the user can specify totalFee (DEPRECATED), or use RPC settxfee to set a higher fee rate.\n"
32723272
"At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee\n"
32733273
"returned by getnetworkinfo) to enter the node's mempool.\n",
32743274
{
32753275
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The txid to be bumped"},
32763276
{"options", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED_NAMED_ARG, "",
32773277
{
32783278
{"confTarget", RPCArg::Type::NUM, /* default */ "fallback to wallet's default", "Confirmation target (in blocks)"},
3279-
{"totalFee", RPCArg::Type::NUM, /* default */ "fallback to 'confTarget'", "Total fee (NOT feerate) to pay, in satoshis.\n"
3279+
{"totalFee", RPCArg::Type::NUM, /* default */ "fallback to 'confTarget'", "Total fee (NOT feerate) to pay, in satoshis. (DEPRECATED)\n"
32803280
" In rare cases, the actual fee paid might be slightly higher than the specified\n"
32813281
" totalFee if the tx change output has to be removed because it is too close to\n"
32823282
" the dust threshold."},
@@ -3331,6 +3331,9 @@ static UniValue bumpfee(const JSONRPCRequest& request)
33313331
} else if (options.exists("confTarget")) { // TODO: alias this to conf_target
33323332
coin_control.m_confirm_target = ParseConfirmTarget(options["confTarget"], pwallet->chain().estimateMaxBlocks());
33333333
} else if (options.exists("totalFee")) {
3334+
if (!pwallet->chain().rpcEnableDeprecated("totalFee")) {
3335+
throw JSONRPCError(RPC_INVALID_PARAMETER, "totalFee argument has been deprecated and will be removed in 0.20. Please use -deprecatedrpc=totalFee to continue using this argument until removal.");
3336+
}
33343337
totalFee = options["totalFee"].get_int64();
33353338
if (totalFee <= 0) {
33363339
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid totalFee %s (must be greater than 0)", FormatMoney(totalFee)));

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
'rpc_bind.py --nonloopback',
176176
'mining_basic.py',
177177
'wallet_bumpfee.py',
178+
'wallet_bumpfee_totalfee_deprecation.py',
178179
'rpc_named_arguments.py',
179180
'wallet_listsinceblock.py',
180181
'p2p_leak.py',

test/functional/wallet_bumpfee.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def set_test_params(self):
3737
self.extra_args = [[
3838
"-walletrbf={}".format(i),
3939
"-mintxfee=0.00002",
40+
"-deprecatedrpc=totalFee",
4041
] for i in range(self.num_nodes)]
4142

4243
def skip_test_if_missing_module(self):
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2019 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test deprecation of passing `totalFee` to the bumpfee RPC."""
6+
from decimal import Decimal
7+
8+
from test_framework.messages import BIP125_SEQUENCE_NUMBER
9+
from test_framework.test_framework import BitcoinTestFramework
10+
from test_framework.util import assert_raises_rpc_error
11+
12+
class BumpFeeWithTotalFeeArgumentDeprecationTest(BitcoinTestFramework):
13+
def set_test_params(self):
14+
self.num_nodes = 2
15+
self.extra_args = [[
16+
"-walletrbf={}".format(i),
17+
"-mintxfee=0.00002",
18+
] for i in range(self.num_nodes)]
19+
20+
def skip_test_if_missing_module(self):
21+
self.skip_if_no_wallet()
22+
23+
def run_test(self):
24+
peer_node, rbf_node = self.nodes
25+
peer_node.generate(110)
26+
self.sync_all()
27+
peer_node.sendtoaddress(rbf_node.getnewaddress(), 0.001)
28+
self.sync_all()
29+
peer_node.generate(1)
30+
self.sync_all()
31+
rbfid = spend_one_input(rbf_node, peer_node.getnewaddress())
32+
33+
self.log.info("Testing bumpfee with totalFee argument raises RPC error with deprecation message")
34+
assert_raises_rpc_error(
35+
-8,
36+
"totalFee argument has been deprecated and will be removed in 0.20. " +
37+
"Please use -deprecatedrpc=totalFee to continue using this argument until removal.",
38+
rbf_node.bumpfee, rbfid, {"totalFee": 2000})
39+
40+
self.log.info("Testing bumpfee without totalFee argument does not raise")
41+
rbf_node.bumpfee(rbfid)
42+
43+
def spend_one_input(node, dest_address, change_size=Decimal("0.00049000")):
44+
tx_input = dict(sequence=BIP125_SEQUENCE_NUMBER,
45+
**next(u for u in node.listunspent() if u["amount"] == Decimal("0.00100000")))
46+
destinations = {dest_address: Decimal("0.00050000")}
47+
destinations[node.getrawchangeaddress()] = change_size
48+
rawtx = node.createrawtransaction([tx_input], destinations)
49+
signedtx = node.signrawtransactionwithwallet(rawtx)
50+
txid = node.sendrawtransaction(signedtx["hex"])
51+
return txid
52+
53+
if __name__ == "__main__":
54+
BumpFeeWithTotalFeeArgumentDeprecationTest().main()

0 commit comments

Comments
 (0)