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