Fix incorrect validations of block transactions

This commit is contained in:
miketout
2018-05-07 10:29:43 -07:00
parent b45d65b46c
commit 68334c8dae
3 changed files with 27 additions and 28 deletions

View File

@@ -2057,9 +2057,9 @@ namespace Consensus {
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase");
}
// ensure that zeroth output of coinbases are not still time locked
uint64_t unlockTime = tx.UnlockTime(0);
if (nSpendHeight >= unlockTime) {
// ensure that output of coinbases are not still time locked
uint64_t unlockTime = komodo_block_unlocktime(coins->nHeight);
if (nSpendHeight < unlockTime && coins->TotalTxValue() >= ASSETCHAINS_TIMELOCKGTE) {
return state.Invalid(
error("CheckInputs(): tried to spend coinbase that is timelocked until block %d", unlockTime),
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase");
@@ -2563,17 +2563,20 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const
const int FIFTY_YEARS = 50*365*24*60*60;
double alertThreshold = 1.0 / (FIFTY_YEARS / SPAN_SECONDS);
if (p <= alertThreshold && nBlocks < BLOCKS_EXPECTED)
if (bestHeader->nHeight > BLOCKS_EXPECTED)
{
// Many fewer blocks than expected: alert!
strWarning = strprintf(_("WARNING: check your network connection, %d blocks received in the last %d hours (%d expected)"),
nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
}
else if (p <= alertThreshold && nBlocks > BLOCKS_EXPECTED)
{
// Many more blocks than expected: alert!
strWarning = strprintf(_("WARNING: abnormally high number of blocks generated, %d blocks received in the last %d hours (%d expected)"),
nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
if (p <= alertThreshold && nBlocks < BLOCKS_EXPECTED)
{
// Many fewer blocks than expected: alert!
strWarning = strprintf(_("WARNING: check your network connection, %d blocks received in the last %d hours (%d expected)"),
nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
}
else if (p <= alertThreshold && nBlocks > BLOCKS_EXPECTED)
{
// Many more blocks than expected: alert!
strWarning = strprintf(_("WARNING: abnormally high number of blocks generated, %d blocks received in the last %d hours (%d expected)"),
nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
}
}
if (!strWarning.empty())
{