Make z_anonsettxdelta work on a tx that is not in our wallet and fix calculation

This commit is contained in:
Duke Leto
2022-06-07 23:56:25 -04:00
parent c218cf1c09
commit cc61b19930

View File

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