Skip to content

Commit

Permalink
consensus: Combine heartwoodActive conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom authored and str4d committed Aug 22, 2020
1 parent 6027a61 commit 830b8a4
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,18 +897,6 @@ bool ContextualCheckTransaction(
REJECT_INVALID, "bad-txns-oversize");
}

// Rules that apply before Heartwood:
if (!heartwoodActive) {
if (tx.IsCoinBase()) {
// A coinbase transaction cannot have output descriptions
if (tx.vShieldedOutput.size() > 0)
return state.DoS(
dosLevelPotentiallyRelaxing,
error("CheckTransaction(): coinbase has output descriptions"),
REJECT_INVALID, "bad-cb-has-output-description");
}
}

// From Canopy onward, coinbase transaction must include outputs corresponding to the
// ZIP 207 consensus funding streams active at the current block height. To avoid
// double-decrypting, we detect any shielded funding streams during the Heartwood
Expand All @@ -918,7 +906,7 @@ bool ContextualCheckTransaction(
GetBlockSubsidy(nHeight, chainparams.GetConsensus()),
chainparams.GetConsensus());

// Rules that apply to Heartwood or later:
// Rules that apply to Heartwood and later:
if (heartwoodActive) {
if (tx.IsCoinBase()) {
// All Sapling outputs in coinbase transactions MUST have valid note commitments
Expand Down Expand Up @@ -978,6 +966,19 @@ bool ContextualCheckTransaction(
}
}
}
} else {
// Rules that apply generally before Heartwood. These were
// previously noncontextual checks that became contextual
// after Heartwood activation.

if (tx.IsCoinBase()) {
// A coinbase transaction cannot have output descriptions
if (tx.vShieldedOutput.size() > 0)
return state.DoS(
dosLevelPotentiallyRelaxing,
error("CheckTransaction(): coinbase has output descriptions"),
REJECT_INVALID, "bad-cb-has-output-description");
}
}

// Rules that apply to Canopy or later:
Expand Down

0 comments on commit 830b8a4

Please sign in to comment.