Add parameter for version in GetValidReceive

This commit is contained in:
Eirik Ogilvie-Wigley
2018-07-17 14:21:16 -06:00
committed by Simon
parent e6b0a8b9ee
commit 3a5f66c880
3 changed files with 17 additions and 13 deletions

View File

@@ -10,9 +10,10 @@
CWalletTx GetValidReceive(ZCJoinSplit& params, CWalletTx GetValidReceive(ZCJoinSplit& params,
const libzcash::SproutSpendingKey& sk, CAmount value, const libzcash::SproutSpendingKey& sk, CAmount value,
bool randomInputs) { bool randomInputs,
int32_t version /* = 2 */) {
CMutableTransaction mtx; CMutableTransaction mtx;
mtx.nVersion = 2; // Enable JoinSplits mtx.nVersion = version;
mtx.vin.resize(2); mtx.vin.resize(2);
if (randomInputs) { if (randomInputs) {
mtx.vin[0].prevout.hash = GetRandHash(); mtx.vin[0].prevout.hash = GetRandHash();
@@ -46,9 +47,11 @@ CWalletTx GetValidReceive(ZCJoinSplit& params,
inputs, outputs, 2*value, 0, false}; inputs, outputs, 2*value, 0, false};
mtx.vjoinsplit.push_back(jsdesc); mtx.vjoinsplit.push_back(jsdesc);
// Shielded Output if (version >= 4) {
OutputDescription od; // Shielded Output
mtx.vShieldedOutput.push_back(od); OutputDescription od;
mtx.vShieldedOutput.push_back(od);
}
// Empty output script. // Empty output script.
uint32_t consensusBranchId = SPROUT_BRANCH_ID; uint32_t consensusBranchId = SPROUT_BRANCH_ID;

View File

@@ -9,7 +9,8 @@
CWalletTx GetValidReceive(ZCJoinSplit& params, CWalletTx GetValidReceive(ZCJoinSplit& params,
const libzcash::SproutSpendingKey& sk, CAmount value, const libzcash::SproutSpendingKey& sk, CAmount value,
bool randomInputs); bool randomInputs,
int32_t version = 2);
libzcash::SproutNote GetNote(ZCJoinSplit& params, libzcash::SproutNote GetNote(ZCJoinSplit& params,
const libzcash::SproutSpendingKey& sk, const libzcash::SproutSpendingKey& sk,
const CTransaction& tx, size_t js, size_t n); const CTransaction& tx, size_t js, size_t n);

View File

@@ -69,8 +69,8 @@ public:
} }
}; };
CWalletTx GetValidReceive(const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs) { CWalletTx GetValidReceive(const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs, int32_t version = 2) {
return GetValidReceive(*params, sk, value, randomInputs); return GetValidReceive(*params, sk, value, randomInputs, version);
} }
libzcash::SproutNote GetNote(const libzcash::SproutSpendingKey& sk, libzcash::SproutNote GetNote(const libzcash::SproutSpendingKey& sk,
@@ -99,7 +99,7 @@ std::pair<JSOutPoint, SaplingOutPoint> CreateValidBlock(TestWallet& wallet,
CBlock& block, CBlock& block,
ZCIncrementalMerkleTree& sproutTree, ZCIncrementalMerkleTree& sproutTree,
ZCSaplingIncrementalMerkleTree& saplingTree) { ZCSaplingIncrementalMerkleTree& saplingTree) {
auto wtx = GetValidReceive(sk, 50, true); auto wtx = GetValidReceive(sk, 50, true, 4);
auto note = GetNote(sk, wtx, 0, 1); auto note = GetNote(sk, wtx, 0, 1);
auto nullifier = note.nullifier(sk); auto nullifier = note.nullifier(sk);
@@ -567,7 +567,7 @@ TEST(wallet_tests, cached_witnesses_empty_chain) {
auto sk = libzcash::SproutSpendingKey::random(); auto sk = libzcash::SproutSpendingKey::random();
wallet.AddSpendingKey(sk); wallet.AddSpendingKey(sk);
auto wtx = GetValidReceive(sk, 10, true); auto wtx = GetValidReceive(sk, 10, true, 4);
auto note = GetNote(sk, wtx, 0, 0); auto note = GetNote(sk, wtx, 0, 0);
auto note2 = GetNote(sk, wtx, 0, 1); auto note2 = GetNote(sk, wtx, 0, 1);
auto nullifier = note.nullifier(sk); auto nullifier = note.nullifier(sk);
@@ -648,7 +648,7 @@ TEST(wallet_tests, cached_witnesses_chain_tip) {
{ {
// Second transaction // Second transaction
auto wtx = GetValidReceive(sk, 50, true); auto wtx = GetValidReceive(sk, 50, true, 4);
auto note = GetNote(sk, wtx, 0, 1); auto note = GetNote(sk, wtx, 0, 1);
auto nullifier = note.nullifier(sk); auto nullifier = note.nullifier(sk);
@@ -757,7 +757,7 @@ TEST(wallet_tests, CachedWitnessesDecrementFirst) {
{ {
// Third transaction - never mined // Third transaction - never mined
auto wtx = GetValidReceive(sk, 20, true); auto wtx = GetValidReceive(sk, 20, true, 4);
auto note = GetNote(sk, wtx, 0, 1); auto note = GetNote(sk, wtx, 0, 1);
auto nullifier = note.nullifier(sk); auto nullifier = note.nullifier(sk);
@@ -895,7 +895,7 @@ TEST(wallet_tests, ClearNoteWitnessCache) {
auto sk = libzcash::SproutSpendingKey::random(); auto sk = libzcash::SproutSpendingKey::random();
wallet.AddSpendingKey(sk); wallet.AddSpendingKey(sk);
auto wtx = GetValidReceive(sk, 10, true); auto wtx = GetValidReceive(sk, 10, true, 4);
auto hash = wtx.GetHash(); auto hash = wtx.GetHash();
auto note = GetNote(sk, wtx, 0, 0); auto note = GetNote(sk, wtx, 0, 0);
auto nullifier = note.nullifier(sk); auto nullifier = note.nullifier(sk);