Merge bitcoin/bitcoin#36333: wallet: Delete `removeprunedfunds` RPC
What changed, and why it matters
This commit removes an old Bitcoin Core wallet RPC command called removeprunedfunds that was already marked deprecated in the previous release. The change is a planned cleanup, not a security fix. It deletes the command's code, its registration, release notes, and related tests. There is no indication in the commit that this fixes a vulnerability or that the removal itself creates a security issue.
No security action required. Operators who still rely on removeprunedfunds should migrate to supported workflows before upgrading, as documented by the deprecation.
Security signals we found
Removal of a deprecated wallet RPC that could alter wallet transaction state
No new parsing of untrusted data or memory-unsafe changes
No vendor security disclosure or CVE referenced in commit or PR description
Evidence from the diff
The merge commit fcf76ea removes the removeprunedfunds RPC and all supporting references. The RPC previously allowed deleting a transaction from a wallet via pwallet->RemoveTxs. It was deprecated in v32 and is now deleted in the next release. The patch removes the RPC method definition from src/wallet/rpc/backup.cpp, unregisters it in src/wallet/rpc/wallet.cpp, adds a release note, and updates/shortens functional tests. No new code paths are introduced that handle untrusted input or modify security-sensitive behavior.
Changed components
src/wallet/rpc/backup.cppsrc/wallet/rpc/wallet.cpptest/functional/rpc_deprecated.pytest/functional/wallet_importprunedfunds.pyInspect captured patch +18 / −96
### doc/release-notes-removeprunedfundsremoval.md
@@ -0,0 +1,5 @@
+Updated RPCs
+------------
+
+- The `removeprunedfunds` RPC was deprecated in v32 and is being removed in this
+ release.
### src/wallet/rpc/backup.cpp
@@ -94,45 +94,6 @@ RPCMethod importprunedfunds()
};
}
-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"},
- },
- RPCResult{RPCResult::Type::NONE, "", ""},
- RPCExamples{
- HelpExampleCli("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"") +
- "\nAs a JSON-RPC call\n"
- + HelpExampleRpc("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"")
- },
- [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue
-{
- 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"))};
- std::vector<Txid> vHash;
- vHash.push_back(hash);
- if (auto res = pwallet->RemoveTxs(vHash); !res) {
- throw JSONRPCError(RPC_WALLET_ERROR, util::ErrorString(res).original);
- }
-
- return UniValue::VNULL;
-},
- };
-}
-
-
/**
* Converts the timestamp from UniValue data to an int64_t.
*
### src/wallet/rpc/wallet.cpp
@@ -1069,7 +1069,6 @@ RPCMethod walletdisplayaddress();
// backup
RPCMethod importprunedfunds();
-RPCMethod removeprunedfunds();
RPCMethod importdescriptors();
RPCMethod listdescriptors();
RPCMethod backupwallet();
@@ -1161,7 +1160,6 @@ std::span<const CRPCCommand> GetWalletRPCCommands()
{"wallet", &loadwallet},
{"wallet", &lockunspent},
{"wallet", &migratewallet},
- {"wallet", &removeprunedfunds},
{"wallet", &rescanblockchain},
{"wallet", &send},
{"wallet", &sendmany},
### test/functional/rpc_deprecated.py
@@ -4,7 +4,6 @@
# 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):
@@ -28,17 +27,7 @@ def run_test(self):
# Please don't delete nor modify this comment
self.log.info("Tests for deprecated RPC methods (if any)")
- 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"
- )
+ self.log.info("Currently no tests for deprecated RPC methods")
if __name__ == '__main__':
### test/functional/wallet_importprunedfunds.py
@@ -2,7 +2,7 @@
# Copyright (c) 2014-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
-"""Test the importprunedfunds and removeprunedfunds RPCs."""
+"""Test the importprunedfunds RPC."""
from decimal import Decimal
from test_framework.address import key_to_p2wpkh
@@ -14,7 +14,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
- assert_not_equal,
assert_raises_rpc_error,
find_vout_for_address,
wallet_importprivkey,
@@ -111,16 +110,6 @@ def run_test(self):
address_info = w1.getaddressinfo(address3)
assert_equal(address_info['ismine'], True)
- # Remove transactions
- assert_raises_rpc_error(-4, f'Transaction {txnid1} does not belong to this wallet', w1.removeprunedfunds, txnid1)
- assert txnid1 not in [tx['txid'] for tx in w1.listtransactions()]
-
- wwatch.removeprunedfunds(txnid2)
- assert txnid2 not in [tx['txid'] for tx in wwatch.listtransactions()]
-
- w1.removeprunedfunds(txnid3)
- assert txnid3 not in [tx['txid'] for tx in w1.listtransactions()]
-
# Import a spending transaction with no wallet outputs (issue #21647)
txid = self.nodes[0].sendtoaddress(address3, 0.1)
vout = find_vout_for_address(self.nodes[0], txid, address3)
@@ -129,12 +118,19 @@ def run_test(self):
spend_txid = w1.sendall(recipients=[external_addr], inputs=[{"txid": txid, "vout": vout}])["txid"]
self.sync_mempools()
self.generate(self.nodes[0], 1)
+
+ funding_raw = w1.gettransaction(txid)['hex']
+ funding_proof = self.nodes[0].gettxoutproof([txid])
spend_raw = w1.gettransaction(spend_txid)['hex']
spend_proof = self.nodes[0].gettxoutproof([spend_txid])
- w1.removeprunedfunds(spend_txid)
- assert not [tx for tx in w1.listtransactions() if tx['txid'] == spend_txid]
- w1.importprunedfunds(spend_raw, spend_proof)
- assert [tx for tx in w1.listtransactions() if tx['txid'] == spend_txid]
+
+ self.nodes[0].createwallet("fresh_wallet", disable_private_keys=True)
+ fresh_wallet = self.nodes[0].get_wallet_rpc("fresh_wallet")
+ desc = w1.getaddressinfo(address3)["desc"]
+ fresh_wallet.importdescriptors([{"desc": desc, "timestamp": "now"}])
+ fresh_wallet.importprunedfunds(funding_raw, funding_proof)
+ fresh_wallet.importprunedfunds(spend_raw, spend_proof)
+ assert [tx for tx in fresh_wallet.listtransactions() if tx['txid'] == spend_txid]
# Check various RPC parameter validation errors
assert_raises_rpc_error(-22, "TX decode failed", w1.importprunedfunds, b'invalid tx'.hex(), proof1)
@@ -148,33 +144,6 @@ def run_test(self):
mb.header.nTime += 1 # modify arbitrary block header field to change block hash
assert_raises_rpc_error(-5, "Block not found in chain", w1.importprunedfunds, rawtxn1, mb.serialize().hex())
- self.log.info("Test removeprunedfunds with conflicting transactions")
- node = self.nodes[0]
-
- # Create a transaction
- utxo = node.listunspent()[0]
- addr = node.getnewaddress()
- tx1_id = node.send(outputs=[{addr: 1}], inputs=[utxo])["txid"]
- tx1_fee = node.gettransaction(tx1_id)["fee"]
-
- # Create a conflicting tx with a larger fee (tx1_fee is negative)
- output_value = utxo["amount"] + tx1_fee - Decimal("0.00001")
- raw_tx2 = node.createrawtransaction(inputs=[utxo], outputs=[{addr: output_value}])
- signed_tx2 = node.signrawtransactionwithwallet(raw_tx2)
- tx2_id = node.sendrawtransaction(signed_tx2["hex"])
- assert_not_equal(tx2_id, tx1_id)
-
- # Both txs should be in the wallet, tx2 replaced tx1 in mempool
- assert tx1_id in [tx["txid"] for tx in node.listtransactions()]
- assert tx2_id in [tx["txid"] for tx in node.listtransactions()]
-
- # Remove the replaced tx from wallet
- node.removeprunedfunds(tx1_id)
-
- # The UTXO should still be considered spent (by tx2)
- available_utxos = [u["txid"] for u in node.listunspent(minconf=0)]
- assert utxo["txid"] not in available_utxos, "UTXO should still be spent by conflicting tx"
-
if __name__ == '__main__':
ImportPrunedFundsTest(__file__).main()Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.