From ce5c8a54e458def4b698b95f810e088e1e508d7d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 16 Feb 2022 09:10:11 -0500 Subject: [PATCH] Make it work correctly --- src/rpc/blockchain.cpp | 8 +++----- src/zcash/IncrementalMerkleTree.hpp | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 24412762a..90b8e7201 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -880,13 +880,11 @@ UniValue getblockmerkletree(const UniValue& params, bool fHelp, const CPubKey& m } phushblockindex = chainActive[nHeight]; - blockRoot = phushblockindex->pprev->hashFinalSaplingRoot; + blockRoot = phushblockindex->hashFinalSaplingRoot; if( pcoinsTip->GetSaplingAnchorAt(blockRoot, tree) ) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << tree.path(); - std::vector merklepath(ss.begin(), ss.end()); - //TODO: this returns the same, wrong data for all heights - return HexStr(merklepath); + ss << tree; + return HexStr(ss.begin(), ss.end()); } else { throw JSONRPCError(RPC_INVALID_PARAMETER, "Could not find merkletree"); } diff --git a/src/zcash/IncrementalMerkleTree.hpp b/src/zcash/IncrementalMerkleTree.hpp index e0a05f6c6..03fa51fda 100644 --- a/src/zcash/IncrementalMerkleTree.hpp +++ b/src/zcash/IncrementalMerkleTree.hpp @@ -108,7 +108,6 @@ public: IncrementalWitness witness() const { return IncrementalWitness(*this); } - MerklePath path(std::deque filler_hashes = std::deque()) const; ADD_SERIALIZE_METHODS; @@ -136,6 +135,7 @@ private: // Collapsed "left" subtrees ordered toward the root of the tree. std::vector> parents; + MerklePath path(std::deque filler_hashes = std::deque()) const; Hash root(size_t depth, std::deque filler_hashes = std::deque()) const; bool is_complete(size_t depth = Depth) const; size_t next_depth(size_t skip) const;