mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Refactors in anticipation of blinded values
This commit is contained in:
parent
743081a205
commit
b5f1b6dd38
34 changed files with 262 additions and 133 deletions
|
|
@ -504,11 +504,11 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe
|
|||
CAmount nValueOut = 0;
|
||||
for (const auto& txout : tx.vout)
|
||||
{
|
||||
if (txout.nValue < 0)
|
||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-vout-negative");
|
||||
if (txout.nValue > MAX_MONEY)
|
||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-vout-toolarge");
|
||||
nValueOut += txout.nValue;
|
||||
if (!txout.nValue.IsValid())
|
||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-vout-amount-invalid");
|
||||
if (!txout.nValue.IsAmount())
|
||||
continue;
|
||||
nValueOut += txout.nValue.GetAmount();
|
||||
if (!MoneyRange(nValueOut))
|
||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-txouttotal-toolarge");
|
||||
}
|
||||
|
|
@ -1432,9 +1432,12 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
|
|||
}
|
||||
|
||||
// Check for negative or overflow input values
|
||||
nValueIn += coins->vout[prevout.n].nValue;
|
||||
if (!MoneyRange(coins->vout[prevout.n].nValue) || !MoneyRange(nValueIn))
|
||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-inputvalues-outofrange");
|
||||
const CTxOutValue& value = coins->vout[prevout.n].nValue;
|
||||
if (value.IsAmount()) {
|
||||
nValueIn += value.GetAmount();
|
||||
if (!MoneyRange(value.GetAmount()) || !MoneyRange(nValueIn))
|
||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-inputvalues-outofrange");
|
||||
}
|
||||
|
||||
if (coins->vout[prevout.n].scriptPubKey.IsWithdrawLock() && tx.vin[i].scriptSig.IsWithdrawProof()) {
|
||||
uint256 genesisHash(coins->vout[prevout.n].scriptPubKey.GetWithdrawLockGenesisHash());
|
||||
|
|
@ -1518,7 +1521,11 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
|
|||
// super-majority signaling has occurred.
|
||||
return state.DoS(100,false, REJECT_INVALID, strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(check.GetScriptError())));
|
||||
}
|
||||
prevValueIn = coins->vout[tx.vin[i].prevout.n].nValue;
|
||||
const CTxOutValue& value = coins->vout[tx.vin[i].prevout.n].nValue;
|
||||
if (value.IsAmount())
|
||||
prevValueIn = value.GetAmount();
|
||||
else
|
||||
prevValueIn = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue