Auto merge of #3340 - Eirik0:rename-merkle-typedefs, r=str4d
Rename merkle tree typedefs to include Sprout This is to be consistent with the naming convention we have been using to distinguish Sprout/Sapling.
This commit is contained in:
@@ -342,7 +342,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
||||
JSOutPoint jso = std::get<0>(t);
|
||||
std::vector<JSOutPoint> vOutPoints = {jso};
|
||||
uint256 inputAnchor;
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
|
||||
std::vector<boost::optional<SproutWitness>> 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<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
boost::unordered_map<uint256, SproutMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
std::vector<uint256> previousCommitments;
|
||||
|
||||
while (!vpubNewProcessed) {
|
||||
@@ -406,7 +406,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
||||
|
||||
CAmount jsInputValue = 0;
|
||||
uint256 jsAnchor;
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> witnesses;
|
||||
std::vector<boost::optional<SproutWitness>> 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<ZCIncrementalWitness> changeWitness;
|
||||
boost::optional<SproutWitness> changeWitness;
|
||||
int n = 0;
|
||||
for (const uint256& commitment : prevJoinSplit.commitments) {
|
||||
tree.append(commitment);
|
||||
@@ -487,7 +487,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
||||
std::vector<SproutNote> vInputNotes;
|
||||
std::vector<SproutSpendingKey> vInputZKeys;
|
||||
std::vector<JSOutPoint> vOutPoints;
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
|
||||
std::vector<boost::optional<SproutWitness>> 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<boost::optional<ZCIncrementalWitness>> witnesses;
|
||||
std::vector<boost::optional<SproutWitness>> 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<JSOutPoint>& outPoints)
|
||||
{
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> witnesses;
|
||||
std::vector<boost::optional<SproutWitness>> 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<boost::optional<ZCIncrementalWitness>> witnesses,
|
||||
std::vector<boost::optional<SproutWitness>> witnesses,
|
||||
uint256 anchor)
|
||||
{
|
||||
if (anchor.IsNull()) {
|
||||
|
||||
@@ -45,7 +45,7 @@ struct MergeToAddressJSInfo {
|
||||
|
||||
// A struct to help us track the witness and anchor for a given JSOutPoint
|
||||
struct MergeToAddressWitnessAnchorData {
|
||||
boost::optional<ZCIncrementalWitness> witness;
|
||||
boost::optional<SproutWitness> witness;
|
||||
uint256 anchor;
|
||||
};
|
||||
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
// JoinSplit where you have the witnesses and anchor
|
||||
UniValue perform_joinsplit(
|
||||
MergeToAddressJSInfo& info,
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> witnesses,
|
||||
std::vector<boost::optional<SproutWitness>> 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<boost::optional<ZCIncrementalWitness>> witnesses,
|
||||
std::vector<boost::optional<SproutWitness>> witnesses,
|
||||
uint256 anchor)
|
||||
{
|
||||
return delegate->perform_joinsplit(info, witnesses, anchor);
|
||||
|
||||
@@ -419,7 +419,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
JSOutPoint jso = std::get<0>(t);
|
||||
std::vector<JSOutPoint> vOutPoints = { jso };
|
||||
uint256 inputAnchor;
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
|
||||
std::vector<boost::optional<SproutWitness>> 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<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
boost::unordered_map<uint256, SproutMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
std::vector<uint256> previousCommitments;
|
||||
|
||||
while (!vpubNewProcessed) {
|
||||
@@ -526,7 +526,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
|
||||
CAmount jsInputValue = 0;
|
||||
uint256 jsAnchor;
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> witnesses;
|
||||
std::vector<boost::optional<SproutWitness>> 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<ZCIncrementalWitness> changeWitness;
|
||||
boost::optional<SproutWitness> changeWitness;
|
||||
int n = 0;
|
||||
for (const uint256& commitment : prevJoinSplit.commitments) {
|
||||
tree.append(commitment);
|
||||
@@ -606,7 +606,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
//
|
||||
std::vector<SproutNote> vInputNotes;
|
||||
std::vector<JSOutPoint> vOutPoints;
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
|
||||
std::vector<boost::optional<SproutWitness>> 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<boost::optional < ZCIncrementalWitness>> witnesses;
|
||||
std::vector<boost::optional < SproutWitness>> 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<JSOutPoint> & outPoints) {
|
||||
std::vector<boost::optional < ZCIncrementalWitness>> witnesses;
|
||||
std::vector<boost::optional < SproutWitness>> 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<boost::optional < ZCIncrementalWitness>> witnesses,
|
||||
std::vector<boost::optional < SproutWitness>> witnesses,
|
||||
uint256 anchor)
|
||||
{
|
||||
if (anchor.IsNull()) {
|
||||
|
||||
@@ -45,7 +45,7 @@ struct AsyncJoinSplitInfo
|
||||
|
||||
// A struct to help us track the witness and anchor for a given JSOutPoint
|
||||
struct WitnessAnchorData {
|
||||
boost::optional<ZCIncrementalWitness> witness;
|
||||
boost::optional<SproutWitness> witness;
|
||||
uint256 anchor;
|
||||
};
|
||||
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
// JoinSplit where you have the witnesses and anchor
|
||||
UniValue perform_joinsplit(
|
||||
AsyncJoinSplitInfo & info,
|
||||
std::vector<boost::optional < ZCIncrementalWitness>> witnesses,
|
||||
std::vector<boost::optional < SproutWitness>> 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<boost::optional < ZCIncrementalWitness>> witnesses,
|
||||
std::vector<boost::optional < SproutWitness>> witnesses,
|
||||
uint256 anchor)
|
||||
{
|
||||
return delegate->perform_joinsplit(info, witnesses, anchor);
|
||||
|
||||
@@ -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);
|
||||
@@ -120,8 +120,8 @@ std::pair<JSOutPoint, SaplingOutPoint> CreateValidBlock(TestWallet& wallet,
|
||||
std::pair<uint256, uint256> GetWitnessesAndAnchors(TestWallet& wallet,
|
||||
std::vector<JSOutPoint>& sproutNotes,
|
||||
std::vector<SaplingOutPoint>& saplingNotes,
|
||||
std::vector<boost::optional<ZCIncrementalWitness>>& sproutWitnesses,
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>>& saplingWitnesses) {
|
||||
std::vector<boost::optional<SproutWitness>>& sproutWitnesses,
|
||||
std::vector<boost::optional<SaplingWitness>>& 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<JSOutPoint> sproutNotes {jsoutpt, jsoutpt2};
|
||||
std::vector<SaplingOutPoint> saplingNotes = SetSaplingNoteData(wtx);
|
||||
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>> saplingWitnesses;
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> 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<uint256, uint256> 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<JSOutPoint> sproutNotes {outpts.first};
|
||||
std::vector<SaplingOutPoint> saplingNotes {outpts.second};
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>> saplingWitnesses;
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> 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<JSOutPoint> sproutNotes {jsoutpt};
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>> saplingWitnesses;
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> 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<boost::optional<ZCIncrementalWitness>> sproutWitnesses5;
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>> saplingWitnesses5;
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses5;
|
||||
std::vector<boost::optional<SaplingWitness>> 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<JSOutPoint> sproutNotes {outpts.first};
|
||||
std::vector<SaplingOutPoint> saplingNotes {outpts.second};
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>> saplingWitnesses;
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses;
|
||||
anchors2 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
}
|
||||
|
||||
@@ -770,8 +770,8 @@ TEST(wallet_tests, CachedWitnessesDecrementFirst) {
|
||||
wallet.AddToWallet(wtx, true, NULL);
|
||||
|
||||
std::vector<JSOutPoint> sproutNotes {jsoutpt};
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>> saplingWitnesses;
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses;
|
||||
|
||||
auto anchors3 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
|
||||
@@ -810,12 +810,12 @@ 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;
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>> saplingWitnesses;
|
||||
SproutMerkleTree sproutTree;
|
||||
SproutMerkleTree sproutRiTree = sproutTree;
|
||||
SaplingMerkleTree saplingTree;
|
||||
SaplingMerkleTree saplingRiTree = saplingTree;
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> 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<JSOutPoint> sproutNotes {jsoutpt, jsoutpt2};
|
||||
std::vector<boost::optional<ZCIncrementalWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>> saplingWitnesses;
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> 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;
|
||||
|
||||
|
||||
@@ -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<boost::optional<ZCIncrementalWitness>> witnesses;
|
||||
std::vector<boost::optional<SproutWitness>> 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<boost::optional<ZCIncrementalWitness>> witnesses;
|
||||
std::vector<boost::optional<SproutWitness>> witnesses;
|
||||
pwalletMain->WitnessNoteCommitment(commitments, witnesses, anchor);
|
||||
|
||||
assert(witnesses.size() == notes.size());
|
||||
|
||||
@@ -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) {
|
||||
@@ -1470,7 +1470,7 @@ bool CWallet::IsFromMe(const uint256& nullifier) const
|
||||
}
|
||||
|
||||
void CWallet::GetSproutNoteWitnesses(std::vector<JSOutPoint> notes,
|
||||
std::vector<boost::optional<ZCIncrementalWitness>>& witnesses,
|
||||
std::vector<boost::optional<SproutWitness>>& witnesses,
|
||||
uint256 &final_anchor)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
@@ -1497,7 +1497,7 @@ void CWallet::GetSproutNoteWitnesses(std::vector<JSOutPoint> notes,
|
||||
}
|
||||
|
||||
void CWallet::GetSaplingNoteWitnesses(std::vector<SaplingOutPoint> notes,
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>>& witnesses,
|
||||
std::vector<boost::optional<SaplingWitness>>& witnesses,
|
||||
uint256 &final_anchor)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
@@ -1888,12 +1888,12 @@ bool CWalletTx::WriteToDisk(CWalletDB *pwalletdb)
|
||||
}
|
||||
|
||||
void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
||||
std::vector<boost::optional<ZCIncrementalWitness>>& witnesses,
|
||||
std::vector<boost::optional<SproutWitness>>& 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<uint256> commitments,
|
||||
{
|
||||
tree.append(note_commitment);
|
||||
|
||||
BOOST_FOREACH(boost::optional<ZCIncrementalWitness>& wit, witnesses) {
|
||||
BOOST_FOREACH(boost::optional<SproutWitness>& wit, witnesses) {
|
||||
if (wit) {
|
||||
wit->append(note_commitment);
|
||||
}
|
||||
@@ -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);
|
||||
@@ -1937,7 +1937,7 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
||||
// TODO: #93; Select a root via some heuristic.
|
||||
final_anchor = tree.root();
|
||||
|
||||
BOOST_FOREACH(boost::optional<ZCIncrementalWitness>& wit, witnesses) {
|
||||
BOOST_FOREACH(boost::optional<SproutWitness>& 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));
|
||||
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
* Cached incremental witnesses for spendable Notes.
|
||||
* Beginning of the list is the most recent witness.
|
||||
*/
|
||||
std::list<ZCIncrementalWitness> witnesses;
|
||||
std::list<SproutWitness> witnesses;
|
||||
|
||||
/**
|
||||
* Block height corresponding to the most current witness.
|
||||
@@ -272,7 +272,7 @@ public:
|
||||
*/
|
||||
SaplingNoteData() : witnessHeight {-1} { }
|
||||
|
||||
std::list<ZCSaplingIncrementalWitness> witnesses;
|
||||
std::list<SaplingWitness> 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<uint256> commitments,
|
||||
std::vector<boost::optional<ZCIncrementalWitness>>& witnesses,
|
||||
std::vector<boost::optional<SproutWitness>>& 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<JSOutPoint> notes,
|
||||
std::vector<boost::optional<ZCIncrementalWitness>>& witnesses,
|
||||
std::vector<boost::optional<SproutWitness>>& witnesses,
|
||||
uint256 &final_anchor);
|
||||
void GetSaplingNoteWitnesses(
|
||||
std::vector<SaplingOutPoint> notes,
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>>& witnesses,
|
||||
std::vector<boost::optional<SaplingWitness>>& 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<std::pair<libzcash::PaymentAddress, uint256>> GetNullifiersForAddresses(const std::set<libzcash::PaymentAddress> & addresses);
|
||||
|
||||
Reference in New Issue
Block a user