From 4c4a1c4d6831c9df6d295983fb79419e9beee456 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Thu, 3 Sep 2020 07:34:01 -0600 Subject: [PATCH] Revert the move of the `getBalanceZaddr` block for ease of review. --- src/wallet/rpcwallet.cpp | 54 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 802753332..204a9d149 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2331,27 +2331,7 @@ UniValue settxfee(const UniValue& params, bool fHelp) return true; } -CAmount getBalanceZaddr(std::string address, int minDepth = 1, int maxDepth = INT_MAX, bool ignoreUnspendable=true) { - CAmount balance = 0; - std::vector sproutEntries; - std::vector saplingEntries; - LOCK2(cs_main, pwalletMain->cs_wallet); - - std::set filterAddresses; - if (address.length() > 0) { - KeyIO keyIO(Params()); - filterAddresses.insert(keyIO.DecodePaymentAddress(address)); - } - - pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, filterAddresses, minDepth, maxDepth, true, ignoreUnspendable); - for (auto & entry : sproutEntries) { - balance += CAmount(entry.note.value()); - } - for (auto & entry : saplingEntries) { - balance += CAmount(entry.note.value()); - } - return balance; -} +CAmount getBalanceZaddr(std::string address, int minDepth = 1, int maxDepth = INT_MAX, bool ignoreUnspendable=true); UniValue getwalletinfo(const UniValue& params, bool fHelp) { @@ -2655,11 +2635,11 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) // User did not provide zaddrs, so use default i.e. all addresses std::set sproutzaddrs = {}; pwalletMain->GetSproutPaymentAddresses(sproutzaddrs); - + // Sapling support std::set saplingzaddrs = {}; pwalletMain->GetSaplingPaymentAddresses(saplingzaddrs); - + zaddrs.insert(sproutzaddrs.begin(), sproutzaddrs.end()); zaddrs.insert(saplingzaddrs.begin(), saplingzaddrs.end()); } @@ -2671,7 +2651,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) std::vector saplingEntries; pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs, nMinDepth, nMaxDepth, true, !fIncludeWatchonly, false); std::set> nullifierSet = pwalletMain->GetNullifiersForAddresses(zaddrs); - + for (auto & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); obj.pushKV("txid", entry.jsop.hash.ToString()); @@ -3399,6 +3379,28 @@ CAmount getBalanceTaddr(std::string transparentAddress, int minDepth=1, bool ign return balance; } +CAmount getBalanceZaddr(std::string address, int minDepth = 1, int maxDepth = INT_MAX, bool ignoreUnspendable=true) { + CAmount balance = 0; + std::vector sproutEntries; + std::vector saplingEntries; + LOCK2(cs_main, pwalletMain->cs_wallet); + + std::set filterAddresses; + if (address.length() > 0) { + KeyIO keyIO(Params()); + filterAddresses.insert(keyIO.DecodePaymentAddress(address)); + } + + pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, filterAddresses, minDepth, maxDepth, true, ignoreUnspendable); + for (auto & entry : sproutEntries) { + balance += CAmount(entry.note.value()); + } + for (auto & entry : saplingEntries) { + balance += CAmount(entry.note.value()); + } + return balance; +} + struct txblock { int height = 0; @@ -4284,7 +4286,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight); bool isShielded = !fromTaddr || zaddrRecipients.size() > 0; if (contextualTx.nVersion == 1 && isShielded) { - contextualTx.nVersion = 2; // Tx format should support vJoinSplits + contextualTx.nVersion = 2; // Tx format should support vJoinSplits } // Create operation and add to global queue @@ -4628,7 +4630,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight); if (contextualTx.nVersion == 1) { - contextualTx.nVersion = 2; // Tx format should support vJoinSplit + contextualTx.nVersion = 2; // Tx format should support vJoinSplit } // Create operation and add to global queue