diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 439c0ba51..c824b75c8 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -3,7 +3,6 @@ // Copyright (c) 2016-2020 The Hush developers // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -22,10 +21,8 @@ #include "rpc/client.h" #include "rpc/protocol.h" #include "util.h" - #include #include - #include using namespace std; @@ -138,8 +135,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { "z_listunspent", 1 }, { "z_listunspent", 2 }, { "z_listunspent", 3 }, - { "z_getbalances", 0}, - { "z_getbalances", 1}, { "z_getbalance", 1}, { "z_getnotescount", 0}, { "z_gettotalbalance", 0}, diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 798c5399e..8297e5dff 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3636,7 +3636,7 @@ UniValue z_getbalances(const UniValue& params, bool fHelp, const CPubKey& mypk) if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - if (fHelp || params.size() > 0) + if (fHelp || params.size() > 1) throw runtime_error( "z_getbalances\n" "\nReturns array of addresses with their unspent shielded balances.\n" @@ -3656,28 +3656,31 @@ UniValue z_getbalances(const UniValue& params, bool fHelp, const CPubKey& mypk) "\nExamples\n" + HelpExampleCli("z_getbalances", "") + + HelpExampleCli("z_getbalances", "0.01") + HelpExampleRpc("z_getbalances", "") + + HelpExampleRpc("z_getbalances", "0.42069") ); - RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); + //RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); LOCK2(cs_main, pwalletMain->cs_wallet); + // ignore amount=0 zaddrs by default + CAmount nMinBal = 1; // puposhis + if (params.size() > 0) + nMinBal = AmountFromValue(params[0]); + std::set zaddrs = {}; std::set saplingzaddrs = {}; pwalletMain->GetSaplingPaymentAddresses(saplingzaddrs); zaddrs.insert(saplingzaddrs.begin(), saplingzaddrs.end()); - UniValue results(UniValue::VARR); - int nMinDepth = 1; - int nMaxDepth = 9999999; std::vector saplingEntries; pwalletMain->GetFilteredNotes(saplingEntries, zaddrs, nMinDepth); std::map mapBalances; - for (auto & entry : saplingEntries) { auto zaddr = EncodePaymentAddress(entry.address); CAmount nBalance = CAmount(entry.note.value()); @@ -3698,11 +3701,15 @@ UniValue z_getbalances(const UniValue& params, bool fHelp, const CPubKey& mypk) return l.first > r.first; }); + UniValue results(UniValue::VARR); for (auto & entry : vec) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("address", entry.first)); - obj.push_back(Pair("balance", (double) entry.second / (uint64_t) 100000000L )); - results.push_back(obj); + auto balance = (double) entry.second / (uint64_t) 100000000L; + obj.push_back(Pair("balance", balance)); + if(entry.second >= nMinBal) { + results.push_back(obj); + } } return results;