Skip to content

Commit bf194c9

Browse files
committed
wallet, rpc: deprecate settxfee and paytxfee
1 parent 83a9e55 commit bf194c9

File tree

11 files changed

+32
-8
lines changed

11 files changed

+32
-8
lines changed

src/wallet/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void WalletInit::AddWalletOptions(ArgsManager& argsman) const
6666
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
6767
argsman.AddArg("-mintxfee=<amt>", strprintf("Fee rates (in %s/kvB) smaller than this are considered zero fee for transaction creation (default: %s)",
6868
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MINFEE)), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
69-
argsman.AddArg("-paytxfee=<amt>", strprintf("Fee rate (in %s/kvB) to add to transactions you send (default: %s)",
69+
argsman.AddArg("-paytxfee=<amt>", strprintf("(DEPRECATED) Fee rate (in %s/kvB) to add to transactions you send (default: %s)",
7070
CURRENCY_UNIT, FormatMoney(CFeeRate{DEFAULT_PAY_TX_FEE}.GetFeePerK())), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
7171
#ifdef ENABLE_EXTERNAL_SIGNER
7272
argsman.AddArg("-signer=<cmd>", "External signing tool, see doc/external-signer.md", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);

src/wallet/rpc/spend.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ RPCHelpMan sendmany()
418418
RPCHelpMan settxfee()
419419
{
420420
return RPCHelpMan{"settxfee",
421-
"\nSet the transaction fee rate in " + CURRENCY_UNIT + "/kvB for this wallet. Overrides the global -paytxfee command line parameter.\n"
421+
"\n(DEPRECATED) Set the transaction fee rate in " + CURRENCY_UNIT + "/kvB for this wallet. Overrides the global -paytxfee command line parameter.\n"
422422
"Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.\n",
423423
{
424424
{"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "The transaction fee rate in " + CURRENCY_UNIT + "/kvB"},
@@ -437,6 +437,11 @@ RPCHelpMan settxfee()
437437

438438
LOCK(pwallet->cs_wallet);
439439

440+
if (!pwallet->chain().rpcEnableDeprecated("settxfee")) {
441+
throw JSONRPCError(RPC_METHOD_DEPRECATED, "settxfee is deprecated and will be fully removed in v31.0."
442+
"\nTo use settxfee restart bitcoind with -deprecatedrpc=settxfee.");
443+
}
444+
440445
CAmount nAmount = AmountFromValue(request.params[0]);
441446
CFeeRate tx_fee_rate(nAmount, 1000);
442447
CFeeRate max_tx_fee_rate(pwallet->m_default_max_tx_fee, 1000);

src/wallet/wallet.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,6 +3181,8 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
31813181
}
31823182

31833183
if (args.IsArgSet("-paytxfee")) {
3184+
warnings.push_back(_("-paytxfee is deprecated and will be fully removed in v31.0."));
3185+
31843186
std::optional<CAmount> pay_tx_fee = ParseMoney(args.GetArg("-paytxfee", ""));
31853187
if (!pay_tx_fee) {
31863188
error = AmountErrMsg("paytxfee", args.GetArg("-paytxfee", ""));

test/functional/rpc_deprecated.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test deprecation of RPC calls."""
66
from test_framework.test_framework import BitcoinTestFramework
7+
from test_framework.util import assert_raises_rpc_error
78

89
class DeprecatedRpcTest(BitcoinTestFramework):
10+
def add_options(self, parser):
11+
self.add_wallet_options(parser)
12+
913
def set_test_params(self):
1014
self.num_nodes = 1
1115
self.setup_clean_chain = True
1216
self.extra_args = [[]]
1317

18+
19+
def skip_test_if_missing_module(self):
20+
self.skip_if_no_wallet()
21+
1422
def run_test(self):
1523
# This test should be used to verify the errors of the currently
1624
# deprecated RPC methods (without the -deprecatedrpc flag) until
@@ -23,7 +31,8 @@ def run_test(self):
2331
# at least one other functional test that still tests the RPCs
2432
# functionality using the respective -deprecatedrpc flag.
2533

26-
self.log.info("Currently no tests for deprecated RPC methods")
34+
self.log.info("Test settxfee RPC")
35+
assert_raises_rpc_error(-32, 'settxfee is deprecated and will be fully removed in v31.0.', self.nodes[0].rpc.settxfee, 0.01)
2736

2837
if __name__ == '__main__':
2938
DeprecatedRpcTest(__file__).main()

test/functional/test_framework/test_framework.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,9 @@ def stop_nodes(self, wait=0):
598598
# Wait for nodes to stop
599599
node.wait_until_stopped()
600600

601-
def restart_node(self, i, extra_args=None, clear_addrman=False):
601+
def restart_node(self, i, extra_args=None, clear_addrman=False, *, expected_stderr=''):
602602
"""Stop and start a test node"""
603-
self.stop_node(i)
603+
self.stop_node(i, expected_stderr=expected_stderr)
604604
if clear_addrman:
605605
peers_dat = self.nodes[i].chain_path / "peers.dat"
606606
os.remove(peers_dat)

test/functional/wallet_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def set_test_params(self):
3535
# whitelist peers to speed up tx relay / mempool sync
3636
self.noban_tx_relay = True
3737
self.extra_args = [[
38-
"-dustrelayfee=0", "-walletrejectlongchains=0"
38+
"-dustrelayfee=0", "-walletrejectlongchains=0", "-deprecatedrpc=settxfee"
3939
]] * self.num_nodes
4040
self.setup_clean_chain = True
4141
self.supports_cli = False

test/functional/wallet_bumpfee.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def set_test_params(self):
6161
"-walletrbf={}".format(i),
6262
"-mintxfee=0.00002",
6363
"-addresstype=bech32",
64+
"-deprecatedrpc=settxfee"
6465
] for i in range(self.num_nodes)]
6566

6667
def skip_test_if_missing_module(self):

test/functional/wallet_create_tx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def add_options(self, parser):
2323
def set_test_params(self):
2424
self.setup_clean_chain = True
2525
self.num_nodes = 1
26+
self.extra_args = [["-deprecatedrpc=settxfee"]]
2627

2728
def skip_test_if_missing_module(self):
2829
self.skip_if_no_wallet()
@@ -71,7 +72,7 @@ def test_tx_size_too_large(self):
7172
)
7273

7374
self.log.info('Check maxtxfee in combination with settxfee')
74-
self.restart_node(0)
75+
self.restart_node(0, expected_stderr='Warning: -paytxfee is deprecated and will be fully removed in v31.0.')
7576
self.nodes[0].settxfee(0.01)
7677
assert_raises_rpc_error(
7778
-6,

test/functional/wallet_fundrawtransaction.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def add_options(self, parser):
4444

4545
def set_test_params(self):
4646
self.num_nodes = 4
47+
self.extra_args = [[
48+
"-deprecatedrpc=settxfee"
49+
] for i in range(self.num_nodes)]
4750
self.setup_clean_chain = True
4851
# whitelist peers to speed up tx relay / mempool sync
4952
self.noban_tx_relay = True

test/functional/wallet_multiwallet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def set_test_params(self):
4646
self.setup_clean_chain = True
4747
self.num_nodes = 2
4848
self.rpc_timeout = 120
49-
self.extra_args = [["-nowallet"], []]
49+
self.extra_args = [["-nowallet", "-deprecatedrpc=settxfee"], []]
5050

5151
def skip_test_if_missing_module(self):
5252
self.skip_if_no_wallet()

0 commit comments

Comments
 (0)