|
|
@ -788,7 +788,7 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) |
|
|
|
if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) { |
|
|
|
for (const auto& txin : tx.vin) { |
|
|
|
if (!(txin.nSequence == CTxIn::SEQUENCE_FINAL)) |
|
|
|
if (!(txin.nSequence == CTxIn::SEQUENCE_FINAL)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -1002,11 +1002,11 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp, bool |
|
|
|
unsigned int GetLegacySigOpCount(const CTransaction& tx) |
|
|
|
unsigned int GetLegacySigOpCount(const CTransaction& tx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned int nSigOps = 0; |
|
|
|
unsigned int nSigOps = 0; |
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) |
|
|
|
for (const auto& txin : tx.vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nSigOps += txin.scriptSig.GetSigOpCount(false); |
|
|
|
nSigOps += txin.scriptSig.GetSigOpCount(false); |
|
|
|
} |
|
|
|
} |
|
|
|
BOOST_FOREACH(const CTxOut& txout, tx.vout) |
|
|
|
for (const auto& txout : tx.vout) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nSigOps += txout.scriptPubKey.GetSigOpCount(false); |
|
|
|
nSigOps += txout.scriptPubKey.GetSigOpCount(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -1064,7 +1064,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state) |
|
|
|
|
|
|
|
|
|
|
|
// Check for negative or overflow output values
|
|
|
|
// Check for negative or overflow output values
|
|
|
|
CAmount nValueOut = 0; |
|
|
|
CAmount nValueOut = 0; |
|
|
|
BOOST_FOREACH(const CTxOut& txout, tx.vout) |
|
|
|
for (const auto& txout : tx.vout) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (txout.nValue < 0) |
|
|
|
if (txout.nValue < 0) |
|
|
|
return state.DoS(100, false, REJECT_INVALID, "bad-txns-vout-negative"); |
|
|
|
return state.DoS(100, false, REJECT_INVALID, "bad-txns-vout-negative"); |
|
|
@ -1077,7 +1077,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state) |
|
|
|
|
|
|
|
|
|
|
|
// Check for duplicate inputs
|
|
|
|
// Check for duplicate inputs
|
|
|
|
set<COutPoint> vInOutPoints; |
|
|
|
set<COutPoint> vInOutPoints; |
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) |
|
|
|
for (const auto& txin : tx.vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (vInOutPoints.count(txin.prevout)) |
|
|
|
if (vInOutPoints.count(txin.prevout)) |
|
|
|
return state.DoS(100, false, REJECT_INVALID, "bad-txns-inputs-duplicate"); |
|
|
|
return state.DoS(100, false, REJECT_INVALID, "bad-txns-inputs-duplicate"); |
|
|
@ -1091,7 +1091,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state) |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) |
|
|
|
for (const auto& txin : tx.vin) |
|
|
|
if (txin.prevout.IsNull()) |
|
|
|
if (txin.prevout.IsNull()) |
|
|
|
return state.DoS(10, false, REJECT_INVALID, "bad-txns-prevout-null"); |
|
|
|
return state.DoS(10, false, REJECT_INVALID, "bad-txns-prevout-null"); |
|
|
|
} |
|
|
|
} |
|
|
@ -3404,13 +3404,13 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P |
|
|
|
return state.DoS(100, false, REJECT_INVALID, "bad-cb-multiple", false, "more than one coinbase"); |
|
|
|
return state.DoS(100, false, REJECT_INVALID, "bad-cb-multiple", false, "more than one coinbase"); |
|
|
|
|
|
|
|
|
|
|
|
// Check transactions
|
|
|
|
// Check transactions
|
|
|
|
BOOST_FOREACH(const CTransaction& tx, block.vtx) |
|
|
|
for (const auto& tx : block.vtx) |
|
|
|
if (!CheckTransaction(tx, state)) |
|
|
|
if (!CheckTransaction(tx, state)) |
|
|
|
return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(), |
|
|
|
return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(), |
|
|
|
strprintf("Transaction check failed (tx hash %s) %s", tx.GetHash().ToString(), state.GetDebugMessage())); |
|
|
|
strprintf("Transaction check failed (tx hash %s) %s", tx.GetHash().ToString(), state.GetDebugMessage())); |
|
|
|
|
|
|
|
|
|
|
|
unsigned int nSigOps = 0; |
|
|
|
unsigned int nSigOps = 0; |
|
|
|
BOOST_FOREACH(const CTransaction& tx, block.vtx) |
|
|
|
for (const auto& tx : block.vtx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nSigOps += GetLegacySigOpCount(tx); |
|
|
|
nSigOps += GetLegacySigOpCount(tx); |
|
|
|
} |
|
|
|
} |
|
|
@ -3541,7 +3541,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn |
|
|
|
: block.GetBlockTime(); |
|
|
|
: block.GetBlockTime(); |
|
|
|
|
|
|
|
|
|
|
|
// Check that all transactions are finalized
|
|
|
|
// Check that all transactions are finalized
|
|
|
|
BOOST_FOREACH(const CTransaction& tx, block.vtx) { |
|
|
|
for (const auto& tx : block.vtx) { |
|
|
|
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff)) { |
|
|
|
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff)) { |
|
|
|
return state.DoS(10, false, REJECT_INVALID, "bad-txns-nonfinal", false, "non-final transaction"); |
|
|
|
return state.DoS(10, false, REJECT_INVALID, "bad-txns-nonfinal", false, "non-final transaction"); |
|
|
|
} |
|
|
|
} |
|
|
|