diff --git a/src/chain.h b/src/chain.h index 16715925e..326a68280 100644 --- a/src/chain.h +++ b/src/chain.h @@ -19,6 +19,7 @@ * current network-adjusted time before the block will be accepted. */ static const int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60; +static const int64_t MAX_FUTURE_BLOCK_TIME_POST_FORK = 3 * 60; /** * Timestamp window used as a grace period by code that compares external diff --git a/src/validation.cpp b/src/validation.cpp index 44a294e40..65c2ab6d9 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -297,6 +297,12 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc return chain.Genesis(); } +static int64_t GetMaxFutureBlockTime(CBlockIndex *pindexPrev, const Consensus::Params ¶ms) +{ + return pindexPrev->nHeight > params.nMaxBlockSpacingFixDeploymentHeight ? MAX_FUTURE_BLOCK_TIME_POST_FORK : + MAX_FUTURE_BLOCK_TIME; +} + std::unique_ptr pcoinsdbview; std::unique_ptr pcoinsTip; std::unique_ptr pblocktree; @@ -3410,7 +3416,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta return state.Invalid(false, REJECT_INVALID, "time-too-old", "block's timestamp is too early"); // Check timestamp - if (block.GetBlockTime() > nAdjustedTime + MAX_FUTURE_BLOCK_TIME) + if (block.GetBlockTime() > nAdjustedTime + GetMaxFutureBlockTime(pindexPrev)) return state.Invalid(false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future"); // Reject outdated version blocks when 95% (75% on testnet) of the network has upgraded: diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 24144d7eb..21694a9c8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -434,7 +434,7 @@ bool CWallet::CreateCoinStakeKernel(CScript &kernelScript, const CScript &stakeS for(unsigned int i = 0; i < nHashDrift; ++i) { - nTryTime = nTimeTx - i; + nTryTime = nTimeTx + nHashDrift - i; if (CheckStakeKernelHash(nBits, blockFrom, nTxPrevOffset, txPrev, prevout, nTryTime, hashProofOfStake, fPrintProofOfStake)) { //Double check that this will pass time requirements