Skip to content

Commit

Permalink
consensus constant breaks testnet rules
Browse files Browse the repository at this point in the history
Signed-off-by: k155 <[email protected]>

(cherry picked from commit bbf411a)
  • Loading branch information
tpruvot authored and 216k155 committed Jul 17, 2018
1 parent 4780fed commit 0df51d7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/consensus/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@
#include "main.h"

namespace Consensus {
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight)
{
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight) {
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
// for an attacker to attempt to split the network.
if (!inputs.HaveInputs(tx))
return state.Invalid(false, 0, "", "Inputs unavailable");

CAmount nValueIn = 0;
CAmount nFees = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++)
{
for (unsigned int i = 0; i < tx.vin.size(); i++) {
const COutPoint &prevout = tx.vin[i].prevout;
const CCoins* coins = inputs.AccessCoins(prevout.hash);
assert(coins);

// If prev is coinbase, check that it's matured
if (coins->IsCoinBase() || coins->IsCoinStake()) {
if (nSpendHeight - coins->nHeight < COINBASE_MATURITY)
const int maturity = IsTestNet() ? 10 : COINBASE_MATURITY; // todo: use COINBASE_MATURITY()
if (nSpendHeight - coins->nHeight < maturity && nSpendHeight - coins->nHeight > 0)
return state.Invalid(false,
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase",
strprintf("tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight));
Expand All @@ -42,8 +41,7 @@ namespace Consensus {

}

if (!tx.IsCoinStake())
{
if (!tx.IsCoinStake()) {
if (nValueIn < tx.GetValueOut())
return state.DoS(100, false, REJECT_INVALID, "bad-txns-in-belowout", false,
strprintf("value in (%s) < value out (%s)", FormatMoney(nValueIn), FormatMoney(tx.GetValueOut())));
Expand Down Expand Up @@ -177,8 +175,6 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp, bool
AssertLockHeld(mempool.cs);

CBlockIndex* tip = chainActive.Tip();
if (!tip) return error("%s: chainActive.Tip() = NULL", __func__);

CBlockIndex index;
index.pprev = tip;
// CheckSequenceLocks() uses chainActive.Height()+1 to evaluate
Expand Down

0 comments on commit 0df51d7

Please sign in to comment.