diff --git a/src/coins.cpp b/src/coins.cpp index b49fce18e..257de700b 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -42,8 +42,8 @@ bool CCoins::Spend(uint32_t nPos) Cleanup(); return true; } -bool CCoinsView::GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { return false; } -bool CCoinsView::GetSaplingAnchorAt(const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) const { return false; } +bool CCoinsView::GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { return false; } +bool CCoinsView::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { return false; } bool CCoinsView::GetNullifier(const uint256 &nullifier, ShieldedType type) const { return false; } bool CCoinsView::GetCoins(const uint256 &txid, CCoins &coins) const { return false; } bool CCoinsView::HaveCoins(const uint256 &txid) const { return false; } @@ -62,8 +62,8 @@ bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; } CCoinsViewBacked::CCoinsViewBacked(CCoinsView *viewIn) : base(viewIn) { } -bool CCoinsViewBacked::GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { return base->GetSproutAnchorAt(rt, tree); } -bool CCoinsViewBacked::GetSaplingAnchorAt(const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) const { return base->GetSaplingAnchorAt(rt, tree); } +bool CCoinsViewBacked::GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { return base->GetSproutAnchorAt(rt, tree); } +bool CCoinsViewBacked::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { return base->GetSaplingAnchorAt(rt, tree); } bool CCoinsViewBacked::GetNullifier(const uint256 &nullifier, ShieldedType type) const { return base->GetNullifier(nullifier, type); } bool CCoinsViewBacked::GetCoins(const uint256 &txid, CCoins &coins) const { return base->GetCoins(txid, coins); } bool CCoinsViewBacked::HaveCoins(const uint256 &txid) const { return base->HaveCoins(txid); } @@ -117,7 +117,7 @@ CCoinsMap::const_iterator CCoinsViewCache::FetchCoins(const uint256 &txid) const } -bool CCoinsViewCache::GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { +bool CCoinsViewCache::GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { CAnchorsSproutMap::const_iterator it = cacheSproutAnchors.find(rt); if (it != cacheSproutAnchors.end()) { if (it->second.entered) { @@ -140,7 +140,7 @@ bool CCoinsViewCache::GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTr return true; } -bool CCoinsViewCache::GetSaplingAnchorAt(const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) const { +bool CCoinsViewCache::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { CAnchorsSaplingMap::const_iterator it = cacheSaplingAnchors.find(rt); if (it != cacheSaplingAnchors.end()) { if (it->second.entered) { @@ -222,9 +222,9 @@ void CCoinsViewCache::AbstractPushAnchor( } } -template<> void CCoinsViewCache::PushAnchor(const ZCIncrementalMerkleTree &tree) +template<> void CCoinsViewCache::PushAnchor(const SproutMerkleTree &tree) { - AbstractPushAnchor( + AbstractPushAnchor( tree, SPROUT, cacheSproutAnchors, @@ -232,9 +232,9 @@ template<> void CCoinsViewCache::PushAnchor(const ZCIncrementalMerkleTree &tree) ); } -template<> void CCoinsViewCache::PushAnchor(const ZCSaplingIncrementalMerkleTree &tree) +template<> void CCoinsViewCache::PushAnchor(const SaplingMerkleTree &tree) { - AbstractPushAnchor( + AbstractPushAnchor( tree, SAPLING, cacheSaplingAnchors, @@ -245,7 +245,7 @@ template<> void CCoinsViewCache::PushAnchor(const ZCSaplingIncrementalMerkleTree template<> void CCoinsViewCache::BringBestAnchorIntoCache( const uint256 ¤tRoot, - ZCIncrementalMerkleTree &tree + SproutMerkleTree &tree ) { assert(GetSproutAnchorAt(currentRoot, tree)); @@ -254,7 +254,7 @@ void CCoinsViewCache::BringBestAnchorIntoCache( template<> void CCoinsViewCache::BringBestAnchorIntoCache( const uint256 ¤tRoot, - ZCSaplingIncrementalMerkleTree &tree + SaplingMerkleTree &tree ) { assert(GetSaplingAnchorAt(currentRoot, tree)); @@ -295,7 +295,7 @@ void CCoinsViewCache::AbstractPopAnchor( void CCoinsViewCache::PopAnchor(const uint256 &newrt, ShieldedType type) { switch (type) { case SPROUT: - AbstractPopAnchor( + AbstractPopAnchor( newrt, SPROUT, cacheSproutAnchors, @@ -303,7 +303,7 @@ void CCoinsViewCache::PopAnchor(const uint256 &newrt, ShieldedType type) { ); break; case SAPLING: - AbstractPopAnchor( + AbstractPopAnchor( newrt, SAPLING, cacheSaplingAnchors, @@ -555,7 +555,7 @@ CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const { - boost::unordered_map intermediates; + boost::unordered_map intermediates; BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { @@ -568,7 +568,7 @@ bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const } } - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; auto it = intermediates.find(joinsplit.anchor); if (it != intermediates.end()) { tree = it->second; @@ -588,7 +588,7 @@ bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const if (GetNullifier(spendDescription.nullifier, SAPLING)) // Prevent double spends return false; - ZCSaplingIncrementalMerkleTree tree; + SaplingMerkleTree tree; if (!GetSaplingAnchorAt(spendDescription.anchor, tree)) { return false; } diff --git a/src/coins.h b/src/coins.h index e9abfdded..e0c67db01 100644 --- a/src/coins.h +++ b/src/coins.h @@ -276,7 +276,7 @@ struct CCoinsCacheEntry struct CAnchorsSproutCacheEntry { bool entered; // This will be false if the anchor is removed from the cache - ZCIncrementalMerkleTree tree; // The tree itself + SproutMerkleTree tree; // The tree itself unsigned char flags; enum Flags { @@ -289,7 +289,7 @@ struct CAnchorsSproutCacheEntry struct CAnchorsSaplingCacheEntry { bool entered; // This will be false if the anchor is removed from the cache - ZCSaplingIncrementalMerkleTree tree; // The tree itself + SaplingMerkleTree tree; // The tree itself unsigned char flags; enum Flags { @@ -341,10 +341,10 @@ class CCoinsView { public: //! Retrieve the tree (Sprout) at a particular anchored root in the chain - virtual bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; + virtual bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const; //! Retrieve the tree (Sapling) at a particular anchored root in the chain - virtual bool GetSaplingAnchorAt(const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) const; + virtual bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const; //! Determine whether a nullifier is spent or not virtual bool GetNullifier(const uint256 &nullifier, ShieldedType type) const; @@ -389,8 +389,8 @@ protected: public: CCoinsViewBacked(CCoinsView *viewIn); - bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; - bool GetSaplingAnchorAt(const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) const; + bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const; + bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const; bool GetNullifier(const uint256 &nullifier, ShieldedType type) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; bool HaveCoins(const uint256 &txid) const; @@ -460,8 +460,8 @@ public: ~CCoinsViewCache(); // Standard CCoinsView methods - bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; - bool GetSaplingAnchorAt(const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) const; + bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const; + bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const; bool GetNullifier(const uint256 &nullifier, ShieldedType type) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; bool HaveCoins(const uint256 &txid) const; diff --git a/src/gtest/test_circuit.cpp b/src/gtest/test_circuit.cpp index 2cc9dbcbb..ab2a8ecb6 100644 --- a/src/gtest/test_circuit.cpp +++ b/src/gtest/test_circuit.cpp @@ -106,7 +106,7 @@ bool test_merkle_gadget( mgadget1.generate_r1cs_constraints(); mgadget2.generate_r1cs_constraints(); - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; uint256 commitment1_data = uint256S("54d626e08c1c802b305dad30b7e54a82f102390cc92c7d4db112048935236e9c"); uint256 commitment2_data = uint256S("59d2cde5e65c1414c32ba54f0fe4bdb3d67618125286e6a191317917c812c6d7"); tree.append(commitment1_data); diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp index 3a8c6ad0f..4de2fc471 100644 --- a/src/gtest/test_joinsplit.cpp +++ b/src/gtest/test_joinsplit.cpp @@ -66,7 +66,7 @@ void test_full_api(ZCJoinSplit* js) SproutPaymentAddress recipient_addr = recipient_key.address(); // Create the commitment tree - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; // Set up a JoinSplit description uint64_t vpub_old = 10; @@ -106,7 +106,7 @@ void test_full_api(ZCJoinSplit* js) // Run tests using both phgr and groth as basis for field values for (auto jsdesc : jsdescs) { - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; SproutProofs jsdescs2; // Recipient should decrypt // Now the recipient should spend the money again @@ -327,12 +327,12 @@ for test_input in TEST_VECTORS: void increment_note_witnesses( const uint256& element, - std::vector& witnesses, - ZCIncrementalMerkleTree& tree + std::vector& witnesses, + SproutMerkleTree& tree ) { tree.append(element); - for (ZCIncrementalWitness& w : witnesses) { + for (SproutWitness& w : witnesses) { w.append(element); } witnesses.push_back(tree.witness()); @@ -341,8 +341,8 @@ void increment_note_witnesses( TEST(joinsplit, full_api_test) { { - std::vector witnesses; - ZCIncrementalMerkleTree tree; + std::vector witnesses; + SproutMerkleTree tree; increment_note_witnesses(uint256(), witnesses, tree); SproutSpendingKey sk = SproutSpendingKey::random(); SproutPaymentAddress addr = sk.address(); diff --git a/src/gtest/test_mempool.cpp b/src/gtest/test_mempool.cpp index ac29fbea4..6ef626e5f 100644 --- a/src/gtest/test_mempool.cpp +++ b/src/gtest/test_mempool.cpp @@ -19,11 +19,11 @@ class FakeCoinsViewDB : public CCoinsView { public: FakeCoinsViewDB() {} - bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { + bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { return false; } - bool GetSaplingAnchorAt(const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) const { + bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { return false; } diff --git a/src/gtest/test_merkletree.cpp b/src/gtest/test_merkletree.cpp index 528c1a186..67b08030f 100644 --- a/src/gtest/test_merkletree.cpp +++ b/src/gtest/test_merkletree.cpp @@ -39,7 +39,7 @@ using namespace std; using namespace libsnark; template<> -void expect_deser_same(const ZCTestingIncrementalWitness& expected) +void expect_deser_same(const SproutTestingWitness& expected) { // Cannot check this; IncrementalWitness cannot be // deserialized because it can only be constructed by @@ -195,7 +195,7 @@ TEST(merkletree, vectors) { UniValue path_tests = read_json(MAKE_STRING(json_tests::merkle_path)); UniValue commitment_tests = read_json(MAKE_STRING(json_tests::merkle_commitments)); - test_tree( + test_tree( commitment_tests, root_tests, ser_tests, @@ -212,7 +212,7 @@ TEST(merkletree, SaplingVectors) { UniValue path_tests = read_json(MAKE_STRING(json_tests::merkle_path_sapling)); UniValue commitment_tests = read_json(MAKE_STRING(json_tests::merkle_commitments_sapling)); - test_tree( + test_tree( commitment_tests, root_tests, ser_tests, @@ -254,7 +254,7 @@ TEST(merkletree, emptyroot) { // an integer which converted to little-endian internally. uint256 expected = uint256S("59d2cde5e65c1414c32ba54f0fe4bdb3d67618125286e6a191317917c812c6d7"); - ASSERT_TRUE(ZCIncrementalMerkleTree::empty_root() == expected); + ASSERT_TRUE(SproutMerkleTree::empty_root() == expected); } TEST(merkletree, EmptyrootSapling) { @@ -263,13 +263,13 @@ TEST(merkletree, EmptyrootSapling) { // an integer which converted to little-endian internally. uint256 expected = uint256S("3e49b5f954aa9d3545bc6c37744661eea48d7c34e3000d82b7f0010c30f4c2fb"); - ASSERT_TRUE(ZCSaplingIncrementalMerkleTree::empty_root() == expected); + ASSERT_TRUE(SaplingMerkleTree::empty_root() == expected); } TEST(merkletree, deserializeInvalid) { // attempt to deserialize a small tree from a serialized large tree // (exceeds depth well-formedness check) - ZCIncrementalMerkleTree newTree; + SproutMerkleTree newTree; for (size_t i = 0; i < 16; i++) { newTree.append(uint256S("54d626e08c1c802b305dad30b7e54a82f102390cc92c7d4db112048935236e9c")); @@ -280,7 +280,7 @@ TEST(merkletree, deserializeInvalid) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << newTree; - ZCTestingIncrementalMerkleTree newTreeSmall; + SproutTestingMerkleTree newTreeSmall; ASSERT_THROW({ss >> newTreeSmall;}, std::ios_base::failure); } @@ -292,7 +292,7 @@ TEST(merkletree, deserializeInvalid2) { PROTOCOL_VERSION ); - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; ASSERT_THROW(ss >> tree, std::ios_base::failure); } @@ -304,7 +304,7 @@ TEST(merkletree, deserializeInvalid3) { PROTOCOL_VERSION ); - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; ASSERT_THROW(ss >> tree, std::ios_base::failure); } @@ -316,15 +316,15 @@ TEST(merkletree, deserializeInvalid4) { PROTOCOL_VERSION ); - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; ASSERT_THROW(ss >> tree, std::ios_base::failure); } TEST(merkletree, testZeroElements) { for (int start = 0; start < 20; start++) { - ZCIncrementalMerkleTree newTree; + SproutMerkleTree newTree; - ASSERT_TRUE(newTree.root() == ZCIncrementalMerkleTree::empty_root()); + ASSERT_TRUE(newTree.root() == SproutMerkleTree::empty_root()); for (int i = start; i > 0; i--) { newTree.append(uint256S("54d626e08c1c802b305dad30b7e54a82f102390cc92c7d4db112048935236e9c")); diff --git a/src/gtest/test_transaction.cpp b/src/gtest/test_transaction.cpp index 61a1a6d0e..1350768ff 100644 --- a/src/gtest/test_transaction.cpp +++ b/src/gtest/test_transaction.cpp @@ -12,7 +12,7 @@ extern int GenMax(int n); TEST(Transaction, JSDescriptionRandomized) { // construct a merkle tree - ZCIncrementalMerkleTree merkleTree; + SproutMerkleTree merkleTree; libzcash::SproutSpendingKey k = libzcash::SproutSpendingKey::random(); libzcash::SproutPaymentAddress addr = k.address(); diff --git a/src/gtest/test_transaction_builder.cpp b/src/gtest/test_transaction_builder.cpp index 335cf26d5..e3f3655d3 100644 --- a/src/gtest/test_transaction_builder.cpp +++ b/src/gtest/test_transaction_builder.cpp @@ -61,7 +61,7 @@ TEST(TransactionBuilder, Invoke) auto maybe_note = maybe_pt.get().note(ivk); ASSERT_EQ(static_cast(maybe_note), true); auto note = maybe_note.get(); - ZCSaplingIncrementalMerkleTree tree; + SaplingMerkleTree tree; tree.append(tx1.vShieldedOutput[0].cm); auto anchor = tree.root(); auto witness = tree.witness(); @@ -145,7 +145,7 @@ TEST(TransactionBuilder, FailsWithNegativeChange) // Generate dummy Sapling note libzcash::SaplingNote note(pk, 59999); auto cm = note.cm().value(); - ZCSaplingIncrementalMerkleTree tree; + SaplingMerkleTree tree; tree.append(cm); auto anchor = tree.root(); auto witness = tree.witness(); @@ -191,7 +191,7 @@ TEST(TransactionBuilder, ChangeOutput) // Generate dummy Sapling note libzcash::SaplingNote note(pk, 25000); auto cm = note.cm().value(); - ZCSaplingIncrementalMerkleTree tree; + SaplingMerkleTree tree; tree.append(cm); auto anchor = tree.root(); auto witness = tree.witness(); @@ -289,7 +289,7 @@ TEST(TransactionBuilder, SetFee) // Generate dummy Sapling note libzcash::SaplingNote note(pk, 50000); auto cm = note.cm().value(); - ZCSaplingIncrementalMerkleTree tree; + SaplingMerkleTree tree; tree.append(cm); auto anchor = tree.root(); auto witness = tree.witness(); diff --git a/src/gtest/test_validation.cpp b/src/gtest/test_validation.cpp index 5059a2046..fb6b296ec 100644 --- a/src/gtest/test_validation.cpp +++ b/src/gtest/test_validation.cpp @@ -21,11 +21,11 @@ class FakeCoinsViewDB : public CCoinsView { public: FakeCoinsViewDB() {} - bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { + bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { return false; } - bool GetSaplingAnchorAt(const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) const { + bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { return false; } diff --git a/src/main.cpp b/src/main.cpp index bef466076..cbec77b07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2269,7 +2269,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex if (NetworkUpgradeActive(pindex->pprev->nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { view.PopAnchor(pindex->pprev->hashFinalSaplingRoot, SAPLING); } else { - view.PopAnchor(ZCSaplingIncrementalMerkleTree::empty_root(), SAPLING); + view.PopAnchor(SaplingMerkleTree::empty_root(), SAPLING); } // move best block pointer to prevout block @@ -2414,7 +2414,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!fJustCheck) { view.SetBestBlock(pindex->GetBlockHash()); // Before the genesis block, there was an empty tree - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; pindex->hashSproutAnchor = tree.root(); // The genesis block contained no JoinSplits pindex->hashFinalSproutRoot = pindex->hashSproutAnchor; @@ -2455,7 +2455,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!fJustCheck) { pindex->hashSproutAnchor = old_sprout_tree_root; } - ZCIncrementalMerkleTree sprout_tree; + SproutMerkleTree sprout_tree; // This should never fail: we should always be able to get the root // that is on the tip of our chain assert(view.GetSproutAnchorAt(old_sprout_tree_root, sprout_tree)); @@ -2466,7 +2466,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin assert(sprout_tree.root() == old_sprout_tree_root); } - ZCSaplingIncrementalMerkleTree sapling_tree; + SaplingMerkleTree sapling_tree; assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); // Grab the consensus branch ID for the block's height @@ -2836,8 +2836,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { // Update chainActive and related variables. UpdateTip(pindexDelete->pprev); // Get the current commitment tree - ZCIncrementalMerkleTree newSproutTree; - ZCSaplingIncrementalMerkleTree newSaplingTree; + SproutMerkleTree newSproutTree; + SaplingMerkleTree newSaplingTree; assert(pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), newSproutTree)); assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), newSaplingTree)); // Let wallets know transactions went from 1-confirmed to @@ -2872,8 +2872,8 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * pblock = █ } // Get the current commitment tree - ZCIncrementalMerkleTree oldSproutTree; - ZCSaplingIncrementalMerkleTree oldSaplingTree; + SproutMerkleTree oldSproutTree; + SaplingMerkleTree oldSaplingTree; assert(pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), oldSproutTree)); assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), oldSaplingTree)); // Apply the block atomically to the chain state. diff --git a/src/miner.cpp b/src/miner.cpp index 23d67c40a..e22ac2c62 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -149,7 +149,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); CCoinsViewCache view(pcoinsTip); - ZCSaplingIncrementalMerkleTree sapling_tree; + SaplingMerkleTree sapling_tree; assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); // Priority order to process transactions diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index b16f01698..9a9b0fd57 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -775,7 +775,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp) obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex())); obj.push_back(Pair("pruned", fPruneMode)); - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), tree); obj.push_back(Pair("commitments", static_cast(tree.size()))); diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 67f2ce185..dc795ad7a 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -28,25 +28,25 @@ class CCoinsViewTest : public CCoinsView uint256 hashBestSproutAnchor_; uint256 hashBestSaplingAnchor_; std::map map_; - std::map mapSproutAnchors_; - std::map mapSaplingAnchors_; + std::map mapSproutAnchors_; + std::map mapSaplingAnchors_; std::map mapSproutNullifiers_; std::map mapSaplingNullifiers_; public: CCoinsViewTest() { - hashBestSproutAnchor_ = ZCIncrementalMerkleTree::empty_root(); - hashBestSaplingAnchor_ = ZCSaplingIncrementalMerkleTree::empty_root(); + hashBestSproutAnchor_ = SproutMerkleTree::empty_root(); + hashBestSaplingAnchor_ = SaplingMerkleTree::empty_root(); } - bool GetSproutAnchorAt(const uint256& rt, ZCIncrementalMerkleTree &tree) const { - if (rt == ZCIncrementalMerkleTree::empty_root()) { - ZCIncrementalMerkleTree new_tree; + bool GetSproutAnchorAt(const uint256& rt, SproutMerkleTree &tree) const { + if (rt == SproutMerkleTree::empty_root()) { + SproutMerkleTree new_tree; tree = new_tree; return true; } - std::map::const_iterator it = mapSproutAnchors_.find(rt); + std::map::const_iterator it = mapSproutAnchors_.find(rt); if (it == mapSproutAnchors_.end()) { return false; } else { @@ -55,14 +55,14 @@ public: } } - bool GetSaplingAnchorAt(const uint256& rt, ZCSaplingIncrementalMerkleTree &tree) const { - if (rt == ZCSaplingIncrementalMerkleTree::empty_root()) { - ZCSaplingIncrementalMerkleTree new_tree; + bool GetSaplingAnchorAt(const uint256& rt, SaplingMerkleTree &tree) const { + if (rt == SaplingMerkleTree::empty_root()) { + SaplingMerkleTree new_tree; tree = new_tree; return true; } - std::map::const_iterator it = mapSaplingAnchors_.find(rt); + std::map::const_iterator it = mapSaplingAnchors_.find(rt); if (it == mapSaplingAnchors_.end()) { return false; } else { @@ -174,8 +174,8 @@ public: mapCoins.erase(it++); } - BatchWriteAnchors(mapSproutAnchors, mapSproutAnchors_); - BatchWriteAnchors(mapSaplingAnchors, mapSaplingAnchors_); + BatchWriteAnchors(mapSproutAnchors, mapSproutAnchors_); + BatchWriteAnchors(mapSaplingAnchors, mapSaplingAnchors_); BatchWriteNullifiers(mapSproutNullifiers, mapSproutNullifiers_); BatchWriteNullifiers(mapSaplingNullifiers, mapSaplingNullifiers_); @@ -240,7 +240,7 @@ public: } -uint256 appendRandomSproutCommitment(ZCIncrementalMerkleTree &tree) +uint256 appendRandomSproutCommitment(SproutMerkleTree &tree) { libzcash::SproutSpendingKey k = libzcash::SproutSpendingKey::random(); libzcash::SproutPaymentAddress addr = k.address(); @@ -253,8 +253,8 @@ uint256 appendRandomSproutCommitment(ZCIncrementalMerkleTree &tree) } template bool GetAnchorAt(const CCoinsViewCacheTest &cache, const uint256 &rt, Tree &tree); -template<> bool GetAnchorAt(const CCoinsViewCacheTest &cache, const uint256 &rt, ZCIncrementalMerkleTree &tree) { return cache.GetSproutAnchorAt(rt, tree); } -template<> bool GetAnchorAt(const CCoinsViewCacheTest &cache, const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) { return cache.GetSaplingAnchorAt(rt, tree); } +template<> bool GetAnchorAt(const CCoinsViewCacheTest &cache, const uint256 &rt, SproutMerkleTree &tree) { return cache.GetSproutAnchorAt(rt, tree); } +template<> bool GetAnchorAt(const CCoinsViewCacheTest &cache, const uint256 &rt, SaplingMerkleTree &tree) { return cache.GetSaplingAnchorAt(rt, tree); } BOOST_FIXTURE_TEST_SUITE(coins_tests, BasicTestingSetup) @@ -433,10 +433,10 @@ template void anchorPopRegressionTestImpl(ShieldedType type) BOOST_AUTO_TEST_CASE(anchor_pop_regression_test) { BOOST_TEST_CONTEXT("Sprout") { - anchorPopRegressionTestImpl(SPROUT); + anchorPopRegressionTestImpl(SPROUT); } BOOST_TEST_CONTEXT("Sapling") { - anchorPopRegressionTestImpl(SAPLING); + anchorPopRegressionTestImpl(SAPLING); } } @@ -525,10 +525,10 @@ template void anchorRegressionTestImpl(ShieldedType type) BOOST_AUTO_TEST_CASE(anchor_regression_test) { BOOST_TEST_CONTEXT("Sprout") { - anchorRegressionTestImpl(SPROUT); + anchorRegressionTestImpl(SPROUT); } BOOST_TEST_CONTEXT("Sapling") { - anchorRegressionTestImpl(SAPLING); + anchorRegressionTestImpl(SAPLING); } } @@ -588,10 +588,10 @@ template void anchorsFlushImpl(ShieldedType type) BOOST_AUTO_TEST_CASE(anchors_flush_test) { BOOST_TEST_CONTEXT("Sprout") { - anchorsFlushImpl(SPROUT); + anchorsFlushImpl(SPROUT); } BOOST_TEST_CONTEXT("Sapling") { - anchorsFlushImpl(SAPLING); + anchorsFlushImpl(SAPLING); } } @@ -601,7 +601,7 @@ BOOST_AUTO_TEST_CASE(chained_joinsplits) CCoinsViewTest base; CCoinsViewCacheTest cache(&base); - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; JSDescription js1; js1.anchor = tree.root(); @@ -746,10 +746,10 @@ template void anchorsTestImpl(ShieldedType type) BOOST_AUTO_TEST_CASE(anchors_test) { BOOST_TEST_CONTEXT("Sprout") { - anchorsTestImpl(SPROUT); + anchorsTestImpl(SPROUT); } BOOST_TEST_CONTEXT("Sapling") { - anchorsTestImpl(SAPLING); + anchorsTestImpl(SAPLING); } } diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp index 4b478df40..328813e35 100644 --- a/src/test/rpc_wallet_tests.cpp +++ b/src/test/rpc_wallet_tests.cpp @@ -1204,7 +1204,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) static_cast(operation.get())->testmode = true; AsyncJoinSplitInfo info; - std::vector> witnesses; + std::vector> witnesses; uint256 anchor; try { proxy.perform_joinsplit(info, witnesses, anchor); @@ -1740,7 +1740,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals) static_cast(operation.get())->testmode = true; MergeToAddressJSInfo info; - std::vector> witnesses; + std::vector> witnesses; uint256 anchor; try { proxy.perform_joinsplit(info, witnesses, anchor); diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 34f7a80e9..88f390c17 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -341,7 +341,7 @@ BOOST_AUTO_TEST_CASE(test_basic_joinsplit_verification) // integrity of the scheme through its own tests. // construct a merkle tree - ZCIncrementalMerkleTree merkleTree; + SproutMerkleTree merkleTree; auto k = libzcash::SproutSpendingKey::random(); auto addr = k.address(); diff --git a/src/transaction_builder.cpp b/src/transaction_builder.cpp index f2b915c5a..ed8d8c25b 100644 --- a/src/transaction_builder.cpp +++ b/src/transaction_builder.cpp @@ -15,7 +15,7 @@ SpendDescriptionInfo::SpendDescriptionInfo( libzcash::SaplingExpandedSpendingKey expsk, libzcash::SaplingNote note, uint256 anchor, - ZCSaplingIncrementalWitness witness) : expsk(expsk), note(note), anchor(anchor), witness(witness) + SaplingWitness witness) : expsk(expsk), note(note), anchor(anchor), witness(witness) { librustzcash_sapling_generate_r(alpha.begin()); } @@ -32,7 +32,7 @@ bool TransactionBuilder::AddSaplingSpend( libzcash::SaplingExpandedSpendingKey expsk, libzcash::SaplingNote note, uint256 anchor, - ZCSaplingIncrementalWitness witness) + SaplingWitness witness) { // Consistency check: all anchors must equal the first one if (!spends.empty()) { diff --git a/src/transaction_builder.h b/src/transaction_builder.h index 6c159e7aa..0291c7ad1 100644 --- a/src/transaction_builder.h +++ b/src/transaction_builder.h @@ -23,13 +23,13 @@ struct SpendDescriptionInfo { libzcash::SaplingNote note; uint256 alpha; uint256 anchor; - ZCSaplingIncrementalWitness witness; + SaplingWitness witness; SpendDescriptionInfo( libzcash::SaplingExpandedSpendingKey expsk, libzcash::SaplingNote note, uint256 anchor, - ZCSaplingIncrementalWitness witness); + SaplingWitness witness); }; struct OutputDescriptionInfo { @@ -79,7 +79,7 @@ public: libzcash::SaplingExpandedSpendingKey expsk, libzcash::SaplingNote note, uint256 anchor, - ZCSaplingIncrementalWitness witness); + SaplingWitness witness); void AddSaplingOutput( libzcash::SaplingFullViewingKey from, diff --git a/src/txdb.cpp b/src/txdb.cpp index 2589e7b1c..36b992a8e 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -44,9 +44,9 @@ CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(Get } -bool CCoinsViewDB::GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { - if (rt == ZCIncrementalMerkleTree::empty_root()) { - ZCIncrementalMerkleTree new_tree; +bool CCoinsViewDB::GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { + if (rt == SproutMerkleTree::empty_root()) { + SproutMerkleTree new_tree; tree = new_tree; return true; } @@ -56,9 +56,9 @@ bool CCoinsViewDB::GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree return read; } -bool CCoinsViewDB::GetSaplingAnchorAt(const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) const { - if (rt == ZCSaplingIncrementalMerkleTree::empty_root()) { - ZCSaplingIncrementalMerkleTree new_tree; +bool CCoinsViewDB::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { + if (rt == SaplingMerkleTree::empty_root()) { + SaplingMerkleTree new_tree; tree = new_tree; return true; } @@ -105,11 +105,11 @@ uint256 CCoinsViewDB::GetBestAnchor(ShieldedType type) const { switch (type) { case SPROUT: if (!db.Read(DB_BEST_SPROUT_ANCHOR, hashBestAnchor)) - return ZCIncrementalMerkleTree::empty_root(); + return SproutMerkleTree::empty_root(); break; case SAPLING: if (!db.Read(DB_BEST_SAPLING_ANCHOR, hashBestAnchor)) - return ZCSaplingIncrementalMerkleTree::empty_root(); + return SaplingMerkleTree::empty_root(); break; default: throw runtime_error("Unknown shielded type"); @@ -176,17 +176,17 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, mapCoins.erase(itOld); } - ::BatchWriteAnchors(batch, mapSproutAnchors, DB_SPROUT_ANCHOR); - ::BatchWriteAnchors(batch, mapSaplingAnchors, DB_SAPLING_ANCHOR); + ::BatchWriteAnchors(batch, mapSproutAnchors, DB_SPROUT_ANCHOR); + ::BatchWriteAnchors(batch, mapSaplingAnchors, DB_SAPLING_ANCHOR); ::BatchWriteNullifiers(batch, mapSproutNullifiers, DB_NULLIFIER); ::BatchWriteNullifiers(batch, mapSaplingNullifiers, DB_SAPLING_NULLIFIER); if (!hashBlock.IsNull()) batch.Write(DB_BEST_BLOCK, hashBlock); - if (!hashSproutAnchor.IsNull() && hashSproutAnchor != ZCIncrementalMerkleTree::empty_root()) + if (!hashSproutAnchor.IsNull() && hashSproutAnchor != SproutMerkleTree::empty_root()) batch.Write(DB_BEST_SPROUT_ANCHOR, hashSproutAnchor); - if (!hashSaplingAnchor.IsNull() && hashSaplingAnchor != ZCSaplingIncrementalMerkleTree::empty_root()) + if (!hashSaplingAnchor.IsNull() && hashSaplingAnchor != SaplingMerkleTree::empty_root()) batch.Write(DB_BEST_SAPLING_ANCHOR, hashSaplingAnchor); LogPrint("coindb", "Committing %u changed transactions (out of %u) to coin database...\n", (unsigned int)changed, (unsigned int)count); diff --git a/src/txdb.h b/src/txdb.h index e8d8ed899..a415ad2bb 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -35,8 +35,8 @@ protected: public: CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); - bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; - bool GetSaplingAnchorAt(const uint256 &rt, ZCSaplingIncrementalMerkleTree &tree) const; + bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const; + bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const; bool GetNullifier(const uint256 &nf, ShieldedType type) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; bool HaveCoins(const uint256 &txid) const; diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 703806667..cf04ad577 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -405,14 +405,14 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const i++; } - boost::unordered_map intermediates; + boost::unordered_map intermediates; BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) { assert(!pcoins->GetNullifier(nf, SPROUT)); } - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; auto it = intermediates.find(joinsplit.anchor); if (it != intermediates.end()) { tree = it->second; @@ -428,7 +428,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const intermediates.insert(std::make_pair(tree.root(), tree)); } for (const SpendDescription &spendDescription : tx.vShieldedSpend) { - ZCSaplingIncrementalMerkleTree tree; + SaplingMerkleTree tree; assert(pcoins->GetSaplingAnchorAt(spendDescription.anchor, tree)); assert(!pcoins->GetNullifier(spendDescription.nullifier, SAPLING)); diff --git a/src/utiltest.cpp b/src/utiltest.cpp index f2cd7f584..898f2c4c9 100644 --- a/src/utiltest.cpp +++ b/src/utiltest.cpp @@ -99,7 +99,7 @@ CWalletTx GetValidSpend(ZCJoinSplit& params, mtx.joinSplitPubKey = joinSplitPubKey; // Fake tree for the unused witness - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; libzcash::JSOutput dummyout; libzcash::JSInput dummyin; diff --git a/src/validationinterface.h b/src/validationinterface.h index 60e90d012..c87a85930 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -34,7 +34,7 @@ protected: virtual void UpdatedBlockTip(const CBlockIndex *pindex) {} virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) {} virtual void EraseFromWallet(const uint256 &hash) {} - virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, ZCIncrementalMerkleTree sproutTree, ZCSaplingIncrementalMerkleTree saplingTree, bool added) {} + virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, SproutMerkleTree sproutTree, SaplingMerkleTree saplingTree, bool added) {} virtual void SetBestChain(const CBlockLocator &locator) {} virtual void UpdatedTransaction(const uint256 &hash) {} virtual void Inventory(const uint256 &hash) {} @@ -55,7 +55,7 @@ struct CMainSignals { /** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */ boost::signals2::signal UpdatedTransaction; /** Notifies listeners of a change to the tip of the active block chain. */ - boost::signals2::signal ChainTip; + boost::signals2::signal ChainTip; /** Notifies listeners of a new active block chain. */ boost::signals2::signal SetBestChain; /** Notifies listeners about an inventory item being seen on the network. */ diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index cc4551f6f..6a16dd4fa 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -342,7 +342,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() JSOutPoint jso = std::get<0>(t); std::vector vOutPoints = {jso}; uint256 inputAnchor; - std::vector> vInputWitnesses; + std::vector> vInputWitnesses; pwalletMain->GetSproutNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor); jsopWitnessAnchorMap[jso.ToString()] = MergeToAddressWitnessAnchorData{vInputWitnesses[0], inputAnchor}; } @@ -385,7 +385,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() } // Keep track of treestate within this transaction - boost::unordered_map intermediates; + boost::unordered_map intermediates; std::vector previousCommitments; while (!vpubNewProcessed) { @@ -406,7 +406,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() CAmount jsInputValue = 0; uint256 jsAnchor; - std::vector> witnesses; + std::vector> witnesses; JSDescription prevJoinSplit; @@ -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; @@ -437,7 +437,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() } assert(changeOutputIndex != -1); - boost::optional changeWitness; + boost::optional changeWitness; int n = 0; for (const uint256& commitment : prevJoinSplit.commitments) { tree.append(commitment); @@ -487,7 +487,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() std::vector vInputNotes; std::vector vInputZKeys; std::vector vOutPoints; - std::vector> vInputWitnesses; + std::vector> vInputWitnesses; uint256 inputAnchor; int numInputsNeeded = (jsChange > 0) ? 1 : 0; while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) { @@ -544,7 +544,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() if (!optionalWitness) { throw JSONRPCError(RPC_WALLET_ERROR, "Witness for note commitment is null"); } - ZCIncrementalWitness w = *optionalWitness; // could use .get(); + SproutWitness w = *optionalWitness; // could use .get(); if (jsChange > 0) { for (const uint256& commitment : previousCommitments) { w.append(commitment); @@ -695,7 +695,7 @@ void AsyncRPCOperation_mergetoaddress::sign_send_raw_transaction(UniValue obj) UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInfo& info) { - std::vector> witnesses; + std::vector> witnesses; uint256 anchor; { LOCK(cs_main); @@ -707,7 +707,7 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInf UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInfo& info, std::vector& outPoints) { - std::vector> witnesses; + std::vector> witnesses; uint256 anchor; { LOCK(cs_main); @@ -718,7 +718,7 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInf UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit( MergeToAddressJSInfo& info, - std::vector> witnesses, + std::vector> witnesses, uint256 anchor) { if (anchor.IsNull()) { diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.h b/src/wallet/asyncrpcoperation_mergetoaddress.h index 0bbd5f82d..ef59ba67b 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.h +++ b/src/wallet/asyncrpcoperation_mergetoaddress.h @@ -45,7 +45,7 @@ struct MergeToAddressJSInfo { // A struct to help us track the witness and anchor for a given JSOutPoint struct MergeToAddressWitnessAnchorData { - boost::optional witness; + boost::optional witness; uint256 anchor; }; @@ -112,7 +112,7 @@ private: // JoinSplit where you have the witnesses and anchor UniValue perform_joinsplit( MergeToAddressJSInfo& info, - std::vector> witnesses, + std::vector> witnesses, uint256 anchor); void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error @@ -172,7 +172,7 @@ public: UniValue perform_joinsplit( MergeToAddressJSInfo& info, - std::vector> witnesses, + std::vector> witnesses, uint256 anchor) { return delegate->perform_joinsplit(info, witnesses, anchor); diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index f5da139eb..50c4ebde2 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -419,7 +419,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { JSOutPoint jso = std::get<0>(t); std::vector vOutPoints = { jso }; uint256 inputAnchor; - std::vector> vInputWitnesses; + std::vector> vInputWitnesses; pwalletMain->GetSproutNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor); jsopWitnessAnchorMap[ jso.ToString() ] = WitnessAnchorData{ vInputWitnesses[0], inputAnchor }; } @@ -516,7 +516,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { } // Keep track of treestate within this transaction - boost::unordered_map intermediates; + boost::unordered_map intermediates; std::vector previousCommitments; while (!vpubNewProcessed) { @@ -526,7 +526,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { CAmount jsInputValue = 0; uint256 jsAnchor; - std::vector> witnesses; + std::vector> witnesses; JSDescription prevJoinSplit; @@ -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; @@ -557,7 +557,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { } assert(changeOutputIndex != -1); - boost::optional changeWitness; + boost::optional changeWitness; int n = 0; for (const uint256& commitment : prevJoinSplit.commitments) { tree.append(commitment); @@ -606,7 +606,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { // std::vector vInputNotes; std::vector vOutPoints; - std::vector> vInputWitnesses; + std::vector> vInputWitnesses; uint256 inputAnchor; int numInputsNeeded = (jsChange>0) ? 1 : 0; while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) { @@ -663,7 +663,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { if (!optionalWitness) { throw JSONRPCError(RPC_WALLET_ERROR, "Witness for note commitment is null"); } - ZCIncrementalWitness w = *optionalWitness; // could use .get(); + SproutWitness w = *optionalWitness; // could use .get(); if (jsChange > 0) { for (const uint256& commitment : previousCommitments) { w.append(commitment); @@ -920,7 +920,7 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() { } UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info) { - std::vector> witnesses; + std::vector> witnesses; uint256 anchor; { LOCK(cs_main); @@ -931,7 +931,7 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info, std::vector & outPoints) { - std::vector> witnesses; + std::vector> witnesses; uint256 anchor; { LOCK(cs_main); @@ -942,7 +942,7 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info UniValue AsyncRPCOperation_sendmany::perform_joinsplit( AsyncJoinSplitInfo & info, - std::vector> witnesses, + std::vector> witnesses, uint256 anchor) { if (anchor.IsNull()) { diff --git a/src/wallet/asyncrpcoperation_sendmany.h b/src/wallet/asyncrpcoperation_sendmany.h index 24f174574..d3729804a 100644 --- a/src/wallet/asyncrpcoperation_sendmany.h +++ b/src/wallet/asyncrpcoperation_sendmany.h @@ -45,7 +45,7 @@ struct AsyncJoinSplitInfo // A struct to help us track the witness and anchor for a given JSOutPoint struct WitnessAnchorData { - boost::optional witness; + boost::optional witness; uint256 anchor; }; @@ -112,7 +112,7 @@ private: // JoinSplit where you have the witnesses and anchor UniValue perform_joinsplit( AsyncJoinSplitInfo & info, - std::vector> witnesses, + std::vector> witnesses, uint256 anchor); void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error @@ -173,7 +173,7 @@ public: UniValue perform_joinsplit( AsyncJoinSplitInfo & info, - std::vector> witnesses, + std::vector> witnesses, uint256 anchor) { return delegate->perform_joinsplit(info, witnesses, anchor); diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index 83807986e..5bacb6ff5 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -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 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); @@ -120,8 +120,8 @@ std::pair CreateValidBlock(TestWallet& wallet, std::pair GetWitnessesAndAnchors(TestWallet& wallet, std::vector& sproutNotes, std::vector& saplingNotes, - std::vector>& sproutWitnesses, - std::vector>& saplingWitnesses) { + std::vector>& sproutWitnesses, + std::vector>& saplingWitnesses) { sproutWitnesses.clear(); saplingWitnesses.clear(); uint256 sproutAnchor; @@ -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; @@ -585,8 +585,8 @@ TEST(wallet_tests, cached_witnesses_empty_chain) { std::vector sproutNotes {jsoutpt, jsoutpt2}; std::vector saplingNotes = SetSaplingNoteData(wtx); - std::vector> sproutWitnesses; - std::vector> saplingWitnesses; + std::vector> sproutWitnesses; + std::vector> saplingWitnesses; ::GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses); @@ -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 anchors1; CBlock block1; - ZCIncrementalMerkleTree sproutTree; - ZCSaplingIncrementalMerkleTree saplingTree; + SproutMerkleTree sproutTree; + SaplingMerkleTree saplingTree; auto sk = libzcash::SproutSpendingKey::random(); wallet.AddSpendingKey(sk); @@ -639,8 +639,8 @@ TEST(wallet_tests, cached_witnesses_chain_tip) { // Called to fetch anchor std::vector sproutNotes {outpts.first}; std::vector saplingNotes {outpts.second}; - std::vector> sproutWitnesses; - std::vector> saplingWitnesses; + std::vector> sproutWitnesses; + std::vector> saplingWitnesses; anchors1 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses); EXPECT_NE(anchors1.first, anchors1.second); @@ -661,8 +661,8 @@ TEST(wallet_tests, cached_witnesses_chain_tip) { wallet.AddToWallet(wtx, true, NULL); std::vector sproutNotes {jsoutpt}; - std::vector> sproutWitnesses; - std::vector> saplingWitnesses; + std::vector> sproutWitnesses; + std::vector> saplingWitnesses; GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses); @@ -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); @@ -709,8 +709,8 @@ TEST(wallet_tests, cached_witnesses_chain_tip) { // Incrementing with the same block again should not change the cache wallet.IncrementNoteWitnesses(&index2, &block2, sproutTree, saplingTree); - std::vector> sproutWitnesses5; - std::vector> saplingWitnesses5; + std::vector> sproutWitnesses5; + std::vector> saplingWitnesses5; auto anchors5 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses5, saplingWitnesses5); EXPECT_NE(anchors5.first, anchors5.second); @@ -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); @@ -750,8 +750,8 @@ TEST(wallet_tests, CachedWitnessesDecrementFirst) { // Called to fetch anchor std::vector sproutNotes {outpts.first}; std::vector saplingNotes {outpts.second}; - std::vector> sproutWitnesses; - std::vector> saplingWitnesses; + std::vector> sproutWitnesses; + std::vector> saplingWitnesses; anchors2 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses); } @@ -770,8 +770,8 @@ TEST(wallet_tests, CachedWitnessesDecrementFirst) { wallet.AddToWallet(wtx, true, NULL); std::vector sproutNotes {jsoutpt}; - std::vector> sproutWitnesses; - std::vector> saplingWitnesses; + std::vector> sproutWitnesses; + std::vector> saplingWitnesses; auto anchors3 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses); @@ -810,12 +810,12 @@ TEST(wallet_tests, CachedWitnessesCleanIndex) { std::vector saplingNotes; std::vector sproutAnchors; std::vector saplingAnchors; - ZCIncrementalMerkleTree sproutTree; - ZCIncrementalMerkleTree sproutRiTree = sproutTree; - ZCSaplingIncrementalMerkleTree saplingTree; - ZCSaplingIncrementalMerkleTree saplingRiTree = saplingTree; - std::vector> sproutWitnesses; - std::vector> saplingWitnesses; + SproutMerkleTree sproutTree; + SproutMerkleTree sproutRiTree = sproutTree; + SaplingMerkleTree saplingTree; + SaplingMerkleTree saplingRiTree = saplingTree; + std::vector> sproutWitnesses; + std::vector> saplingWitnesses; auto sk = libzcash::SproutSpendingKey::random(); wallet.AddSpendingKey(sk); @@ -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; @@ -922,8 +922,8 @@ TEST(wallet_tests, ClearNoteWitnessCache) { wallet.AddToWallet(wtx, true, NULL); std::vector sproutNotes {jsoutpt, jsoutpt2}; - std::vector> sproutWitnesses; - std::vector> saplingWitnesses; + std::vector> sproutWitnesses; + std::vector> saplingWitnesses; // Before clearing, we should have a witness for one note GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses); @@ -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; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d196da4e5..e46d06d1b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2646,7 +2646,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, @@ -2846,7 +2846,7 @@ UniValue zc_raw_receive(const UniValue& params, bool fHelp) SproutNote decrypted_note = npt.note(payment_addr); assert(pwalletMain != NULL); - std::vector> witnesses; + std::vector> witnesses; uint256 anchor; uint256 commitment = decrypted_note.cm(); pwalletMain->WitnessNoteCommitment( @@ -2947,7 +2947,7 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp) } uint256 anchor; - std::vector> witnesses; + std::vector> witnesses; pwalletMain->WitnessNoteCommitment(commitments, witnesses, anchor); assert(witnesses.size() == notes.size()); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d02b03e7c..7905c2368 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -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& wtxItem : mapWallet) { @@ -1470,7 +1470,7 @@ bool CWallet::IsFromMe(const uint256& nullifier) const } void CWallet::GetSproutNoteWitnesses(std::vector notes, - std::vector>& witnesses, + std::vector>& witnesses, uint256 &final_anchor) { LOCK(cs_wallet); @@ -1497,7 +1497,7 @@ void CWallet::GetSproutNoteWitnesses(std::vector notes, } void CWallet::GetSaplingNoteWitnesses(std::vector notes, - std::vector>& witnesses, + std::vector>& witnesses, uint256 &final_anchor) { LOCK(cs_wallet); @@ -1888,12 +1888,12 @@ bool CWalletTx::WriteToDisk(CWalletDB *pwalletdb) } void CWallet::WitnessNoteCommitment(std::vector commitments, - std::vector>& witnesses, + std::vector>& witnesses, uint256 &final_anchor) { witnesses.resize(commitments.size()); CBlockIndex* pindex = chainActive.Genesis(); - ZCIncrementalMerkleTree tree; + SproutMerkleTree tree; while (pindex) { CBlock block; @@ -1907,7 +1907,7 @@ void CWallet::WitnessNoteCommitment(std::vector commitments, { tree.append(note_commitment); - BOOST_FOREACH(boost::optional& wit, witnesses) { + BOOST_FOREACH(boost::optional& wit, witnesses) { if (wit) { wit->append(note_commitment); } @@ -1928,7 +1928,7 @@ void CWallet::WitnessNoteCommitment(std::vector 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); @@ -1937,7 +1937,7 @@ void CWallet::WitnessNoteCommitment(std::vector commitments, // TODO: #93; Select a root via some heuristic. final_anchor = tree.root(); - BOOST_FOREACH(boost::optional& wit, witnesses) { + BOOST_FOREACH(boost::optional& wit, witnesses) { if (wit) { assert(final_anchor == wit->root()); } @@ -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)); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 43fdc5d77..d395d0dbb 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -220,7 +220,7 @@ public: * Cached incremental witnesses for spendable Notes. * Beginning of the list is the most recent witness. */ - std::list witnesses; + std::list witnesses; /** * Block height corresponding to the most current witness. @@ -272,7 +272,7 @@ public: */ SaplingNoteData() : witnessHeight {-1} { } - std::list witnesses; + std::list witnesses; int witnessHeight; }; @@ -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. */ @@ -1033,7 +1033,7 @@ public: void EraseFromWallet(const uint256 &hash); void WitnessNoteCommitment( std::vector commitments, - std::vector>& witnesses, + std::vector>& witnesses, uint256 &final_anchor); int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); void ReacceptWalletTransactions(); @@ -1077,11 +1077,11 @@ public: bool IsFromMe(const uint256& nullifier) const; void GetSproutNoteWitnesses( std::vector notes, - std::vector>& witnesses, + std::vector>& witnesses, uint256 &final_anchor); void GetSaplingNoteWitnesses( std::vector notes, - std::vector>& witnesses, + std::vector>& witnesses, uint256 &final_anchor); isminetype IsMine(const CTxIn& txin) const; @@ -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> GetNullifiersForAddresses(const std::set & addresses); diff --git a/src/zcash/IncrementalMerkleTree.hpp b/src/zcash/IncrementalMerkleTree.hpp index 1e4c8ac85..79a90bc5b 100644 --- a/src/zcash/IncrementalMerkleTree.hpp +++ b/src/zcash/IncrementalMerkleTree.hpp @@ -248,16 +248,16 @@ EmptyMerkleRoots IncrementalMerkleTree::emptyroots; } // end namespace `libzcash` -typedef libzcash::IncrementalMerkleTree ZCIncrementalMerkleTree; -typedef libzcash::IncrementalMerkleTree ZCTestingIncrementalMerkleTree; +typedef libzcash::IncrementalMerkleTree SproutMerkleTree; +typedef libzcash::IncrementalMerkleTree SproutTestingMerkleTree; -typedef libzcash::IncrementalWitness ZCIncrementalWitness; -typedef libzcash::IncrementalWitness ZCTestingIncrementalWitness; +typedef libzcash::IncrementalWitness SproutWitness; +typedef libzcash::IncrementalWitness SproutTestingWitness; -typedef libzcash::IncrementalMerkleTree ZCSaplingIncrementalMerkleTree; -typedef libzcash::IncrementalMerkleTree ZCSaplingTestingIncrementalMerkleTree; +typedef libzcash::IncrementalMerkleTree SaplingMerkleTree; +typedef libzcash::IncrementalMerkleTree SaplingTestingMerkleTree; -typedef libzcash::IncrementalWitness ZCSaplingIncrementalWitness; -typedef libzcash::IncrementalWitness ZCSaplingTestingIncrementalWitness; +typedef libzcash::IncrementalWitness SaplingWitness; +typedef libzcash::IncrementalWitness SaplingTestingWitness; #endif /* ZC_INCREMENTALMERKLETREE_H_ */ diff --git a/src/zcash/JoinSplit.cpp b/src/zcash/JoinSplit.cpp index 50ee8f1b0..0772ecb67 100644 --- a/src/zcash/JoinSplit.cpp +++ b/src/zcash/JoinSplit.cpp @@ -428,10 +428,10 @@ JSOutput::JSOutput() : addr(uint256(), uint256()), value(0) { addr = a_sk.address(); } -JSInput::JSInput() : witness(ZCIncrementalMerkleTree().witness()), +JSInput::JSInput() : witness(SproutMerkleTree().witness()), key(SproutSpendingKey::random()) { note = SproutNote(key.address().a_pk, 0, random_uint256(), random_uint256()); - ZCIncrementalMerkleTree dummy_tree; + SproutMerkleTree dummy_tree; dummy_tree.append(note.cm()); witness = dummy_tree.witness(); } diff --git a/src/zcash/JoinSplit.hpp b/src/zcash/JoinSplit.hpp index 2e1c79335..c37926ede 100644 --- a/src/zcash/JoinSplit.hpp +++ b/src/zcash/JoinSplit.hpp @@ -25,12 +25,12 @@ typedef boost::variant SproutProof; class JSInput { public: - ZCIncrementalWitness witness; + SproutWitness witness; SproutNote note; SproutSpendingKey key; JSInput(); - JSInput(ZCIncrementalWitness witness, + JSInput(SproutWitness witness, SproutNote note, SproutSpendingKey key) : witness(witness), note(note), key(key) { } diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index fea10000f..2a1afed80 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -112,7 +112,7 @@ double benchmark_create_joinsplit() uint256 joinSplitPubKey; /* Get the anchor of an empty commitment tree. */ - uint256 anchor = ZCIncrementalMerkleTree().root(); + uint256 anchor = SproutMerkleTree().root(); struct timeval tv_start; timer_start(tv_start); @@ -298,8 +298,8 @@ double benchmark_try_decrypt_notes(size_t nAddrs) double benchmark_increment_note_witnesses(size_t nTxs) { CWallet wallet; - ZCIncrementalMerkleTree sproutTree; - ZCSaplingIncrementalMerkleTree saplingTree; + SproutMerkleTree sproutTree; + SaplingMerkleTree saplingTree; auto sk = libzcash::SproutSpendingKey::random(); wallet.AddSpendingKey(sk); @@ -355,12 +355,12 @@ double benchmark_increment_note_witnesses(size_t nTxs) // Fake the input of a given block class FakeCoinsViewDB : public CCoinsViewDB { uint256 hash; - ZCIncrementalMerkleTree t; + SproutMerkleTree t; public: FakeCoinsViewDB(std::string dbName, uint256& hash) : CCoinsViewDB(dbName, 100, false, false), hash(hash) {} - bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { + bool GetAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { if (rt == t.root()) { tree = t; return true;