aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpc
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2023-07-16 13:31:38 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2024-02-09 14:54:50 -0300
commit83b762845f5804f23b63526d403b2f327fe99632 (patch)
tree73b81732c18231ddcf7bd550b43d38b6c4b6c055 /src/wallet/rpc
parent595d50a1032ad7ffa9945464c86aa57f16665e93 (diff)
downloadbitcoin-83b762845f5804f23b63526d403b2f327fe99632.tar.xz
wallet: batch and simplify ZapSelectTx process
The goal of the function is to erase the wallet transactions that match the inputted hashes. There is no need to traverse the database, reading record by record, to then perform single entry removals for each of them. To ensure consistency and improve performance, this change-set removes all tx records within a single atomic db batch operation, as well as it cleans up code, improves error handling and simplifies the transactions removal process entirely. This optimizes the removal of watch-only transactions during the wallet migration process and the 'removeprunedfunds' RPC command.
Diffstat (limited to 'src/wallet/rpc')
-rw-r--r--src/wallet/rpc/backup.cpp10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp
index 3e1ec667e0..401c0b2d23 100644
--- a/src/wallet/rpc/backup.cpp
+++ b/src/wallet/rpc/backup.cpp
@@ -394,14 +394,8 @@ RPCHelpMan removeprunedfunds()
uint256 hash(ParseHashV(request.params[0], "txid"));
std::vector<uint256> vHash;
vHash.push_back(hash);
- std::vector<uint256> vHashOut;
-
- if (pwallet->ZapSelectTx(vHash, vHashOut) != DBErrors::LOAD_OK) {
- throw JSONRPCError(RPC_WALLET_ERROR, "Could not properly delete the transaction.");
- }
-
- if(vHashOut.empty()) {
- throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction does not exist in wallet.");
+ if (auto res = pwallet->ZapSelectTx(vHash); !res) {
+ throw JSONRPCError(RPC_WALLET_ERROR, util::ErrorString(res).original);
}
return UniValue::VNULL;