diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b85ab8f89..9796f8d19 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2566,17 +2566,17 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) UniValue results(UniValue::VARR); if (zaddrs.size() > 0) { - std::vector sproutEntries; - std::vector saplingEntries; + std::vector sproutEntries; + std::vector saplingEntries; pwalletMain->GetUnspentFilteredNotes(sproutEntries, saplingEntries, zaddrs, nMinDepth, nMaxDepth, !fIncludeWatchonly); std::set> nullifierSet = pwalletMain->GetNullifiersForAddresses(zaddrs); - for (CUnspentSproutNotePlaintextEntry & entry : sproutEntries) { + for (auto & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid", entry.jsop.hash.ToString())); obj.push_back(Pair("jsindex", (int)entry.jsop.js )); obj.push_back(Pair("jsoutindex", (int)entry.jsop.n)); - obj.push_back(Pair("confirmations", entry.nHeight)); + obj.push_back(Pair("confirmations", entry.confirmations)); bool hasSproutSpendingKey = pwalletMain->HaveSproutSpendingKey(boost::get(entry.address)); obj.push_back(Pair("spendable", hasSproutSpendingKey)); obj.push_back(Pair("address", EncodePaymentAddress(entry.address))); @@ -2589,11 +2589,11 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) results.push_back(obj); } - for (UnspentSaplingNoteEntry & entry : saplingEntries) { + for (auto & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid", entry.op.hash.ToString())); obj.push_back(Pair("outindex", (int)entry.op.n)); - obj.push_back(Pair("confirmations", entry.nHeight)); + obj.push_back(Pair("confirmations", entry.confirmations)); libzcash::SaplingIncomingViewingKey ivk; libzcash::SaplingFullViewingKey fvk; pwalletMain->GetSaplingIncomingViewingKey(boost::get(entry.address), ivk); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3690ed166..6a29242fa 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4440,7 +4440,7 @@ void CWallet::GetFilteredNotes( hSig, (unsigned char) j); - sproutEntries.push_back(CSproutNotePlaintextEntry{jsop, pa, plaintext}); + sproutEntries.push_back(CSproutNotePlaintextEntry{jsop, pa, plaintext, wtx.GetDepthInMainChain()}); } catch (const note_decryption_failed &err) { // Couldn't decrypt with this spending key @@ -4495,7 +4495,7 @@ void CWallet::GetFilteredNotes( auto note = notePt.note(nd.ivk).get(); saplingEntries.push_back(SaplingNoteEntry { - op, pa, note, notePt.memo() }); + op, pa, note, notePt.memo(), wtx.GetDepthInMainChain() }); } } } @@ -4503,8 +4503,8 @@ void CWallet::GetFilteredNotes( /* Find unspent notes filtered by payment address, min depth and max depth */ void CWallet::GetUnspentFilteredNotes( - std::vector& sproutEntries, - std::vector& saplingEntries, + std::vector& sproutEntries, + std::vector& saplingEntries, std::set& filterAddresses, int minDepth, int maxDepth, @@ -4560,7 +4560,7 @@ void CWallet::GetUnspentFilteredNotes( hSig, (unsigned char) j); - sproutEntries.push_back(CUnspentSproutNotePlaintextEntry{jsop, pa, plaintext, wtx.GetDepthInMainChain()}); + sproutEntries.push_back(CSproutNotePlaintextEntry{jsop, pa, plaintext, wtx.GetDepthInMainChain()}); } catch (const note_decryption_failed &err) { // Couldn't decrypt with this spending key @@ -4609,7 +4609,7 @@ void CWallet::GetUnspentFilteredNotes( } auto note = notePt.note(nd.ivk).get(); - saplingEntries.push_back(UnspentSaplingNoteEntry { + saplingEntries.push_back(SaplingNoteEntry { op, pa, note, notePt.memo(), wtx.GetDepthInMainChain() }); } } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index e7d30f467..45918a26c 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -309,38 +309,23 @@ public: typedef std::map mapSproutNoteData_t; typedef std::map mapSaplingNoteData_t; -/** Decrypted note and its location in a transaction. */ +/** Decrypted note, its location in a transaction, and number of confirmations. */ struct CSproutNotePlaintextEntry { JSOutPoint jsop; libzcash::SproutPaymentAddress address; libzcash::SproutNotePlaintext plaintext; + int confirmations; }; -/** Decrypted note, location in a transaction, and confirmation height. */ -struct CUnspentSproutNotePlaintextEntry { - JSOutPoint jsop; - libzcash::SproutPaymentAddress address; - libzcash::SproutNotePlaintext plaintext; - int nHeight; -}; - -/** Sapling note and its location in a transaction. */ +/** Sapling note, its location in a transaction, and number of confirmations. */ struct SaplingNoteEntry { SaplingOutPoint op; libzcash::SaplingPaymentAddress address; libzcash::SaplingNote note; std::array memo; -}; - -/** Sapling note, location in a transaction, and confirmation height. */ -struct UnspentSaplingNoteEntry { - SaplingOutPoint op; - libzcash::SaplingPaymentAddress address; - libzcash::SaplingNote note; - std::array memo; - int nHeight; + int confirmations; }; /** A transaction with a merkle branch linking it to the block chain. */ @@ -1305,8 +1290,8 @@ public: bool ignoreUnspendable=true); /* Find unspent notes filtered by payment address, min depth and max depth */ - void GetUnspentFilteredNotes(std::vector& sproutEntries, - std::vector& saplingEntries, + void GetUnspentFilteredNotes(std::vector& sproutEntries, + std::vector& saplingEntries, std::set& filterAddresses, int minDepth=1, int maxDepth=INT_MAX,