From 826e7d063aa105dd71251de94049589e5ab7ee63 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Wed, 14 Nov 2018 14:49:32 +0100 Subject: [PATCH] Move internal collateral check to the else branch of the external collateral check --- src/evo/providertx.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/evo/providertx.cpp b/src/evo/providertx.cpp index c781da630..8f0bc7e0d 100644 --- a/src/evo/providertx.cpp +++ b/src/evo/providertx.cpp @@ -93,15 +93,6 @@ bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValid return state.DoS(100, false, REJECT_INVALID, "bad-protx-mode"); } - // when collateralOutpoint refers to an external collateral, we check it further down - if (ptx.collateralOutpoint.hash.IsNull()) { - if (ptx.collateralOutpoint.n >= tx.vout.size()) { - return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral-index"); - } - if (tx.vout[ptx.collateralOutpoint.n].nValue != 1000 * COIN) { - return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral"); - } - } if (ptx.keyIDOwner.IsNull() || !ptx.pubKeyOperator.IsValid() || ptx.keyIDVoting.IsNull()) { return state.DoS(10, false, REJECT_INVALID, "bad-protx-key-null"); } @@ -152,6 +143,12 @@ bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValid collateralOutpoint = ptx.collateralOutpoint; } else { + if (ptx.collateralOutpoint.n >= tx.vout.size()) { + return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral-index"); + } + if (tx.vout[ptx.collateralOutpoint.n].nValue != 1000 * COIN) { + return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral"); + } collateralOutpoint = COutPoint(tx.GetHash(), ptx.collateralOutpoint.n); }