Rename tx.valueBalance -> tx.valueBalanceSapling

This commit is contained in:
Kris Nuttycombe 2021-06-29 14:40:26 -06:00 committed by Jack Grigg
parent feef0e03f6
commit fd91f099f4
13 changed files with 107 additions and 107 deletions

View File

@ -324,7 +324,7 @@ TEST(ChecktransactionTests, BadTxnsTxouttotalToolargeOutputs) {
TEST(ChecktransactionTests, ValueBalanceNonZero) { TEST(ChecktransactionTests, ValueBalanceNonZero) {
CMutableTransaction mtx = GetValidTransaction(); CMutableTransaction mtx = GetValidTransaction();
mtx.valueBalance = 10; mtx.valueBalanceSapling = 10;
CTransaction tx(mtx); CTransaction tx(mtx);
@ -336,7 +336,7 @@ TEST(ChecktransactionTests, ValueBalanceNonZero) {
TEST(ChecktransactionTests, PositiveValueBalanceTooLarge) { TEST(ChecktransactionTests, PositiveValueBalanceTooLarge) {
CMutableTransaction mtx = GetValidTransaction(); CMutableTransaction mtx = GetValidTransaction();
mtx.vShieldedSpend.resize(1); mtx.vShieldedSpend.resize(1);
mtx.valueBalance = MAX_MONEY + 1; mtx.valueBalanceSapling = MAX_MONEY + 1;
CTransaction tx(mtx); CTransaction tx(mtx);
@ -348,7 +348,7 @@ TEST(ChecktransactionTests, PositiveValueBalanceTooLarge) {
TEST(ChecktransactionTests, NegativeValueBalanceTooLarge) { TEST(ChecktransactionTests, NegativeValueBalanceTooLarge) {
CMutableTransaction mtx = GetValidTransaction(); CMutableTransaction mtx = GetValidTransaction();
mtx.vShieldedSpend.resize(1); mtx.vShieldedSpend.resize(1);
mtx.valueBalance = -(MAX_MONEY + 1); mtx.valueBalanceSapling = -(MAX_MONEY + 1);
CTransaction tx(mtx); CTransaction tx(mtx);
@ -361,7 +361,7 @@ TEST(ChecktransactionTests, ValueBalanceOverflowsTotal) {
CMutableTransaction mtx = GetValidTransaction(); CMutableTransaction mtx = GetValidTransaction();
mtx.vShieldedSpend.resize(1); mtx.vShieldedSpend.resize(1);
mtx.vout[0].nValue = 1; mtx.vout[0].nValue = 1;
mtx.valueBalance = -MAX_MONEY; mtx.valueBalanceSapling = -MAX_MONEY;
CTransaction tx(mtx); CTransaction tx(mtx);
@ -859,7 +859,7 @@ TEST(ChecktransactionTests, SaplingSproutInputSumsTooLarge) {
EXPECT_TRUE(CheckTransactionWithoutProofVerification(tx, state)); EXPECT_TRUE(CheckTransactionWithoutProofVerification(tx, state));
} }
mtx.valueBalance = (MAX_MONEY / 2) + 10; mtx.valueBalanceSapling = (MAX_MONEY / 2) + 10;
{ {
UNSAFE_CTransaction tx(mtx); UNSAFE_CTransaction tx(mtx);
@ -1221,7 +1221,7 @@ TEST(ChecktransactionTests, HeartwoodAcceptsShieldedCoinbase) {
RegtestDeactivateHeartwood(); RegtestDeactivateHeartwood();
} }
// Check that the consensus rules relevant to valueBalance, vShieldedOutput, and // Check that the consensus rules relevant to valueBalanceSapling, vShieldedOutput, and
// bindingSig from https://zips.z.cash/protocol/protocol.pdf#txnencoding are // bindingSig from https://zips.z.cash/protocol/protocol.pdf#txnencoding are
// applied to coinbase transactions. // applied to coinbase transactions.
TEST(ChecktransactionTests, HeartwoodEnforcesSaplingRulesOnShieldedCoinbase) { TEST(ChecktransactionTests, HeartwoodEnforcesSaplingRulesOnShieldedCoinbase) {
@ -1242,10 +1242,10 @@ TEST(ChecktransactionTests, HeartwoodEnforcesSaplingRulesOnShieldedCoinbase) {
mtx.vin[0].prevout.SetNull(); mtx.vin[0].prevout.SetNull();
mtx.vin[0].scriptSig << 123; mtx.vin[0].scriptSig << 123;
mtx.vJoinSplit.resize(0); mtx.vJoinSplit.resize(0);
mtx.valueBalance = -1000; mtx.valueBalanceSapling = -1000;
// Coinbase transaction should fail non-contextual checks with no shielded // Coinbase transaction should fail non-contextual checks with no shielded
// outputs and non-zero valueBalance. // outputs and non-zero valueBalanceSapling.
{ {
CTransaction tx(mtx); CTransaction tx(mtx);
EXPECT_TRUE(tx.IsCoinBase()); EXPECT_TRUE(tx.IsCoinBase());
@ -1261,10 +1261,10 @@ TEST(ChecktransactionTests, HeartwoodEnforcesSaplingRulesOnShieldedCoinbase) {
librustzcash_sapling_proving_ctx_free(ctx); librustzcash_sapling_proving_ctx_free(ctx);
mtx.vShieldedOutput.push_back(odesc); mtx.vShieldedOutput.push_back(odesc);
// Coinbase transaction should fail non-contextual checks with valueBalance // Coinbase transaction should fail non-contextual checks with valueBalanceSapling
// out of range. // out of range.
{ {
mtx.valueBalance = MAX_MONEY + 1; mtx.valueBalanceSapling = MAX_MONEY + 1;
EXPECT_THROW((CTransaction(mtx)), std::ios_base::failure); EXPECT_THROW((CTransaction(mtx)), std::ios_base::failure);
UNSAFE_CTransaction tx(mtx); UNSAFE_CTransaction tx(mtx);
EXPECT_TRUE(tx.IsCoinBase()); EXPECT_TRUE(tx.IsCoinBase());
@ -1274,7 +1274,7 @@ TEST(ChecktransactionTests, HeartwoodEnforcesSaplingRulesOnShieldedCoinbase) {
EXPECT_FALSE(CheckTransactionWithoutProofVerification(tx, state)); EXPECT_FALSE(CheckTransactionWithoutProofVerification(tx, state));
} }
{ {
mtx.valueBalance = -MAX_MONEY - 1; mtx.valueBalanceSapling = -MAX_MONEY - 1;
EXPECT_THROW((CTransaction(mtx)), std::ios_base::failure); EXPECT_THROW((CTransaction(mtx)), std::ios_base::failure);
UNSAFE_CTransaction tx(mtx); UNSAFE_CTransaction tx(mtx);
EXPECT_TRUE(tx.IsCoinBase()); EXPECT_TRUE(tx.IsCoinBase());
@ -1284,7 +1284,7 @@ TEST(ChecktransactionTests, HeartwoodEnforcesSaplingRulesOnShieldedCoinbase) {
EXPECT_FALSE(CheckTransactionWithoutProofVerification(tx, state)); EXPECT_FALSE(CheckTransactionWithoutProofVerification(tx, state));
} }
mtx.valueBalance = -1000; mtx.valueBalanceSapling = -1000;
CTransaction tx(mtx); CTransaction tx(mtx);
EXPECT_TRUE(tx.IsCoinBase()); EXPECT_TRUE(tx.IsCoinBase());

View File

@ -102,7 +102,7 @@ TEST(TransactionBuilder, TransparentToSapling)
EXPECT_EQ(tx.vJoinSplit.size(), 0); EXPECT_EQ(tx.vJoinSplit.size(), 0);
EXPECT_EQ(tx.vShieldedSpend.size(), 0); EXPECT_EQ(tx.vShieldedSpend.size(), 0);
EXPECT_EQ(tx.vShieldedOutput.size(), 1); EXPECT_EQ(tx.vShieldedOutput.size(), 1);
EXPECT_EQ(tx.valueBalance, -40000); EXPECT_EQ(tx.valueBalanceSapling, -40000);
CValidationState state; CValidationState state;
EXPECT_TRUE(ContextualCheckTransaction(tx, state, Params(), 2, true)); EXPECT_TRUE(ContextualCheckTransaction(tx, state, Params(), 2, true));
@ -139,7 +139,7 @@ TEST(TransactionBuilder, SaplingToSapling) {
EXPECT_EQ(tx.vJoinSplit.size(), 0); EXPECT_EQ(tx.vJoinSplit.size(), 0);
EXPECT_EQ(tx.vShieldedSpend.size(), 1); EXPECT_EQ(tx.vShieldedSpend.size(), 1);
EXPECT_EQ(tx.vShieldedOutput.size(), 2); EXPECT_EQ(tx.vShieldedOutput.size(), 2);
EXPECT_EQ(tx.valueBalance, 10000); EXPECT_EQ(tx.valueBalanceSapling, 10000);
CValidationState state; CValidationState state;
EXPECT_TRUE(ContextualCheckTransaction(tx, state, Params(), 3, true)); EXPECT_TRUE(ContextualCheckTransaction(tx, state, Params(), 3, true));
@ -177,7 +177,7 @@ TEST(TransactionBuilder, SaplingToSprout) {
EXPECT_EQ(tx.vJoinSplit[0].vpub_new, 0); EXPECT_EQ(tx.vJoinSplit[0].vpub_new, 0);
EXPECT_EQ(tx.vShieldedSpend.size(), 1); EXPECT_EQ(tx.vShieldedSpend.size(), 1);
EXPECT_EQ(tx.vShieldedOutput.size(), 1); EXPECT_EQ(tx.vShieldedOutput.size(), 1);
EXPECT_EQ(tx.valueBalance, 35000); EXPECT_EQ(tx.valueBalanceSapling, 35000);
CValidationState state; CValidationState state;
EXPECT_TRUE(ContextualCheckTransaction(tx, state, Params(), 3, true)); EXPECT_TRUE(ContextualCheckTransaction(tx, state, Params(), 3, true));
@ -238,7 +238,7 @@ TEST(TransactionBuilder, SproutToSproutAndSapling) {
EXPECT_EQ(tx.vJoinSplit[2].vpub_new, 10000); EXPECT_EQ(tx.vJoinSplit[2].vpub_new, 10000);
EXPECT_EQ(tx.vShieldedSpend.size(), 0); EXPECT_EQ(tx.vShieldedSpend.size(), 0);
EXPECT_EQ(tx.vShieldedOutput.size(), 1); EXPECT_EQ(tx.vShieldedOutput.size(), 1);
EXPECT_EQ(tx.valueBalance, -5000); EXPECT_EQ(tx.valueBalanceSapling, -5000);
CValidationState state; CValidationState state;
EXPECT_TRUE(ContextualCheckTransaction(tx, state, Params(), 4, true)); EXPECT_TRUE(ContextualCheckTransaction(tx, state, Params(), 4, true));
@ -365,7 +365,7 @@ TEST(TransactionBuilder, ChangeOutput)
EXPECT_EQ(tx.vJoinSplit.size(), 0); EXPECT_EQ(tx.vJoinSplit.size(), 0);
EXPECT_EQ(tx.vShieldedSpend.size(), 1); EXPECT_EQ(tx.vShieldedSpend.size(), 1);
EXPECT_EQ(tx.vShieldedOutput.size(), 1); EXPECT_EQ(tx.vShieldedOutput.size(), 1);
EXPECT_EQ(tx.valueBalance, -15000); EXPECT_EQ(tx.valueBalanceSapling, -15000);
} }
// Change to a Sapling address // Change to a Sapling address
@ -380,7 +380,7 @@ TEST(TransactionBuilder, ChangeOutput)
EXPECT_EQ(tx.vJoinSplit.size(), 0); EXPECT_EQ(tx.vJoinSplit.size(), 0);
EXPECT_EQ(tx.vShieldedSpend.size(), 0); EXPECT_EQ(tx.vShieldedSpend.size(), 0);
EXPECT_EQ(tx.vShieldedOutput.size(), 1); EXPECT_EQ(tx.vShieldedOutput.size(), 1);
EXPECT_EQ(tx.valueBalance, -15000); EXPECT_EQ(tx.valueBalanceSapling, -15000);
} }
// Change to a transparent address // Change to a transparent address
@ -395,7 +395,7 @@ TEST(TransactionBuilder, ChangeOutput)
EXPECT_EQ(tx.vJoinSplit.size(), 0); EXPECT_EQ(tx.vJoinSplit.size(), 0);
EXPECT_EQ(tx.vShieldedSpend.size(), 0); EXPECT_EQ(tx.vShieldedSpend.size(), 0);
EXPECT_EQ(tx.vShieldedOutput.size(), 0); EXPECT_EQ(tx.vShieldedOutput.size(), 0);
EXPECT_EQ(tx.valueBalance, 0); EXPECT_EQ(tx.valueBalanceSapling, 0);
EXPECT_EQ(tx.vout[0].nValue, 15000); EXPECT_EQ(tx.vout[0].nValue, 15000);
} }
@ -427,7 +427,7 @@ TEST(TransactionBuilder, SetFee)
EXPECT_EQ(tx.vJoinSplit.size(), 0); EXPECT_EQ(tx.vJoinSplit.size(), 0);
EXPECT_EQ(tx.vShieldedSpend.size(), 1); EXPECT_EQ(tx.vShieldedSpend.size(), 1);
EXPECT_EQ(tx.vShieldedOutput.size(), 2); EXPECT_EQ(tx.vShieldedOutput.size(), 2);
EXPECT_EQ(tx.valueBalance, 10000); EXPECT_EQ(tx.valueBalanceSapling, 10000);
} }
// Configured fee // Configured fee
@ -443,7 +443,7 @@ TEST(TransactionBuilder, SetFee)
EXPECT_EQ(tx.vJoinSplit.size(), 0); EXPECT_EQ(tx.vJoinSplit.size(), 0);
EXPECT_EQ(tx.vShieldedSpend.size(), 1); EXPECT_EQ(tx.vShieldedSpend.size(), 1);
EXPECT_EQ(tx.vShieldedOutput.size(), 2); EXPECT_EQ(tx.vShieldedOutput.size(), 2);
EXPECT_EQ(tx.valueBalance, 20000); EXPECT_EQ(tx.valueBalanceSapling, 20000);
} }
// Revert to default // Revert to default

View File

@ -1290,7 +1290,7 @@ bool ContextualCheckTransaction(
if (!librustzcash_sapling_final_check( if (!librustzcash_sapling_final_check(
ctx, ctx,
tx.valueBalance, tx.valueBalanceSapling,
tx.bindingSig.begin(), tx.bindingSig.begin(),
dataToBeSigned.begin() dataToBeSigned.begin()
)) ))
@ -1454,21 +1454,21 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
REJECT_INVALID, "bad-txns-txouttotal-toolarge"); REJECT_INVALID, "bad-txns-txouttotal-toolarge");
} }
// Check for non-zero valueBalance when there are no Sapling inputs or outputs // Check for non-zero valueBalanceSapling when there are no Sapling inputs or outputs
if (tx.vShieldedSpend.empty() && tx.vShieldedOutput.empty() && tx.valueBalance != 0) { // XXX value balance ffi if (tx.vShieldedSpend.empty() && tx.vShieldedOutput.empty() && tx.valueBalanceSapling != 0) { // XXX value balance ffi
return state.DoS(100, error("CheckTransaction(): tx.valueBalance has no sources or sinks"), return state.DoS(100, error("CheckTransaction(): tx.valueBalanceSapling has no sources or sinks"),
REJECT_INVALID, "bad-txns-valuebalance-nonzero"); REJECT_INVALID, "bad-txns-valuebalance-nonzero");
} }
// Check for overflow valueBalance XXX rename to sapling value balance, add orchard value balance checks // Check for overflow valueBalanceSapling XXX rename to sapling value balance, add orchard value balance checks
if (tx.valueBalance > MAX_MONEY || tx.valueBalance < -MAX_MONEY) { // XXX need value balance ffi if (tx.valueBalanceSapling > MAX_MONEY || tx.valueBalanceSapling < -MAX_MONEY) { // XXX need value balance ffi
return state.DoS(100, error("CheckTransaction(): abs(tx.valueBalance) too large"), return state.DoS(100, error("CheckTransaction(): abs(tx.valueBalanceSapling) too large"),
REJECT_INVALID, "bad-txns-valuebalance-toolarge"); REJECT_INVALID, "bad-txns-valuebalance-toolarge");
} }
if (tx.valueBalance <= 0) { if (tx.valueBalanceSapling <= 0) {
// NB: negative valueBalance "takes" money from the transparent value pool just as outputs do // NB: negative valueBalanceSapling "takes" money from the transparent value pool just as outputs do
nValueOut += -tx.valueBalance; nValueOut += -tx.valueBalanceSapling;
if (!MoneyRange(nValueOut)) { if (!MoneyRange(nValueOut)) {
return state.DoS(100, error("CheckTransaction(): txout total out of range"), return state.DoS(100, error("CheckTransaction(): txout total out of range"),
@ -1528,9 +1528,9 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
} }
// Also check for Sapling // Also check for Sapling
if (tx.valueBalance >= 0) { if (tx.valueBalanceSapling >= 0) {
// NB: positive valueBalance "adds" money to the transparent value pool, just as inputs do // NB: positive valueBalanceSapling "adds" money to the transparent value pool, just as inputs do
nValueIn += tx.valueBalance; nValueIn += tx.valueBalanceSapling;
if (!MoneyRange(nValueIn)) { if (!MoneyRange(nValueIn)) {
return state.DoS(100, error("CheckTransaction(): txin total out of range"), return state.DoS(100, error("CheckTransaction(): txin total out of range"),
@ -4252,13 +4252,13 @@ bool ReceivedBlockTransactions(
CAmount saplingValue = 0; CAmount saplingValue = 0;
CAmount orchardValue = 0; CAmount orchardValue = 0;
for (auto tx : block.vtx) { for (auto tx : block.vtx) {
// Negative valueBalance "takes" money from the transparent value pool // Negative valueBalanceSapling "takes" money from the transparent value pool
// and adds it to the Sapling value pool. Positive valueBalance "gives" // and adds it to the Sapling value pool. Positive valueBalanceSapling "gives"
// money to the transparent value pool, removing from the Sapling value // money to the transparent value pool, removing from the Sapling value
// pool. So we invert the sign here. // pool. So we invert the sign here.
saplingValue += -tx.valueBalance; saplingValue += -tx.valueBalanceSapling;
// Orchard valueBalance behaves the same way as Sapling valueBalance. // valueBalanceOrchard behaves the same way as valueBalanceSapling.
orchardValue += -tx.GetOrchardBundle().GetValueBalance(); orchardValue += -tx.GetOrchardBundle().GetValueBalance();
for (auto js : tx.vJoinSplit) { for (auto js : tx.vJoinSplit) {

View File

@ -126,13 +126,13 @@ class AddFundingStreamValueToTx
{ {
private: private:
CMutableTransaction &mtx; CMutableTransaction &mtx;
void* ctx; void* ctx;
const CAmount fundingStreamValue; const CAmount fundingStreamValue;
const libzcash::Zip212Enabled zip212Enabled; const libzcash::Zip212Enabled zip212Enabled;
public: public:
AddFundingStreamValueToTx( AddFundingStreamValueToTx(
CMutableTransaction &mtx, CMutableTransaction &mtx,
void* ctx, void* ctx,
const CAmount fundingStreamValue, const CAmount fundingStreamValue,
const libzcash::Zip212Enabled zip212Enabled): mtx(mtx), ctx(ctx), fundingStreamValue(fundingStreamValue), zip212Enabled(zip212Enabled) {} const libzcash::Zip212Enabled zip212Enabled): mtx(mtx), ctx(ctx), fundingStreamValue(fundingStreamValue), zip212Enabled(zip212Enabled) {}
@ -144,7 +144,7 @@ public:
auto odesc = output.Build(ctx); auto odesc = output.Build(ctx);
if (odesc) { if (odesc) {
mtx.vShieldedOutput.push_back(odesc.value()); mtx.vShieldedOutput.push_back(odesc.value());
mtx.valueBalance -= fundingStreamValue; mtx.valueBalanceSapling -= fundingStreamValue;
return true; return true;
} else { } else {
return false; return false;
@ -231,7 +231,7 @@ public:
bool success = librustzcash_sapling_binding_sig( bool success = librustzcash_sapling_binding_sig(
ctx, ctx,
mtx.valueBalance, mtx.valueBalanceSapling,
dataToBeSigned.begin(), dataToBeSigned.begin(),
mtx.bindingSig.data()); mtx.bindingSig.data());
@ -248,7 +248,7 @@ public:
auto ctx = librustzcash_sapling_proving_ctx_init(); auto ctx = librustzcash_sapling_proving_ctx_init();
auto miner_reward = SetFoundersRewardAndGetMinerValue(ctx); auto miner_reward = SetFoundersRewardAndGetMinerValue(ctx);
mtx.valueBalance -= miner_reward; mtx.valueBalanceSapling -= miner_reward;
uint256 ovk; uint256 ovk;
@ -543,7 +543,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const MinerAddre
CAmount saplingValueDummy = saplingValue; CAmount saplingValueDummy = saplingValue;
CAmount orchardValueDummy = orchardValue; CAmount orchardValueDummy = orchardValue;
saplingValueDummy += -tx.valueBalance; saplingValueDummy += -tx.valueBalanceSapling;
orchardValueDummy += -tx.GetOrchardBundle().GetValueBalance(); orchardValueDummy += -tx.GetOrchardBundle().GetValueBalance();
for (auto js : tx.vJoinSplit) { for (auto js : tx.vJoinSplit) {

View File

@ -14,9 +14,9 @@
SaplingBundle::SaplingBundle( SaplingBundle::SaplingBundle(
const std::vector<SpendDescription>& vShieldedSpend, const std::vector<SpendDescription>& vShieldedSpend,
const std::vector<OutputDescription>& vShieldedOutput, const std::vector<OutputDescription>& vShieldedOutput,
const CAmount& valueBalance, const CAmount& valueBalanceSapling,
const binding_sig_t& bindingSig) const binding_sig_t& bindingSig)
: valueBalanceSapling(valueBalance), bindingSigSapling(bindingSig) : valueBalanceSapling(valueBalanceSapling), bindingSigSapling(bindingSig)
{ {
for (auto &spend : vShieldedSpend) { for (auto &spend : vShieldedSpend) {
vSpendsSapling.emplace_back(spend.cv, spend.nullifier, spend.rk); vSpendsSapling.emplace_back(spend.cv, spend.nullifier, spend.rk);
@ -127,11 +127,11 @@ std::string CTxOut::ToString() const
} }
CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::SPROUT_MIN_CURRENT_VERSION), fOverwintered(false), nVersionGroupId(0), nExpiryHeight(0), nLockTime(0), valueBalance(0) {} CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::SPROUT_MIN_CURRENT_VERSION), fOverwintered(false), nVersionGroupId(0), nExpiryHeight(0), nLockTime(0), valueBalanceSapling(0) {}
CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), nExpiryHeight(tx.nExpiryHeight), CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), nExpiryHeight(tx.nExpiryHeight),
nConsensusBranchId(tx.GetConsensusBranchId()), nConsensusBranchId(tx.GetConsensusBranchId()),
vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime),
valueBalance(tx.valueBalance), vShieldedSpend(tx.vShieldedSpend), vShieldedOutput(tx.vShieldedOutput), valueBalanceSapling(tx.valueBalanceSapling), vShieldedSpend(tx.vShieldedSpend), vShieldedOutput(tx.vShieldedOutput),
orchardBundle(tx.GetOrchardBundle()), orchardBundle(tx.GetOrchardBundle()),
vJoinSplit(tx.vJoinSplit), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig), vJoinSplit(tx.vJoinSplit), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig),
bindingSig(tx.bindingSig) bindingSig(tx.bindingSig)
@ -188,7 +188,7 @@ CTransaction::CTransaction() : nVersion(CTransaction::SPROUT_MIN_CURRENT_VERSION
fOverwintered(false), nVersionGroupId(0), nExpiryHeight(0), fOverwintered(false), nVersionGroupId(0), nExpiryHeight(0),
nConsensusBranchId(std::nullopt), nConsensusBranchId(std::nullopt),
vin(), vout(), nLockTime(0), vin(), vout(), nLockTime(0),
valueBalance(0), vShieldedSpend(), vShieldedOutput(), valueBalanceSapling(0), vShieldedSpend(), vShieldedOutput(),
orchardBundle(), orchardBundle(),
vJoinSplit(), joinSplitPubKey(), joinSplitSig(), vJoinSplit(), joinSplitPubKey(), joinSplitSig(),
bindingSig() { } bindingSig() { }
@ -196,7 +196,7 @@ CTransaction::CTransaction() : nVersion(CTransaction::SPROUT_MIN_CURRENT_VERSION
CTransaction::CTransaction(const CMutableTransaction &tx) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), nExpiryHeight(tx.nExpiryHeight), CTransaction::CTransaction(const CMutableTransaction &tx) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), nExpiryHeight(tx.nExpiryHeight),
nConsensusBranchId(tx.nConsensusBranchId), nConsensusBranchId(tx.nConsensusBranchId),
vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime),
valueBalance(tx.valueBalance), vShieldedSpend(tx.vShieldedSpend), vShieldedOutput(tx.vShieldedOutput), valueBalanceSapling(tx.valueBalanceSapling), vShieldedSpend(tx.vShieldedSpend), vShieldedOutput(tx.vShieldedOutput),
orchardBundle(tx.orchardBundle), orchardBundle(tx.orchardBundle),
vJoinSplit(tx.vJoinSplit), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig), vJoinSplit(tx.vJoinSplit), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig),
bindingSig(tx.bindingSig) bindingSig(tx.bindingSig)
@ -211,7 +211,7 @@ CTransaction::CTransaction(
bool evilDeveloperFlag) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), nExpiryHeight(tx.nExpiryHeight), bool evilDeveloperFlag) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), nExpiryHeight(tx.nExpiryHeight),
nConsensusBranchId(tx.nConsensusBranchId), nConsensusBranchId(tx.nConsensusBranchId),
vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime),
valueBalance(tx.valueBalance), vShieldedSpend(tx.vShieldedSpend), vShieldedOutput(tx.vShieldedOutput), valueBalanceSapling(tx.valueBalanceSapling), vShieldedSpend(tx.vShieldedSpend), vShieldedOutput(tx.vShieldedOutput),
orchardBundle(tx.orchardBundle), orchardBundle(tx.orchardBundle),
vJoinSplit(tx.vJoinSplit), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig), vJoinSplit(tx.vJoinSplit), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig),
bindingSig(tx.bindingSig) bindingSig(tx.bindingSig)
@ -224,7 +224,7 @@ CTransaction::CTransaction(CMutableTransaction &&tx) : nVersion(tx.nVersion),
nConsensusBranchId(tx.nConsensusBranchId), nConsensusBranchId(tx.nConsensusBranchId),
vin(std::move(tx.vin)), vout(std::move(tx.vout)), vin(std::move(tx.vin)), vout(std::move(tx.vout)),
nLockTime(tx.nLockTime), nExpiryHeight(tx.nExpiryHeight), nLockTime(tx.nLockTime), nExpiryHeight(tx.nExpiryHeight),
valueBalance(tx.valueBalance), valueBalanceSapling(tx.valueBalanceSapling),
vShieldedSpend(std::move(tx.vShieldedSpend)), vShieldedOutput(std::move(tx.vShieldedOutput)), vShieldedSpend(std::move(tx.vShieldedSpend)), vShieldedOutput(std::move(tx.vShieldedOutput)),
orchardBundle(std::move(tx.orchardBundle)), orchardBundle(std::move(tx.orchardBundle)),
vJoinSplit(std::move(tx.vJoinSplit)), vJoinSplit(std::move(tx.vJoinSplit)),
@ -243,7 +243,7 @@ CTransaction& CTransaction::operator=(const CTransaction &tx) {
*const_cast<std::vector<CTxOut>*>(&vout) = tx.vout; *const_cast<std::vector<CTxOut>*>(&vout) = tx.vout;
*const_cast<unsigned int*>(&nLockTime) = tx.nLockTime; *const_cast<unsigned int*>(&nLockTime) = tx.nLockTime;
*const_cast<uint32_t*>(&nExpiryHeight) = tx.nExpiryHeight; *const_cast<uint32_t*>(&nExpiryHeight) = tx.nExpiryHeight;
*const_cast<CAmount*>(&valueBalance) = tx.valueBalance; *const_cast<CAmount*>(&valueBalanceSapling) = tx.valueBalanceSapling;
*const_cast<std::vector<SpendDescription>*>(&vShieldedSpend) = tx.vShieldedSpend; *const_cast<std::vector<SpendDescription>*>(&vShieldedSpend) = tx.vShieldedSpend;
*const_cast<std::vector<OutputDescription>*>(&vShieldedOutput) = tx.vShieldedOutput; *const_cast<std::vector<OutputDescription>*>(&vShieldedOutput) = tx.vShieldedOutput;
orchardBundle = tx.orchardBundle; orchardBundle = tx.orchardBundle;
@ -266,11 +266,11 @@ CAmount CTransaction::GetValueOut() const
throw std::runtime_error("CTransaction::GetValueOut(): value out of range"); throw std::runtime_error("CTransaction::GetValueOut(): value out of range");
} }
if (valueBalance <= 0) { if (valueBalanceSapling <= 0) {
// NB: negative valueBalance "takes" money from the transparent value pool just as outputs do // NB: negative valueBalanceSapling "takes" money from the transparent value pool just as outputs do
nValueOut += -valueBalance; nValueOut += -valueBalanceSapling;
if (!MoneyRange(-valueBalance) || !MoneyRange(nValueOut)) { if (!MoneyRange(-valueBalanceSapling) || !MoneyRange(nValueOut)) {
throw std::runtime_error("CTransaction::GetValueOut(): value out of range"); throw std::runtime_error("CTransaction::GetValueOut(): value out of range");
} }
} }
@ -290,11 +290,11 @@ CAmount CTransaction::GetShieldedValueIn() const
{ {
CAmount nValue = 0; CAmount nValue = 0;
if (valueBalance >= 0) { if (valueBalanceSapling >= 0) {
// NB: positive valueBalance "gives" money to the transparent value pool just as inputs do // NB: positive valueBalanceSapling "gives" money to the transparent value pool just as inputs do
nValue += valueBalance; nValue += valueBalanceSapling;
if (!MoneyRange(valueBalance) || !MoneyRange(nValue)) { if (!MoneyRange(valueBalanceSapling) || !MoneyRange(nValue)) {
throw std::runtime_error("CTransaction::GetShieldedValueIn(): value out of range"); throw std::runtime_error("CTransaction::GetShieldedValueIn(): value out of range");
} }
} }
@ -348,7 +348,7 @@ std::string CTransaction::ToString() const
vout.size(), vout.size(),
nLockTime); nLockTime);
} else if (nVersion >= SAPLING_MIN_TX_VERSION) { } else if (nVersion >= SAPLING_MIN_TX_VERSION) {
str += strprintf("CTransaction(hash=%s, ver=%d, fOverwintered=%d, nVersionGroupId=%08x, vin.size=%u, vout.size=%u, nLockTime=%u, nExpiryHeight=%u, valueBalance=%u, vShieldedSpend.size=%u, vShieldedOutput.size=%u)\n", str += strprintf("CTransaction(hash=%s, ver=%d, fOverwintered=%d, nVersionGroupId=%08x, vin.size=%u, vout.size=%u, nLockTime=%u, nExpiryHeight=%u, valueBalanceSapling=%u, vShieldedSpend.size=%u, vShieldedOutput.size=%u)\n",
GetHash().ToString().substr(0,10), GetHash().ToString().substr(0,10),
nVersion, nVersion,
fOverwintered, fOverwintered,
@ -357,7 +357,7 @@ std::string CTransaction::ToString() const
vout.size(), vout.size(),
nLockTime, nLockTime,
nExpiryHeight, nExpiryHeight,
valueBalance, valueBalanceSapling,
vShieldedSpend.size(), vShieldedSpend.size(),
vShieldedOutput.size()); vShieldedOutput.size());
} else if (nVersion >= 3) { } else if (nVersion >= 3) {

View File

@ -715,7 +715,7 @@ public:
const std::vector<CTxOut> vout; const std::vector<CTxOut> vout;
const uint32_t nLockTime; const uint32_t nLockTime;
const uint32_t nExpiryHeight; const uint32_t nExpiryHeight;
const CAmount valueBalance; const CAmount valueBalanceSapling;
const std::vector<SpendDescription> vShieldedSpend; const std::vector<SpendDescription> vShieldedSpend;
const std::vector<OutputDescription> vShieldedOutput; const std::vector<OutputDescription> vShieldedOutput;
const std::vector<JSDescription> vJoinSplit; const std::vector<JSDescription> vJoinSplit;
@ -797,13 +797,13 @@ public:
saplingBundle.GetV4ShieldedSpend(); saplingBundle.GetV4ShieldedSpend();
*const_cast<std::vector<OutputDescription>*>(&vShieldedOutput) = *const_cast<std::vector<OutputDescription>*>(&vShieldedOutput) =
saplingBundle.GetV4ShieldedOutput(); saplingBundle.GetV4ShieldedOutput();
*const_cast<CAmount*>(&valueBalance) = saplingBundle.valueBalanceSapling; *const_cast<CAmount*>(&valueBalanceSapling) = saplingBundle.valueBalanceSapling;
*const_cast<binding_sig_t*>(&bindingSig) = saplingBundle.bindingSigSapling; *const_cast<binding_sig_t*>(&bindingSig) = saplingBundle.bindingSigSapling;
} else { } else {
SaplingBundle saplingBundle( SaplingBundle saplingBundle(
vShieldedSpend, vShieldedSpend,
vShieldedOutput, vShieldedOutput,
valueBalance, valueBalanceSapling,
bindingSig); bindingSig);
READWRITE(saplingBundle); READWRITE(saplingBundle);
} }
@ -819,7 +819,7 @@ public:
READWRITE(*const_cast<uint32_t*>(&nExpiryHeight)); READWRITE(*const_cast<uint32_t*>(&nExpiryHeight));
} }
if (isSaplingV4 || isFuture) { if (isSaplingV4 || isFuture) {
READWRITE(*const_cast<CAmount*>(&valueBalance)); READWRITE(*const_cast<CAmount*>(&valueBalanceSapling));
READWRITE(*const_cast<std::vector<SpendDescription>*>(&vShieldedSpend)); READWRITE(*const_cast<std::vector<SpendDescription>*>(&vShieldedSpend));
READWRITE(*const_cast<std::vector<OutputDescription>*>(&vShieldedOutput)); READWRITE(*const_cast<std::vector<OutputDescription>*>(&vShieldedOutput));
} }
@ -885,16 +885,16 @@ public:
* it is (e.g. if vpub_new is non-zero the joinSplit is "giving value" to * it is (e.g. if vpub_new is non-zero the joinSplit is "giving value" to
* the outputs in the transaction). Similarly, we can think of the Sapling * the outputs in the transaction). Similarly, we can think of the Sapling
* shielded part of the transaction as an input or output according to * shielded part of the transaction as an input or output according to
* whether valueBalance - the sum of shielded input values minus the sum of * whether valueBalanceSapling - the sum of shielded input values minus the sum of
* shielded output values - is positive or negative. * shielded output values - is positive or negative.
*/ */
// Return sum of txouts, (negative valueBalance or zero) and JoinSplit vpub_old. // Return sum of txouts, (negative valueBalanceSapling or zero) and JoinSplit vpub_old.
CAmount GetValueOut() const; CAmount GetValueOut() const;
// GetValueIn() is a method on CCoinsViewCache, because // GetValueIn() is a method on CCoinsViewCache, because
// inputs must be known to compute value in. // inputs must be known to compute value in.
// Return sum of (positive valueBalance or zero) and JoinSplit vpub_new // Return sum of (positive valueBalanceSapling or zero) and JoinSplit vpub_new
CAmount GetShieldedValueIn() const; CAmount GetShieldedValueIn() const;
// Compute priority, given priority of inputs and (optionally) tx size // Compute priority, given priority of inputs and (optionally) tx size
@ -934,7 +934,7 @@ struct CMutableTransaction
std::vector<CTxOut> vout; std::vector<CTxOut> vout;
uint32_t nLockTime; uint32_t nLockTime;
uint32_t nExpiryHeight; uint32_t nExpiryHeight;
CAmount valueBalance; CAmount valueBalanceSapling;
std::vector<SpendDescription> vShieldedSpend; std::vector<SpendDescription> vShieldedSpend;
std::vector<OutputDescription> vShieldedOutput; std::vector<OutputDescription> vShieldedOutput;
OrchardBundle orchardBundle; OrchardBundle orchardBundle;
@ -1005,13 +1005,13 @@ struct CMutableTransaction
READWRITE(saplingBundle); READWRITE(saplingBundle);
vShieldedSpend = saplingBundle.GetV4ShieldedSpend(); vShieldedSpend = saplingBundle.GetV4ShieldedSpend();
vShieldedOutput = saplingBundle.GetV4ShieldedOutput(); vShieldedOutput = saplingBundle.GetV4ShieldedOutput();
valueBalance = saplingBundle.valueBalanceSapling; valueBalanceSapling = saplingBundle.valueBalanceSapling;
bindingSig = saplingBundle.bindingSigSapling; bindingSig = saplingBundle.bindingSigSapling;
} else { } else {
SaplingBundle saplingBundle( SaplingBundle saplingBundle(
vShieldedSpend, vShieldedSpend,
vShieldedOutput, vShieldedOutput,
valueBalance, valueBalanceSapling,
bindingSig); bindingSig);
READWRITE(saplingBundle); READWRITE(saplingBundle);
} }
@ -1027,7 +1027,7 @@ struct CMutableTransaction
READWRITE(nExpiryHeight); READWRITE(nExpiryHeight);
} }
if (isSaplingV4 || isFuture) { if (isSaplingV4 || isFuture) {
READWRITE(valueBalance); READWRITE(valueBalanceSapling);
READWRITE(vShieldedSpend); READWRITE(vShieldedSpend);
READWRITE(vShieldedOutput); READWRITE(vShieldedOutput);
} }

View File

@ -227,8 +227,8 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
entry.pushKV("vjoinsplit", vjoinsplit); entry.pushKV("vjoinsplit", vjoinsplit);
if (tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION) { if (tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION) {
entry.pushKV("valueBalance", ValueFromAmount(tx.valueBalance)); entry.pushKV("valueBalance", ValueFromAmount(tx.valueBalanceSapling));
entry.pushKV("valueBalanceZat", tx.valueBalance); entry.pushKV("valueBalanceZat", tx.valueBalanceSapling);
UniValue vspenddesc = TxShieldedSpendsToJSON(tx); UniValue vspenddesc = TxShieldedSpendsToJSON(tx);
entry.pushKV("vShieldedSpend", vspenddesc); entry.pushKV("vShieldedSpend", vspenddesc);
UniValue voutputdesc = TxShieldedOutputsToJSON(tx); UniValue voutputdesc = TxShieldedOutputsToJSON(tx);
@ -594,7 +594,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, locktime out of range"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, locktime out of range");
rawTx.nLockTime = nLockTime; rawTx.nLockTime = nLockTime;
} }
if (params.size() > 3 && !params[3].isNull()) { if (params.size() > 3 && !params[3].isNull()) {
if (Params().GetConsensus().NetworkUpgradeActive(nextBlockHeight, Consensus::UPGRADE_OVERWINTER)) { if (Params().GetConsensus().NetworkUpgradeActive(nextBlockHeight, Consensus::UPGRADE_OVERWINTER)) {
int64_t nExpiryHeight = params[3].get_int64(); int64_t nExpiryHeight = params[3].get_int64();
@ -1017,7 +1017,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
} }
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE); bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
// Use the approximate release height if it is greater so offline nodes // Use the approximate release height if it is greater so offline nodes
// have a better estimation of the current height and will be more likely to // have a better estimation of the current height and will be more likely to
// determine the correct consensus branch ID. Regtest mode ignores release height. // determine the correct consensus branch ID. Regtest mode ignores release height.
int chainHeight = chainActive.Height() + 1; int chainHeight = chainActive.Height() + 1;
@ -1032,8 +1032,8 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
if (!IsConsensusBranchId(consensusBranchId)) { if (!IsConsensusBranchId(consensusBranchId)) {
throw runtime_error(params[4].get_str() + " is not a valid consensus branch id"); throw runtime_error(params[4].get_str() + " is not a valid consensus branch id");
} }
} }
// Script verification errors // Script verification errors
UniValue vErrors(UniValue::VARR); UniValue vErrors(UniValue::VARR);

View File

@ -94,7 +94,7 @@ bool static IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) {
* Where R and S are not negative (their first byte has its highest bit not set), and not * Where R and S are not negative (their first byte has its highest bit not set), and not
* excessively padded (do not start with a 0 byte, unless an otherwise negative number follows, * excessively padded (do not start with a 0 byte, unless an otherwise negative number follows,
* in which case a single 0 byte is necessary and even required). * in which case a single 0 byte is necessary and even required).
* *
* See https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623 * See https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623
* *
* This function is consensus-critical since BIP66. * This function is consensus-critical since BIP66.
@ -134,7 +134,7 @@ bool static IsValidSignatureEncoding(const std::vector<unsigned char> &sig) {
// Verify that the length of the signature matches the sum of the length // Verify that the length of the signature matches the sum of the length
// of the elements. // of the elements.
if ((size_t)(lenR + lenS + 7) != sig.size()) return false; if ((size_t)(lenR + lenS + 7) != sig.size()) return false;
// Check whether the R element is an integer. // Check whether the R element is an integer.
if (sig[2] != 0x02) return false; if (sig[2] != 0x02) return false;
@ -1288,7 +1288,7 @@ uint256 SignatureHash(
ss << txTo.nExpiryHeight; ss << txTo.nExpiryHeight;
if (sigversion == SIGVERSION_SAPLING) { if (sigversion == SIGVERSION_SAPLING) {
// Sapling value balance // Sapling value balance
ss << txTo.valueBalance; ss << txTo.valueBalanceSapling;
} }
// Sighash type // Sighash type
ss << nHashType; ss << nHashType;

View File

@ -147,7 +147,7 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle, uint32_t co
RandomScript(txout.scriptPubKey); RandomScript(txout.scriptPubKey);
} }
if (tx.nVersionGroupId == SAPLING_VERSION_GROUP_ID) { if (tx.nVersionGroupId == SAPLING_VERSION_GROUP_ID) {
tx.valueBalance = insecure_rand() % 100000000; tx.valueBalanceSapling = insecure_rand() % 100000000;
for (int spend = 0; spend < shielded_spends; spend++) { for (int spend = 0; spend < shielded_spends; spend++) {
SpendDescription sdesc; SpendDescription sdesc;
zcash_test_harness_random_jubjub_point(sdesc.cv.begin()); zcash_test_harness_random_jubjub_point(sdesc.cv.begin());

View File

@ -199,7 +199,7 @@ void TransactionBuilder::AddSaplingSpend(
} }
spends.emplace_back(expsk, note, anchor, witness); spends.emplace_back(expsk, note, anchor, witness);
mtx.valueBalance += note.value(); mtx.valueBalanceSapling += note.value();
} }
void TransactionBuilder::AddSaplingOutput( void TransactionBuilder::AddSaplingOutput(
@ -221,7 +221,7 @@ void TransactionBuilder::AddSaplingOutput(
auto note = libzcash::SaplingNote(to, value, zip_212_enabled); auto note = libzcash::SaplingNote(to, value, zip_212_enabled);
outputs.emplace_back(ovk, note, memo); outputs.emplace_back(ovk, note, memo);
mtx.valueBalance -= value; mtx.valueBalanceSapling -= value;
} }
void TransactionBuilder::AddSproutInput( void TransactionBuilder::AddSproutInput(
@ -307,7 +307,7 @@ TransactionBuilderResult TransactionBuilder::Build()
// //
// Valid change // Valid change
CAmount change = mtx.valueBalance - fee; CAmount change = mtx.valueBalanceSapling - fee;
for (auto jsInput : jsInputs) { for (auto jsInput : jsInputs) {
change += jsInput.note.value(); change += jsInput.note.value();
} }
@ -460,7 +460,7 @@ TransactionBuilderResult TransactionBuilder::Build()
} }
librustzcash_sapling_binding_sig( librustzcash_sapling_binding_sig(
ctx, ctx,
mtx.valueBalance, mtx.valueBalanceSapling,
dataToBeSigned.begin(), dataToBeSigned.begin(),
mtx.bindingSig.data()); mtx.bindingSig.data());

View File

@ -1106,7 +1106,7 @@ TEST(WalletTests, SpentSaplingNoteIsFromMe) {
EXPECT_EQ(tx2.vJoinSplit.size(), 0); EXPECT_EQ(tx2.vJoinSplit.size(), 0);
EXPECT_EQ(tx2.vShieldedSpend.size(), 1); EXPECT_EQ(tx2.vShieldedSpend.size(), 1);
EXPECT_EQ(tx2.vShieldedOutput.size(), 2); EXPECT_EQ(tx2.vShieldedOutput.size(), 2);
EXPECT_EQ(tx2.valueBalance, 10000); EXPECT_EQ(tx2.valueBalanceSapling, 10000);
CWalletTx wtx2 {&wallet, tx2}; CWalletTx wtx2 {&wallet, tx2};
@ -1973,7 +1973,7 @@ TEST(WalletTests, MarkAffectedSaplingTransactionsDirty) {
EXPECT_EQ(tx1.vJoinSplit.size(), 0); EXPECT_EQ(tx1.vJoinSplit.size(), 0);
EXPECT_EQ(tx1.vShieldedSpend.size(), 0); EXPECT_EQ(tx1.vShieldedSpend.size(), 0);
EXPECT_EQ(tx1.vShieldedOutput.size(), 1); EXPECT_EQ(tx1.vShieldedOutput.size(), 1);
EXPECT_EQ(tx1.valueBalance, -40000); EXPECT_EQ(tx1.valueBalanceSapling, -40000);
CWalletTx wtx {&wallet, tx1}; CWalletTx wtx {&wallet, tx1};
@ -2027,7 +2027,7 @@ TEST(WalletTests, MarkAffectedSaplingTransactionsDirty) {
EXPECT_EQ(tx2.vJoinSplit.size(), 0); EXPECT_EQ(tx2.vJoinSplit.size(), 0);
EXPECT_EQ(tx2.vShieldedSpend.size(), 1); EXPECT_EQ(tx2.vShieldedSpend.size(), 1);
EXPECT_EQ(tx2.vShieldedOutput.size(), 2); EXPECT_EQ(tx2.vShieldedOutput.size(), 2);
EXPECT_EQ(tx2.valueBalance, 10000); EXPECT_EQ(tx2.valueBalanceSapling, 10000);
CWalletTx wtx2 {&wallet, tx2}; CWalletTx wtx2 {&wallet, tx2};
auto hash2 = wtx2.GetHash(); auto hash2 = wtx2.GetHash();

View File

@ -4423,10 +4423,10 @@ UniValue z_getmigrationstatus(const UniValue& params, bool fHelp) {
// A transaction is "finalized" iff it has at least 10 confirmations. // A transaction is "finalized" iff it has at least 10 confirmations.
// TODO: subject to change, if the recommended number of confirmations changes. // TODO: subject to change, if the recommended number of confirmations changes.
if (tx.GetDepthInMainChain() >= 10) { if (tx.GetDepthInMainChain() >= 10) {
finalizedMigratedAmount -= tx.valueBalance; finalizedMigratedAmount -= tx.valueBalanceSapling;
++numFinalizedMigrationTxs; ++numFinalizedMigrationTxs;
} else { } else {
unfinalizedMigratedAmount -= tx.valueBalance; unfinalizedMigratedAmount -= tx.valueBalanceSapling;
} }
// If the transaction is in the mempool it will not be associated with a block yet // If the transaction is in the mempool it will not be associated with a block yet
if (tx.hashBlock.IsNull() || mapBlockIndex[tx.hashBlock] == nullptr) { if (tx.hashBlock.IsNull() || mapBlockIndex[tx.hashBlock] == nullptr) {

View File

@ -158,7 +158,7 @@ SaplingPaymentAddress CWallet::GenerateNewSaplingZKey()
return xsk.DefaultAddress(); return xsk.DefaultAddress();
} }
// Add spending key to keystore // Add spending key to keystore
bool CWallet::AddSaplingZKey(const libzcash::SaplingExtendedSpendingKey &sk) bool CWallet::AddSaplingZKey(const libzcash::SaplingExtendedSpendingKey &sk)
{ {
AssertLockHeld(cs_wallet); // mapSaplingZKeyMetadata AssertLockHeld(cs_wallet); // mapSaplingZKeyMetadata
@ -166,7 +166,7 @@ bool CWallet::AddSaplingZKey(const libzcash::SaplingExtendedSpendingKey &sk)
if (!CCryptoKeyStore::AddSaplingSpendingKey(sk)) { if (!CCryptoKeyStore::AddSaplingSpendingKey(sk)) {
return false; return false;
} }
if (!fFileBacked) { if (!fFileBacked) {
return true; return true;
} }
@ -175,7 +175,7 @@ bool CWallet::AddSaplingZKey(const libzcash::SaplingExtendedSpendingKey &sk)
auto ivk = sk.expsk.full_viewing_key().in_viewing_key(); auto ivk = sk.expsk.full_viewing_key().in_viewing_key();
return CWalletDB(strWalletFile).WriteSaplingZKey(ivk, sk, mapSaplingZKeyMetadata[ivk]); return CWalletDB(strWalletFile).WriteSaplingZKey(ivk, sk, mapSaplingZKeyMetadata[ivk]);
} }
return true; return true;
} }
@ -614,7 +614,7 @@ void CWallet::ChainTipAdded(const CBlockIndex *pindex,
} }
} }
void CWallet::ChainTip(const CBlockIndex *pindex, void CWallet::ChainTip(const CBlockIndex *pindex,
const CBlock *pblock, const CBlock *pblock,
std::optional<std::pair<SproutMerkleTree, SaplingMerkleTree>> added) std::optional<std::pair<SproutMerkleTree, SaplingMerkleTree>> added)
{ {
@ -1276,7 +1276,7 @@ void DecrementNoteWitnesses(NoteDataMap& noteDataMap, int indexHeight, int64_t n
if (nd->witnesses.size() > 0) { if (nd->witnesses.size() > 0) {
nd->witnesses.pop_front(); nd->witnesses.pop_front();
} }
// indexHeight is the height of the block being removed, so // indexHeight is the height of the block being removed, so
// the new witness cache height is one below it. // the new witness cache height is one below it.
nd->witnessHeight = indexHeight - 1; nd->witnessHeight = indexHeight - 1;
} }
@ -2602,14 +2602,14 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived,
} }
} }
// If we sent utxos from this transaction, create output for value taken from (negative valueBalance) // If we sent utxos from this transaction, create output for value taken from (negative valueBalanceSapling)
// or added (positive valueBalance) to the transparent value pool by Sapling shielding and unshielding. // or added (positive valueBalanceSapling) to the transparent value pool by Sapling shielding and unshielding.
if (isFromMyTaddr) { if (isFromMyTaddr) {
if (valueBalance < 0) { if (valueBalanceSapling < 0) {
COutputEntry output = {CNoDestination(), -valueBalance, (int) vout.size()}; COutputEntry output = {CNoDestination(), -valueBalanceSapling, (int) vout.size()};
listSent.push_back(output); listSent.push_back(output);
} else if (valueBalance > 0) { } else if (valueBalanceSapling > 0) {
COutputEntry output = {CNoDestination(), valueBalance, (int) vout.size()}; COutputEntry output = {CNoDestination(), valueBalanceSapling, (int) vout.size()};
listReceived.push_back(output); listReceived.push_back(output);
} }
} }
@ -5045,7 +5045,7 @@ void CWallet::GetFilteredNotes(
} }
/** /**
* Find notes in the wallet filtered by payment addresses, min depth, max depth, * Find notes in the wallet filtered by payment addresses, min depth, max depth,
* if the note is spent, if a spending key is required, and if the notes are locked. * if the note is spent, if a spending key is required, and if the notes are locked.
* These notes are decrypted and added to the output parameter vector, outEntries. * These notes are decrypted and added to the output parameter vector, outEntries.
*/ */
@ -5366,7 +5366,7 @@ KeyAddResult AddSpendingKeyToWallet::operator()(const libzcash::SaplingExtendedS
m_wallet->mapSaplingZKeyMetadata[ivk].seedFp = seedFp; m_wallet->mapSaplingZKeyMetadata[ivk].seedFp = seedFp;
} }
return KeyAdded; return KeyAdded;
} }
} }
} }