Add check that vpubs are not both nonzero and test it.
This commit is contained in:
20
src/main.cpp
20
src/main.cpp
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user