Add check that vpubs are not both nonzero and test it.

This commit is contained in:
Taylor Hornby
2016-04-13 16:52:24 -06:00
parent d16d5ef832
commit 6ad4db2253
3 changed files with 52 additions and 9 deletions

View File

@@ -881,26 +881,36 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
// Ensure that pour values are well-formed
BOOST_FOREACH(const CPourTx& pour, tx.vpour)
{
if (pour.vpub_old < 0)
if (pour.vpub_old < 0) {
return state.DoS(100, error("CheckTransaction(): pour.vpub_old negative"),
REJECT_INVALID, "bad-txns-vpub_old-negative");
}
if (pour.vpub_new < 0)
if (pour.vpub_new < 0) {
return state.DoS(100, error("CheckTransaction(): pour.vpub_new negative"),
REJECT_INVALID, "bad-txns-vpub_new-negative");
}
if (pour.vpub_old > MAX_MONEY)
if (pour.vpub_old > MAX_MONEY) {
return state.DoS(100, error("CheckTransaction(): pour.vpub_old too high"),
REJECT_INVALID, "bad-txns-vpub_old-toolarge");
}
if (pour.vpub_new > MAX_MONEY)
if (pour.vpub_new > MAX_MONEY) {
return state.DoS(100, error("CheckTransaction(): pour.vpub_new too high"),
REJECT_INVALID, "bad-txns-vpub_new-toolarge");
}
if (pour.vpub_new != 0 && pour.vpub_old != 0) {
return state.DoS(100, error("CheckTransaction(): pour.vpub_new and pour.vpub_old both nonzero"),
REJECT_INVALID, "bad-txns-vpubs-both-nonzero");
}
nValueOut += pour.vpub_new;
if (!MoneyRange(nValueOut))
if (!MoneyRange(nValueOut)) {
return state.DoS(100, error("CheckTransaction(): txout total out of range"),
REJECT_INVALID, "bad-txns-txouttotal-toolarge");
}
}