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.
This commit is contained in:
David Gumberg
2026-06-25 22:23:59 +00:00
parent e5b7785447
commit f280f5eb47
4 changed files with 25 additions and 1 deletions

View File

@@ -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.

View File

@@ -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<CWallet> 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"))};

View File

@@ -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__':

View File

@@ -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()