Rename Merkle Trees to include sprout or sapling
This commit is contained in:
@@ -385,7 +385,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
||||
}
|
||||
|
||||
// Keep track of treestate within this transaction
|
||||
boost::unordered_map<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
boost::unordered_map<uint256, SproutMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
std::vector<uint256> previousCommitments;
|
||||
|
||||
while (!vpubNewProcessed) {
|
||||
@@ -428,7 +428,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
// Update tree state with previous joinsplit
|
||||
ZCIncrementalMerkleTree tree;
|
||||
SproutMerkleTree tree;
|
||||
auto it = intermediates.find(prevJoinSplit.anchor);
|
||||
if (it != intermediates.end()) {
|
||||
tree = it->second;
|
||||
|
||||
@@ -516,7 +516,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
}
|
||||
|
||||
// Keep track of treestate within this transaction
|
||||
boost::unordered_map<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
boost::unordered_map<uint256, SproutMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
std::vector<uint256> previousCommitments;
|
||||
|
||||
while (!vpubNewProcessed) {
|
||||
@@ -548,7 +548,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
// Update tree state with previous joinsplit
|
||||
ZCIncrementalMerkleTree tree;
|
||||
SproutMerkleTree tree;
|
||||
auto it = intermediates.find(prevJoinSplit.anchor);
|
||||
if (it != intermediates.end()) {
|
||||
tree = it->second;
|
||||
|
||||
@@ -51,8 +51,8 @@ public:
|
||||
|
||||
void IncrementNoteWitnesses(const CBlockIndex* pindex,
|
||||
const CBlock* pblock,
|
||||
ZCIncrementalMerkleTree& sproutTree,
|
||||
ZCSaplingIncrementalMerkleTree& saplingTree) {
|
||||
SproutMerkleTree& sproutTree,
|
||||
SaplingMerkleTree& saplingTree) {
|
||||
CWallet::IncrementNoteWitnesses(pindex, pblock, sproutTree, saplingTree);
|
||||
}
|
||||
void DecrementNoteWitnesses(const CBlockIndex* pindex) {
|
||||
@@ -97,8 +97,8 @@ std::pair<JSOutPoint, SaplingOutPoint> CreateValidBlock(TestWallet& wallet,
|
||||
const libzcash::SproutSpendingKey& sk,
|
||||
const CBlockIndex& index,
|
||||
CBlock& block,
|
||||
ZCIncrementalMerkleTree& sproutTree,
|
||||
ZCSaplingIncrementalMerkleTree& saplingTree) {
|
||||
SproutMerkleTree& sproutTree,
|
||||
SaplingMerkleTree& saplingTree) {
|
||||
auto wtx = GetValidReceive(sk, 50, true, 4);
|
||||
auto note = GetNote(sk, wtx, 0, 1);
|
||||
auto nullifier = note.nullifier(sk);
|
||||
@@ -147,7 +147,7 @@ TEST(wallet_tests, note_data_serialisation) {
|
||||
mapSproutNoteData_t noteData;
|
||||
JSOutPoint jsoutpt {wtx.GetHash(), 0, 1};
|
||||
SproutNoteData nd {sk.address(), nullifier};
|
||||
ZCIncrementalMerkleTree tree;
|
||||
SproutMerkleTree tree;
|
||||
nd.witnesses.push_front(tree.witness());
|
||||
noteData[jsoutpt] = nd;
|
||||
|
||||
@@ -605,8 +605,8 @@ TEST(wallet_tests, cached_witnesses_empty_chain) {
|
||||
CBlock block;
|
||||
block.vtx.push_back(wtx);
|
||||
CBlockIndex index(block);
|
||||
ZCIncrementalMerkleTree sproutTree;
|
||||
ZCSaplingIncrementalMerkleTree saplingTree;
|
||||
SproutMerkleTree sproutTree;
|
||||
SaplingMerkleTree saplingTree;
|
||||
wallet.IncrementNoteWitnesses(&index, &block, sproutTree, saplingTree);
|
||||
|
||||
::GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
@@ -624,8 +624,8 @@ TEST(wallet_tests, cached_witnesses_chain_tip) {
|
||||
TestWallet wallet;
|
||||
std::pair<uint256, uint256> anchors1;
|
||||
CBlock block1;
|
||||
ZCIncrementalMerkleTree sproutTree;
|
||||
ZCSaplingIncrementalMerkleTree saplingTree;
|
||||
SproutMerkleTree sproutTree;
|
||||
SaplingMerkleTree saplingTree;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
@@ -675,8 +675,8 @@ TEST(wallet_tests, cached_witnesses_chain_tip) {
|
||||
block2.vtx.push_back(wtx);
|
||||
CBlockIndex index2(block2);
|
||||
index2.nHeight = 2;
|
||||
ZCIncrementalMerkleTree sproutTree2 {sproutTree};
|
||||
ZCSaplingIncrementalMerkleTree saplingTree2 {saplingTree};
|
||||
SproutMerkleTree sproutTree2 {sproutTree};
|
||||
SaplingMerkleTree saplingTree2 {saplingTree};
|
||||
wallet.IncrementNoteWitnesses(&index2, &block2, sproutTree2, saplingTree2);
|
||||
|
||||
auto anchors2 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
@@ -724,8 +724,8 @@ TEST(wallet_tests, cached_witnesses_chain_tip) {
|
||||
|
||||
TEST(wallet_tests, CachedWitnessesDecrementFirst) {
|
||||
TestWallet wallet;
|
||||
ZCIncrementalMerkleTree sproutTree;
|
||||
ZCSaplingIncrementalMerkleTree saplingTree;
|
||||
SproutMerkleTree sproutTree;
|
||||
SaplingMerkleTree saplingTree;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
@@ -810,10 +810,10 @@ TEST(wallet_tests, CachedWitnessesCleanIndex) {
|
||||
std::vector<SaplingOutPoint> saplingNotes;
|
||||
std::vector<uint256> sproutAnchors;
|
||||
std::vector<uint256> saplingAnchors;
|
||||
ZCIncrementalMerkleTree sproutTree;
|
||||
ZCIncrementalMerkleTree sproutRiTree = sproutTree;
|
||||
ZCSaplingIncrementalMerkleTree saplingTree;
|
||||
ZCSaplingIncrementalMerkleTree saplingRiTree = saplingTree;
|
||||
SproutMerkleTree sproutTree;
|
||||
SproutMerkleTree sproutRiTree = sproutTree;
|
||||
SaplingMerkleTree saplingTree;
|
||||
SaplingMerkleTree saplingRiTree = saplingTree;
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>> saplingWitnesses;
|
||||
|
||||
@@ -846,8 +846,8 @@ TEST(wallet_tests, CachedWitnessesCleanIndex) {
|
||||
// Now pretend we are reindexing: the chain is cleared, and each block is
|
||||
// used to increment witnesses again.
|
||||
for (size_t i = 0; i < numBlocks; i++) {
|
||||
ZCIncrementalMerkleTree sproutRiPrevTree {sproutRiTree};
|
||||
ZCSaplingIncrementalMerkleTree saplingRiPrevTree {saplingRiTree};
|
||||
SproutMerkleTree sproutRiPrevTree {sproutRiTree};
|
||||
SaplingMerkleTree saplingRiPrevTree {saplingRiTree};
|
||||
wallet.IncrementNoteWitnesses(&(indices[i]), &(blocks[i]), sproutRiTree, saplingRiTree);
|
||||
|
||||
auto anchors = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
@@ -909,12 +909,12 @@ TEST(wallet_tests, ClearNoteWitnessCache) {
|
||||
auto saplingNotes = SetSaplingNoteData(wtx);
|
||||
|
||||
// Pretend we mined the tx by adding a fake witness
|
||||
ZCIncrementalMerkleTree sproutTree;
|
||||
SproutMerkleTree sproutTree;
|
||||
wtx.mapSproutNoteData[jsoutpt].witnesses.push_front(sproutTree.witness());
|
||||
wtx.mapSproutNoteData[jsoutpt].witnessHeight = 1;
|
||||
wallet.nWitnessCacheSize = 1;
|
||||
|
||||
ZCSaplingIncrementalMerkleTree saplingTree;
|
||||
SaplingMerkleTree saplingTree;
|
||||
wtx.mapSaplingNoteData[saplingNotes[0]].witnesses.push_front(saplingTree.witness());
|
||||
wtx.mapSaplingNoteData[saplingNotes[0]].witnessHeight = 1;
|
||||
wallet.nWitnessCacheSize = 2;
|
||||
@@ -1081,7 +1081,7 @@ TEST(wallet_tests, UpdatedNoteData) {
|
||||
wtx.SetSproutNoteData(noteData);
|
||||
|
||||
// Pretend we mined the tx by adding a fake witness
|
||||
ZCIncrementalMerkleTree tree;
|
||||
SproutMerkleTree tree;
|
||||
wtx.mapSproutNoteData[jsoutpt].witnesses.push_front(tree.witness());
|
||||
wtx.mapSproutNoteData[jsoutpt].witnessHeight = 100;
|
||||
|
||||
|
||||
@@ -2643,7 +2643,7 @@ UniValue zc_sample_joinsplit(const UniValue& params, bool fHelp)
|
||||
LOCK(cs_main);
|
||||
|
||||
uint256 joinSplitPubKey;
|
||||
uint256 anchor = ZCIncrementalMerkleTree().root();
|
||||
uint256 anchor = SproutMerkleTree().root();
|
||||
JSDescription samplejoinsplit(true,
|
||||
*pzcashParams,
|
||||
joinSplitPubKey,
|
||||
|
||||
@@ -451,8 +451,8 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
|
||||
|
||||
void CWallet::ChainTip(const CBlockIndex *pindex,
|
||||
const CBlock *pblock,
|
||||
ZCIncrementalMerkleTree sproutTree,
|
||||
ZCSaplingIncrementalMerkleTree saplingTree,
|
||||
SproutMerkleTree sproutTree,
|
||||
SaplingMerkleTree saplingTree,
|
||||
bool added)
|
||||
{
|
||||
if (added) {
|
||||
@@ -847,8 +847,8 @@ void UpdateWitnessHeights(NoteDataMap& noteDataMap, int indexHeight, int64_t nWi
|
||||
|
||||
void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
||||
const CBlock* pblockIn,
|
||||
ZCIncrementalMerkleTree& sproutTree,
|
||||
ZCSaplingIncrementalMerkleTree& saplingTree)
|
||||
SproutMerkleTree& sproutTree,
|
||||
SaplingMerkleTree& saplingTree)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||
@@ -1893,7 +1893,7 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
||||
{
|
||||
witnesses.resize(commitments.size());
|
||||
CBlockIndex* pindex = chainActive.Genesis();
|
||||
ZCIncrementalMerkleTree tree;
|
||||
SproutMerkleTree tree;
|
||||
|
||||
while (pindex) {
|
||||
CBlock block;
|
||||
@@ -1928,7 +1928,7 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
||||
|
||||
// Consistency check: we should be able to find the current tree
|
||||
// in our CCoins view.
|
||||
ZCIncrementalMerkleTree dummy_tree;
|
||||
SproutMerkleTree dummy_tree;
|
||||
assert(pcoinsTip->GetSproutAnchorAt(current_anchor, dummy_tree));
|
||||
|
||||
pindex = chainActive.Next(pindex);
|
||||
@@ -1980,8 +1980,8 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
|
||||
ret++;
|
||||
}
|
||||
|
||||
ZCIncrementalMerkleTree sproutTree;
|
||||
ZCSaplingIncrementalMerkleTree saplingTree;
|
||||
SproutMerkleTree sproutTree;
|
||||
SaplingMerkleTree saplingTree;
|
||||
// This should never fail: we should always be able to get the tree
|
||||
// state on the path to the tip of our chain
|
||||
assert(pcoinsTip->GetSproutAnchorAt(pindex->hashSproutAnchor, sproutTree));
|
||||
|
||||
@@ -737,8 +737,8 @@ protected:
|
||||
*/
|
||||
void IncrementNoteWitnesses(const CBlockIndex* pindex,
|
||||
const CBlock* pblock,
|
||||
ZCIncrementalMerkleTree& sproutTree,
|
||||
ZCSaplingIncrementalMerkleTree& saplingTree);
|
||||
SproutMerkleTree& sproutTree,
|
||||
SaplingMerkleTree& saplingTree);
|
||||
/**
|
||||
* pindex is the old tip being disconnected.
|
||||
*/
|
||||
@@ -1096,7 +1096,7 @@ public:
|
||||
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
|
||||
CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const;
|
||||
CAmount GetChange(const CTransaction& tx) const;
|
||||
void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, ZCIncrementalMerkleTree sproutTree, ZCSaplingIncrementalMerkleTree saplingTree, bool added);
|
||||
void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, SproutMerkleTree sproutTree, SaplingMerkleTree saplingTree, bool added);
|
||||
/** Saves witness caches and best block locator to disk. */
|
||||
void SetBestChain(const CBlockLocator& loc);
|
||||
std::set<std::pair<libzcash::PaymentAddress, uint256>> GetNullifiersForAddresses(const std::set<libzcash::PaymentAddress> & addresses);
|
||||
|
||||
Reference in New Issue
Block a user