Add check for consistency between nActionsOrchard and Orchard flags.

Fixes #5245
This commit is contained in:
Kris Nuttycombe 2021-07-06 10:40:47 -06:00
parent c34162d6dd
commit 76aafa0f5f
1 changed files with 7 additions and 1 deletions

View File

@ -1112,7 +1112,6 @@ bool ContextualCheckTransaction(
}
}
// nSpendsSapling, nOutputsSapling, and nActionsOrchard MUST all be less than 2^16
size_t max_elements = (1 << 16) - 1;
if (tx.vShieldedSpend.size() > max_elements) {
@ -1134,6 +1133,13 @@ bool ContextualCheckTransaction(
REJECT_INVALID, "bad-tx-too-many-orchard-actions");
}
if (orchard_bundle.GetNumActions() > 0 && !orchard_bundle.OutputsEnabled() && !orchard_bundle.SpendsEnabled()) {
return state.DoS(
dosLevelPotentiallyRelaxing,
error("ContextualCheckTransaction(): Orchard actions are present, but flags do not permit Orchard spends or outputs"),
REJECT_INVALID, "bad-tx-orchard-flags-disable-actions");
}
if (tx.IsCoinBase()) {
if (!orchard_bundle.CoinbaseOutputsAreValid()) {
return state.DoS(