diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index 9e2fdb8fb..ea5d6bf1d 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -91,9 +91,9 @@ JSOutPoint CreateValidBlock(TestWallet& wallet, auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); wallet.AddToWallet(wtx, true, NULL); @@ -117,9 +117,9 @@ TEST(wallet_tests, note_data_serialisation) { auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; ZCIncrementalMerkleTree tree; nd.witnesses.push_front(tree.witness()); noteData[jsoutpt] = nd; @@ -127,7 +127,7 @@ TEST(wallet_tests, note_data_serialisation) { CDataStream ss(SER_DISK, CLIENT_VERSION); ss << noteData; - mapNoteData_t noteData2; + mapSproutNoteData_t noteData2; ss >> noteData2; EXPECT_EQ(noteData, noteData2); @@ -145,9 +145,9 @@ TEST(wallet_tests, find_unspent_notes) { auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); @@ -240,9 +240,9 @@ TEST(wallet_tests, find_unspent_notes) { auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); @@ -299,25 +299,25 @@ TEST(wallet_tests, set_note_addrs_in_cwallettx) { auto wtx = GetValidReceive(sk, 10, true); auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - EXPECT_EQ(0, wtx.mapNoteData.size()); + EXPECT_EQ(0, wtx.mapSproutNoteData.size()); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); - EXPECT_EQ(noteData, wtx.mapNoteData); + EXPECT_EQ(noteData, wtx.mapSproutNoteData); } TEST(wallet_tests, set_invalid_note_addrs_in_cwallettx) { CWalletTx wtx; - EXPECT_EQ(0, wtx.mapNoteData.size()); + EXPECT_EQ(0, wtx.mapSproutNoteData.size()); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; auto sk = libzcash::SproutSpendingKey::random(); JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), uint256()}; + SproutNoteData nd {sk.address(), uint256()}; noteData[jsoutpt] = nd; EXPECT_THROW(wtx.SetNoteData(noteData), std::logic_error); @@ -374,7 +374,7 @@ TEST(wallet_tests, FindMyNotes) { EXPECT_EQ(2, noteMap.size()); JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; EXPECT_EQ(1, noteMap.count(jsoutpt)); EXPECT_EQ(nd, noteMap[jsoutpt]); } @@ -397,7 +397,7 @@ TEST(wallet_tests, FindMyNotesInEncryptedWallet) { EXPECT_EQ(2, noteMap.size()); JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; EXPECT_EQ(1, noteMap.count(jsoutpt)); EXPECT_NE(nd, noteMap[jsoutpt]); @@ -490,9 +490,9 @@ TEST(wallet_tests, navigate_from_nullifier_to_note) { auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); @@ -520,9 +520,9 @@ TEST(wallet_tests, spent_note_is_from_me) { EXPECT_FALSE(wallet.IsFromMe(wtx)); EXPECT_FALSE(wallet.IsFromMe(wtx2)); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); @@ -546,11 +546,11 @@ TEST(wallet_tests, cached_witnesses_empty_chain) { auto nullifier = note.nullifier(sk); auto nullifier2 = note2.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 0}; JSOutPoint jsoutpt2 {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; - CNoteData nd2 {sk.address(), nullifier2}; + SproutNoteData nd {sk.address(), nullifier}; + SproutNoteData nd2 {sk.address(), nullifier2}; noteData[jsoutpt] = nd; noteData[jsoutpt2] = nd2; wtx.SetNoteData(noteData); @@ -611,9 +611,9 @@ TEST(wallet_tests, cached_witnesses_chain_tip) { auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); wallet.AddToWallet(wtx, true, NULL); @@ -700,9 +700,9 @@ TEST(wallet_tests, CachedWitnessesDecrementFirst) { auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); wallet.AddToWallet(wtx, true, NULL); @@ -821,17 +821,17 @@ TEST(wallet_tests, ClearNoteWitnessCache) { auto note = GetNote(sk, wtx, 0, 0); auto nullifier = note.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 0}; JSOutPoint jsoutpt2 {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); // Pretend we mined the tx by adding a fake witness ZCIncrementalMerkleTree tree; - wtx.mapNoteData[jsoutpt].witnesses.push_front(tree.witness()); - wtx.mapNoteData[jsoutpt].witnessHeight = 1; + wtx.mapSproutNoteData[jsoutpt].witnesses.push_front(tree.witness()); + wtx.mapSproutNoteData[jsoutpt].witnessHeight = 1; wallet.nWitnessCacheSize = 1; wallet.AddToWallet(wtx, true, NULL); @@ -844,7 +844,7 @@ TEST(wallet_tests, ClearNoteWitnessCache) { wallet.GetNoteWitnesses(notes, witnesses, anchor2); EXPECT_TRUE((bool) witnesses[0]); EXPECT_FALSE((bool) witnesses[1]); - EXPECT_EQ(1, wallet.mapWallet[hash].mapNoteData[jsoutpt].witnessHeight); + EXPECT_EQ(1, wallet.mapWallet[hash].mapSproutNoteData[jsoutpt].witnessHeight); EXPECT_EQ(1, wallet.nWitnessCacheSize); // After clearing, we should not have a witness for either note @@ -853,7 +853,7 @@ TEST(wallet_tests, ClearNoteWitnessCache) { wallet.GetNoteWitnesses(notes, witnesses, anchor2); EXPECT_FALSE((bool) witnesses[0]); EXPECT_FALSE((bool) witnesses[1]); - EXPECT_EQ(-1, wallet.mapWallet[hash].mapNoteData[jsoutpt].witnessHeight); + EXPECT_EQ(-1, wallet.mapWallet[hash].mapSproutNoteData[jsoutpt].witnessHeight); EXPECT_EQ(0, wallet.nWitnessCacheSize); } @@ -949,9 +949,9 @@ TEST(wallet_tests, UpdateNullifierNoteMap) { auto nullifier = note.nullifier(sk); // Pretend that we called FindMyNotes while the wallet was locked - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address()}; + SproutNoteData nd {sk.address()}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); @@ -984,35 +984,35 @@ TEST(wallet_tests, UpdatedNoteData) { // First pretend we added the tx to the wallet and // we don't have the key for the second note - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 0}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); // Pretend we mined the tx by adding a fake witness ZCIncrementalMerkleTree tree; - wtx.mapNoteData[jsoutpt].witnesses.push_front(tree.witness()); - wtx.mapNoteData[jsoutpt].witnessHeight = 100; + wtx.mapSproutNoteData[jsoutpt].witnesses.push_front(tree.witness()); + wtx.mapSproutNoteData[jsoutpt].witnessHeight = 100; // Now pretend we added the key for the second note, and // the tx was "added" to the wallet again to update it. // This happens via the 'z_importkey' RPC method. JSOutPoint jsoutpt2 {wtx2.GetHash(), 0, 1}; - CNoteData nd2 {sk.address(), nullifier2}; + SproutNoteData nd2 {sk.address(), nullifier2}; noteData[jsoutpt2] = nd2; wtx2.SetNoteData(noteData); // The txs should initially be different - EXPECT_NE(wtx.mapNoteData, wtx2.mapNoteData); - EXPECT_EQ(1, wtx.mapNoteData[jsoutpt].witnesses.size()); - EXPECT_EQ(100, wtx.mapNoteData[jsoutpt].witnessHeight); + EXPECT_NE(wtx.mapSproutNoteData, wtx2.mapSproutNoteData); + EXPECT_EQ(1, wtx.mapSproutNoteData[jsoutpt].witnesses.size()); + EXPECT_EQ(100, wtx.mapSproutNoteData[jsoutpt].witnessHeight); // After updating, they should be the same EXPECT_TRUE(wallet.UpdatedNoteData(wtx2, wtx)); - EXPECT_EQ(wtx.mapNoteData, wtx2.mapNoteData); - EXPECT_EQ(1, wtx.mapNoteData[jsoutpt].witnesses.size()); - EXPECT_EQ(100, wtx.mapNoteData[jsoutpt].witnessHeight); + EXPECT_EQ(wtx.mapSproutNoteData, wtx2.mapSproutNoteData); + EXPECT_EQ(1, wtx.mapSproutNoteData[jsoutpt].witnesses.size()); + EXPECT_EQ(100, wtx.mapSproutNoteData[jsoutpt].witnessHeight); // TODO: The new note should get witnessed (but maybe not here) (#1350) } @@ -1028,9 +1028,9 @@ TEST(wallet_tests, MarkAffectedTransactionsDirty) { auto nullifier = note.nullifier(sk); auto wtx2 = GetValidSpend(sk, note, 5); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {hash, 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4d57d04c2..80de2d4c8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -653,7 +653,7 @@ void CWallet::SyncMetaData(pair::iterator, typename TxSpe CWalletTx* copyTo = &mapWallet[hash]; if (copyFrom == copyTo) continue; copyTo->mapValue = copyFrom->mapValue; - // mapNoteData not copied on purpose + // mapSproutNoteData not copied on purpose // (it is always set correctly for each CWalletTx) copyTo->vOrderForm = copyFrom->vOrderForm; // fTimeReceivedIsTxTime not copied on purpose @@ -744,7 +744,7 @@ void CWallet::ClearNoteWitnessCache() { LOCK(cs_wallet); for (std::pair& wtxItem : mapWallet) { - for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { + for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) { item.second.witnesses.clear(); item.second.witnessHeight = -1; } @@ -759,8 +759,8 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, { LOCK(cs_wallet); for (std::pair& wtxItem : mapWallet) { - for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { - CNoteData* nd = &(item.second); + for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) { + SproutNoteData* nd = &(item.second); // Only increment witnesses that are behind the current height if (nd->witnessHeight < pindex->nHeight) { // Check the validity of the cache @@ -805,8 +805,8 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, // Increment existing witnesses for (std::pair& wtxItem : mapWallet) { - for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { - CNoteData* nd = &(item.second); + for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) { + SproutNoteData* nd = &(item.second); if (nd->witnessHeight < pindex->nHeight && nd->witnesses.size() > 0) { // Check the validity of the cache @@ -820,9 +820,9 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, // If this is our note, witness it if (txIsOurs) { JSOutPoint jsoutpt {hash, i, j}; - if (mapWallet[hash].mapNoteData.count(jsoutpt) && - mapWallet[hash].mapNoteData[jsoutpt].witnessHeight < pindex->nHeight) { - CNoteData* nd = &(mapWallet[hash].mapNoteData[jsoutpt]); + if (mapWallet[hash].mapSproutNoteData.count(jsoutpt) && + mapWallet[hash].mapSproutNoteData[jsoutpt].witnessHeight < pindex->nHeight) { + SproutNoteData* nd = &(mapWallet[hash].mapSproutNoteData[jsoutpt]); if (nd->witnesses.size() > 0) { // We think this can happen because we write out the // witness cache state after every block increment or @@ -831,7 +831,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, // operations, it is possible for IncrementNoteWitnesses // to be called again on previously-cached blocks. This // doesn't affect existing cached notes because of the - // CNoteData::witnessHeight checks. See #1378 for details. + // SproutNoteData::witnessHeight checks. See #1378 for details. LogPrintf("Inconsistent witness cache state found for %s\n- Cache size: %d\n- Top (height %d): %s\n- New (height %d): %s\n", jsoutpt.ToString(), nd->witnesses.size(), nd->witnessHeight, @@ -853,8 +853,8 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, // Update witness heights for (std::pair& wtxItem : mapWallet) { - for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { - CNoteData* nd = &(item.second); + for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) { + SproutNoteData* nd = &(item.second); if (nd->witnessHeight < pindex->nHeight) { nd->witnessHeight = pindex->nHeight; // Check the validity of the cache @@ -875,8 +875,8 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) { LOCK(cs_wallet); for (std::pair& wtxItem : mapWallet) { - for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { - CNoteData* nd = &(item.second); + for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) { + SproutNoteData* nd = &(item.second); // Only increment witnesses that are not above the current height if (nd->witnessHeight <= pindex->nHeight) { // Check the validity of the cache @@ -898,8 +898,8 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) } nWitnessCacheSize -= 1; for (std::pair& wtxItem : mapWallet) { - for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { - CNoteData* nd = &(item.second); + for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) { + SproutNoteData* nd = &(item.second); // Check the validity of the cache // Technically if there are notes witnessed above the current // height, their cache will now be invalid (relative to the new @@ -1075,7 +1075,7 @@ bool CWallet::UpdateNullifierNoteMap() ZCNoteDecryption dec; for (std::pair& wtxItem : mapWallet) { - for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { + for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) { if (!item.second.nullifier) { if (GetNoteDecryptor(item.second.address, dec)) { auto i = item.first.js; @@ -1103,7 +1103,7 @@ void CWallet::UpdateNullifierNoteMapWithTx(const CWalletTx& wtx) { { LOCK(cs_wallet); - for (const mapNoteData_t::value_type& item : wtx.mapNoteData) { + for (const mapSproutNoteData_t::value_type& item : wtx.mapSproutNoteData) { if (item.second.nullifier) { mapNullifiersToNotes[*item.second.nullifier] = item.first; } @@ -1238,12 +1238,12 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) { - if (wtxIn.mapNoteData.empty() || wtxIn.mapNoteData == wtx.mapNoteData) { + if (wtxIn.mapSproutNoteData.empty() || wtxIn.mapSproutNoteData == wtx.mapSproutNoteData) { return false; } - auto tmp = wtxIn.mapNoteData; + auto tmp = wtxIn.mapSproutNoteData; // Ensure we keep any cached witnesses we may already have - for (const std::pair nd : wtx.mapNoteData) { + for (const std::pair nd : wtx.mapSproutNoteData) { if (tmp.count(nd.first) && nd.second.witnesses.size() > 0) { tmp.at(nd.first).witnesses.assign( nd.second.witnesses.cbegin(), nd.second.witnesses.cend()); @@ -1251,7 +1251,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) tmp.at(nd.first).witnessHeight = nd.second.witnessHeight; } // Now copy over the updated note data - wtx.mapNoteData = tmp; + wtx.mapSproutNoteData = tmp; return true; } @@ -1365,14 +1365,14 @@ boost::optional CWallet::GetNoteNullifier(const JSDescription& jsdesc, * * It should never be necessary to call this method with a CWalletTx, because * the result of FindMyNotes (for the addresses available at the time) will - * already have been cached in CWalletTx.mapNoteData. + * already have been cached in CWalletTx.mapSproutNoteData. */ -mapNoteData_t CWallet::FindMyNotes(const CTransaction& tx) const +mapSproutNoteData_t CWallet::FindMyNotes(const CTransaction& tx) const { LOCK(cs_SpendingKeyStore); uint256 hash = tx.GetHash(); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; for (size_t i = 0; i < tx.vjoinsplit.size(); i++) { auto hSig = tx.vjoinsplit[i].h_sig(*pzcashParams, tx.joinSplitPubKey); for (uint8_t j = 0; j < tx.vjoinsplit[i].ciphertexts.size(); j++) { @@ -1386,10 +1386,10 @@ mapNoteData_t CWallet::FindMyNotes(const CTransaction& tx) const item.second, hSig, j); if (nullifier) { - CNoteData nd {address, *nullifier}; + SproutNoteData nd {address, *nullifier}; noteData.insert(std::make_pair(jsoutpt, nd)); } else { - CNoteData nd {address}; + SproutNoteData nd {address}; noteData.insert(std::make_pair(jsoutpt, nd)); } break; @@ -1429,9 +1429,9 @@ void CWallet::GetNoteWitnesses(std::vector notes, int i = 0; for (JSOutPoint note : notes) { if (mapWallet.count(note.hash) && - mapWallet[note.hash].mapNoteData.count(note) && - mapWallet[note.hash].mapNoteData[note].witnesses.size() > 0) { - witnesses[i] = mapWallet[note.hash].mapNoteData[note].witnesses.front(); + mapWallet[note.hash].mapSproutNoteData.count(note) && + mapWallet[note.hash].mapSproutNoteData[note].witnesses.size() > 0) { + witnesses[i] = mapWallet[note.hash].mapSproutNoteData[note].witnesses.front(); if (!rt) { rt = witnesses[i]->root(); } else { @@ -1578,14 +1578,14 @@ CAmount CWallet::GetChange(const CTransaction& tx) const return nChange; } -void CWalletTx::SetNoteData(mapNoteData_t ¬eData) +void CWalletTx::SetNoteData(mapSproutNoteData_t ¬eData) { - mapNoteData.clear(); - for (const std::pair nd : noteData) { + mapSproutNoteData.clear(); + for (const std::pair nd : noteData) { if (nd.first.js < vjoinsplit.size() && nd.first.n < vjoinsplit[nd.first.js].ciphertexts.size()) { // Store the address and nullifier for the Note - mapNoteData[nd.first] = nd.second; + mapSproutNoteData[nd.first] = nd.second; } else { // If FindMyNotes() was used to obtain noteData, // this should never happen @@ -1691,7 +1691,7 @@ void CWalletTx::GetAmounts(list& listReceived, // Check output side if (!fMyJSDesc) { - for (const std::pair nd : this->mapNoteData) { + for (const std::pair nd : this->mapSproutNoteData) { if (nd.first.js < vjoinsplit.size() && nd.first.n < vjoinsplit[nd.first.js].ciphertexts.size()) { fMyJSDesc = true; break; @@ -3821,13 +3821,13 @@ void CWallet::GetFilteredNotes( continue; } - if (wtx.mapNoteData.size() == 0) { + if (wtx.mapSproutNoteData.size() == 0) { continue; } - for (auto & pair : wtx.mapNoteData) { + for (auto & pair : wtx.mapSproutNoteData) { JSOutPoint jsop = pair.first; - CNoteData nd = pair.second; + SproutNoteData nd = pair.second; SproutPaymentAddress pa = nd.address; // skip notes which belong to a different payment address in the wallet @@ -3902,13 +3902,13 @@ void CWallet::GetUnspentFilteredNotes( continue; } - if (wtx.mapNoteData.size() == 0) { + if (wtx.mapSproutNoteData.size() == 0) { continue; } - for (auto & pair : wtx.mapNoteData) { + for (auto & pair : wtx.mapSproutNoteData) { JSOutPoint jsop = pair.first; - CNoteData nd = pair.second; + SproutNoteData nd = pair.second; SproutPaymentAddress pa = nd.address; // skip notes which belong to a different payment address in the wallet diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 4aee8d01f..f3623df97 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -197,14 +197,14 @@ public: std::string ToString() const; }; -class CNoteData +class SproutNoteData { public: libzcash::SproutPaymentAddress address; /** * Cached note nullifier. May not be set if the wallet was not unlocked when - * this was CNoteData was created. If not set, we always assume that the + * this was SproutNoteData was created. If not set, we always assume that the * note has not been spent. * * It's okay to cache the nullifier in the wallet, because we are storing @@ -225,7 +225,7 @@ public: /** * Block height corresponding to the most current witness. * - * When we first create a CNoteData in CWallet::FindMyNotes, this is set to + * When we first create a SproutNoteData in CWallet::FindMyNotes, this is set to * -1 as a placeholder. The next time CWallet::ChainTip is called, we can * determine what height the witness cache for this note is valid for (even * if no witnesses were cached), and so can set the correct value in @@ -233,10 +233,10 @@ public: */ int witnessHeight; - CNoteData() : address(), nullifier(), witnessHeight {-1} { } - CNoteData(libzcash::SproutPaymentAddress a) : + SproutNoteData() : address(), nullifier(), witnessHeight {-1} { } + SproutNoteData(libzcash::SproutPaymentAddress a) : address {a}, nullifier(), witnessHeight {-1} { } - CNoteData(libzcash::SproutPaymentAddress a, uint256 n) : + SproutNoteData(libzcash::SproutPaymentAddress a, uint256 n) : address {a}, nullifier {n}, witnessHeight {-1} { } ADD_SERIALIZE_METHODS; @@ -249,21 +249,21 @@ public: READWRITE(witnessHeight); } - friend bool operator<(const CNoteData& a, const CNoteData& b) { + friend bool operator<(const SproutNoteData& a, const SproutNoteData& b) { return (a.address < b.address || (a.address == b.address && a.nullifier < b.nullifier)); } - friend bool operator==(const CNoteData& a, const CNoteData& b) { + friend bool operator==(const SproutNoteData& a, const SproutNoteData& b) { return (a.address == b.address && a.nullifier == b.nullifier); } - friend bool operator!=(const CNoteData& a, const CNoteData& b) { + friend bool operator!=(const SproutNoteData& a, const SproutNoteData& b) { return !(a == b); } }; -typedef std::map mapNoteData_t; +typedef std::map mapSproutNoteData_t; /** Decrypted note and its location in a transaction. */ struct CSproutNotePlaintextEntry @@ -350,7 +350,7 @@ private: public: mapValue_t mapValue; - mapNoteData_t mapNoteData; + mapSproutNoteData_t mapSproutNoteData; std::vector > vOrderForm; unsigned int fTimeReceivedIsTxTime; unsigned int nTimeReceived; //! time received by this node @@ -403,7 +403,7 @@ public: { pwallet = pwalletIn; mapValue.clear(); - mapNoteData.clear(); + mapSproutNoteData.clear(); vOrderForm.clear(); fTimeReceivedIsTxTime = false; nTimeReceived = 0; @@ -453,7 +453,7 @@ public: std::vector vUnused; //! Used to be vtxPrev READWRITE(vUnused); READWRITE(mapValue); - READWRITE(mapNoteData); + READWRITE(mapSproutNoteData); READWRITE(vOrderForm); READWRITE(fTimeReceivedIsTxTime); READWRITE(nTimeReceived); @@ -495,7 +495,7 @@ public: MarkDirty(); } - void SetNoteData(mapNoteData_t ¬eData); + void SetNoteData(mapSproutNoteData_t ¬eData); //! filter decides which addresses will count towards the debit CAmount GetDebit(const isminefilter& filter) const; @@ -842,7 +842,7 @@ public: * * - GetFilteredNotes can't filter out spent notes. * - * - Per the comment in CNoteData, we assume that if we don't have a + * - Per the comment in SproutNoteData, we assume that if we don't have a * cached nullifier, the note is not spent. * * Another more problematic implication is that the wallet can fail to @@ -1053,7 +1053,7 @@ public: const ZCNoteDecryption& dec, const uint256& hSig, uint8_t n) const; - mapNoteData_t FindMyNotes(const CTransaction& tx) const; + mapSproutNoteData_t FindMyNotes(const CTransaction& tx) const; bool IsFromMe(const uint256& nullifier) const; void GetNoteWitnesses( std::vector notes, diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index b7fb3276e..89fb92c1e 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -310,9 +310,9 @@ double benchmark_increment_note_witnesses(size_t nTxs) auto note = GetNote(*pzcashParams, sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData); @@ -333,9 +333,9 @@ double benchmark_increment_note_witnesses(size_t nTxs) auto note = GetNote(*pzcashParams, sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - mapNoteData_t noteData; + mapSproutNoteData_t noteData; JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - CNoteData nd {sk.address(), nullifier}; + SproutNoteData nd {sk.address(), nullifier}; noteData[jsoutpt] = nd; wtx.SetNoteData(noteData);