mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge da083d4bbd into merged_master (Bitcoin PR bitcoin/bitcoin#29775)
This commit is contained in:
commit
d06014267a
27 changed files with 291 additions and 31 deletions
|
|
@ -4767,6 +4767,18 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
|
|||
LogPrintf("ERROR: %s: block height in header is incorrect (got %d, expected %d)\n", __func__, block.block_height, nHeight);
|
||||
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "bad-header-height");
|
||||
}
|
||||
|
||||
// Testnet4 only: Check timestamp against prev for difficulty-adjustment
|
||||
// blocks to prevent timewarp attacks (see https://github.com/bitcoin/bitcoin/pull/15482).
|
||||
if (consensusParams.enforce_BIP94) {
|
||||
// Check timestamp for the first block of each difficulty adjustment
|
||||
// interval, except the genesis block.
|
||||
if (nHeight % consensusParams.DifficultyAdjustmentInterval() == 0) {
|
||||
if (block.GetBlockTime() < pindexPrev->GetBlockTime() - 60 * 60 * 2) {
|
||||
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "time-timewarp-attack", "block's timestamp is too early on diff adjustment block");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check timestamp
|
||||
if (block.Time() > NodeClock::now() + std::chrono::seconds{MAX_FUTURE_BLOCK_TIME}) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue