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; }