From 999c73169b5d7eab208c04edcdd8e766cc75eea0 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 12 Nov 2023 14:27:57 -0500 Subject: [PATCH] Add nullifier info and fix params check --- src/wallet/rpcwallet.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index aec3f555a..91a3e3817 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3641,22 +3641,28 @@ UniValue z_getwitnesscachestats(const UniValue& params, bool fHelp, const CPubKe if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - if (fHelp || params.size() < 1 || params.size() > 2) + if (fHelp || params.size() > 0 ) throw runtime_error( "z_getwitnesscachestats\n" "\nReturns statistics about the witness cache for zaddrs\n" "\nResult:\n" "\njson\n" "\nExamples:\n" - + HelpExampleCli("z_getwitnesscachestats", "456") - + HelpExampleRpc("z_getwitnesscachestats", "456") + + HelpExampleCli("z_getwitnesscachestats","") + + HelpExampleRpc("z_getwitnesscachestats","") ); LOCK2(cs_main, pwalletMain->cs_wallet); uint32_t nMinDepth = 1; uint64_t total_witnesses = 0; uint64_t total_zutxos = 0; + std::vector nullifiers; + for (auto& wtx : pwalletMain->mapWallet) { + // add all nullifiers in this tx to our list + for (uint32_t i = 0; i < wtx.second.vShieldedSpend.size(); i++) { + nullifiers.emplace_back(wtx.second.vShieldedSpend[i].nullifier); + } if (wtx.second.GetDepthInMainChain() >= nMinDepth) { total_zutxos += wtx.second.mapSaplingNoteData.size(); for (mapSaplingNoteData_t::value_type& item : wtx.second.mapSaplingNoteData) { @@ -3667,6 +3673,7 @@ UniValue z_getwitnesscachestats(const UniValue& params, bool fHelp, const CPubKe } UniValue ret(UniValue::VOBJ); ret.pushKV("total_witnesses", total_witnesses); + ret.pushKV("total_nullifiers", nullifiers.size()); ret.pushKV("total_zutxos", total_zutxos); ret.pushKV("witnesses_cache_size", pwalletMain->nWitnessCacheSize); ret.pushKV("max_witnesses_cache_size", (int) WITNESS_CACHE_SIZE);