Skip to content

Commit

Permalink
Verify match between type and tx version in GetValidatedTxPayload
Browse files Browse the repository at this point in the history
  • Loading branch information
panleone committed Mar 23, 2024
1 parent bf373bf commit 325a204
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/evo/specialtx_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ static bool CheckCollateralOut(const CTxOut& out, const ProRegPL& pl, CValidatio
// Provider Register Payload
static bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache* view, CValidationState& state)
{
assert(tx.nType == CTransaction::TxType::PROREG);

ProRegPL pl;
if (!GetValidatedTxPayload(tx, pl, state)) {
Expand Down Expand Up @@ -191,7 +190,6 @@ static bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev,
// Provider Update Service Payload
static bool CheckProUpServTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state)
{
assert(tx.nType == CTransaction::TxType::PROUPSERV);

ProUpServPL pl;
if (!GetValidatedTxPayload(tx, pl, state)) {
Expand Down Expand Up @@ -245,7 +243,6 @@ static bool CheckProUpServTx(const CTransaction& tx, const CBlockIndex* pindexPr
// Provider Update Registrar Payload
static bool CheckProUpRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache* view, CValidationState& state)
{
assert(tx.nType == CTransaction::TxType::PROUPREG);

ProUpRegPL pl;
if (!GetValidatedTxPayload(tx, pl, state)) {
Expand Down Expand Up @@ -324,7 +321,6 @@ static bool CheckProUpRegTx(const CTransaction& tx, const CBlockIndex* pindexPre
// Provider Update Revoke Payload
static bool CheckProUpRevTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state)
{
assert(tx.nType == CTransaction::TxType::PROUPREV);

ProUpRevPL pl;
if (!GetValidatedTxPayload(tx, pl, state)) {
Expand Down Expand Up @@ -593,6 +589,9 @@ uint256 CalcTxInputsHash(const CTransaction& tx)
template <typename T>
bool GetValidatedTxPayload(const CTransaction& tx, T& obj, CValidationState& state)
{
if (tx.nType != T::SPECIALTX_TYPE) {
return state.DoS(100, false, REJECT_INVALID, "bad-protx-type");
}
if (!GetTxPayload(tx, obj)) {
return state.DoS(100, false, REJECT_INVALID, "bad-protx-payload");
}
Expand Down

0 comments on commit 325a204

Please sign in to comment.