From f280f5eb47497f53ff997e7d3bec9667cb60339a Mon Sep 17 00:00:00 2001 From: David Gumberg Date: Thu, 25 Jun 2026 22:23:59 +0000 Subject: [PATCH] wallet: rpc: deprecate removeprunedfunds This RPC has no helpful use while being both dangerous and a maintenance burden. Despite what the name says, it allows the deletion of arbitrary transactions, and `importprunedfunds` does not allow the importing of transactions not belonging to the user, and `listtransactions` does not list transactions not belonging to the wallet, so this RPC can only be used to delete transactions actually belonging to the wallet, and in the unlikely event that transactions not belonging to the wallet are present, they cause no harm except for occupying a few bytes on the users disk. --- doc/release-notes-removeprunedfunds.md | 6 ++++++ src/wallet/rpc/backup.cpp | 5 +++++ test/functional/rpc_deprecated.py | 14 +++++++++++++- test/functional/wallet_importprunedfunds.py | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 doc/release-notes-removeprunedfunds.md diff --git a/doc/release-notes-removeprunedfunds.md b/doc/release-notes-removeprunedfunds.md new file mode 100644 index 00000000000..0e0d0ceb3c9 --- /dev/null +++ b/doc/release-notes-removeprunedfunds.md @@ -0,0 +1,6 @@ +Updated RPCs +------------ + +- The `removeprunedfunds` RPC has been deprecated and will be removed in the +next major release. In order to continue using it, `bitcoind` must be started +with the `-deprecatedrpc=removeprunedfunds` option. diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp index 396be628259..acfb78547a3 100644 --- a/src/wallet/rpc/backup.cpp +++ b/src/wallet/rpc/backup.cpp @@ -95,6 +95,7 @@ RPCMethod removeprunedfunds() { return RPCMethod{ "removeprunedfunds", + "(DEPRECATED) This feature will be removed in the next major release. Start bitcoind with the `-deprecatedrpc=removeprunedfunds` option in order to use this.\n" "Deletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will affect wallet balances.\n", { {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded id of the transaction you are deleting"}, @@ -110,6 +111,10 @@ RPCMethod removeprunedfunds() std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return UniValue::VNULL; + if (!pwallet->chain().rpcEnableDeprecated("removeprunedfunds")) { + throw JSONRPCError(RPC_METHOD_DEPRECATED, "DEPRECATION WARNING: This feature will be removed in the next major release. Start bitcoind with the `-deprecatedrpc=removeprunedfunds` option in order to use this."); + } + LOCK(pwallet->cs_wallet); Txid hash{Txid::FromUint256(ParseHashV(request.params[0], "txid"))}; diff --git a/test/functional/rpc_deprecated.py b/test/functional/rpc_deprecated.py index 2f86954f22b..dd7f6002474 100755 --- a/test/functional/rpc_deprecated.py +++ b/test/functional/rpc_deprecated.py @@ -4,6 +4,8 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test deprecation of RPC calls.""" from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_raises_rpc_error + class DeprecatedRpcTest(BitcoinTestFramework): def set_test_params(self): @@ -26,7 +28,17 @@ class DeprecatedRpcTest(BitcoinTestFramework): # Please don't delete nor modify this comment self.log.info("Tests for deprecated RPC methods (if any)") - self.log.info("Currently no tests for deprecated RPC methods") + if self.is_wallet_compiled(): + self.log.info("Tests for deprecated wallet-related RPC methods (if any)") + self.nodes[0].createwallet("ancient_wallet") + wallet = self.nodes[0].get_wallet_rpc("ancient_wallet") + + self.log.info("Test removeprunedfunds deprecation") + assert_raises_rpc_error( + -32, "Start bitcoind with the `-deprecatedrpc=removeprunedfunds`", + wallet.removeprunedfunds, + "fakeargument" + ) if __name__ == '__main__': diff --git a/test/functional/wallet_importprunedfunds.py b/test/functional/wallet_importprunedfunds.py index 95e2a5b3a4f..6c1c640645f 100755 --- a/test/functional/wallet_importprunedfunds.py +++ b/test/functional/wallet_importprunedfunds.py @@ -25,6 +25,7 @@ class ImportPrunedFundsTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 + self.extra_args = [["-deprecatedrpc=removeprunedfunds"]] * 2 def skip_test_if_missing_module(self): self.skip_if_no_wallet()