From cc61b19930f3337d3058f6f97105e664c6c00adc Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 7 Jun 2022 23:56:25 -0400 Subject: [PATCH] Make z_anonsettxdelta work on a tx that is not in our wallet and fix calculation --- src/wallet/rpcwallet.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 28c987fb1..189d668f3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3724,17 +3724,17 @@ UniValue z_anonsettxdelta(const UniValue& params, bool fHelp, const CPubKey& myp + HelpExampleRpc("z_anonsettxdelta txid", "123") ); - LOCK2(cs_main, pwalletMain->cs_wallet); - uint256 txid; + uint256 txid,hashBlock; + CTransaction tx; txid.SetHex(params[0].get_str()); - if (!pwalletMain->mapWallet.count(txid)) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id!"); - const CWalletTx& wtx = pwalletMain->mapWallet[txid]; + LOCK(cs_main); + if (!GetTransaction(txid, tx, hashBlock, true)) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction"); // delta = shielded outputs - shielded inputs - int delta = wtx.vShieldedSpend.size() - wtx.vShieldedOutput.size(); + int delta = tx.vShieldedOutput.size() - tx.vShieldedSpend.size(); return delta; }