Rename tx.valueBalance -> tx.valueBalanceSapling
This commit is contained in:
parent
feef0e03f6
commit
fd91f099f4
|
@ -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());
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
34
src/main.cpp
34
src/main.cpp
|
@ -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) {
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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());
|
||||||
|
|
|
@ -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());
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue