@@ -2915,6 +2915,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
2915
2915
if (pindex->IsProofOfStake ())
2916
2916
setStakeSeen.insert (make_pair (pindex->prevoutStake , pindex->nStakeTime ));
2917
2917
2918
+
2919
+ // Check proof of stake
2920
+ if (block.nBits != GetNextTargetRequired (pindex->pprev , block.IsProofOfStake ())){
2921
+ return state.DoS (1 ,error (" ContextualCheckBlock() : incorrect %s at height %d (%d)" , !block.IsProofOfStake () ? " proof-of-work" : " proof-of-stake" ,pindex->pprev ->nHeight , block.nBits ), REJECT_INVALID, " bad-diffbits" );
2922
+ }
2923
+
2918
2924
arith_uint256 hashProof;
2919
2925
2920
2926
// Verify hash target and signature of coinstake tx
@@ -2929,9 +2935,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
2929
2935
}
2930
2936
2931
2937
if (block.IsProofOfWork ())
2932
- {
2933
2938
hashProof = UintToArith256 (block.GetPoWHash ());
2934
- }
2935
2939
2936
2940
if (!pindex->SetStakeEntropyBit (block.GetStakeEntropyBit ()))
2937
2941
return state.DoS (1 ,error (" ConnectBlock() : SetStakeEntropyBit() failed" ), REJECT_INVALID, " bad-entropy-bit" );
@@ -4762,11 +4766,6 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
4762
4766
if (VersionBitsState (pindexPrev, consensusParams, Consensus::DEPLOYMENT_CSV, versionbitscache) == THRESHOLD_ACTIVE) {
4763
4767
nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST;
4764
4768
}
4765
-
4766
- // Check proof of stake
4767
- if (nHeight > 0 && block.nBits != GetNextTargetRequired (pindexPrev, block.IsProofOfStake ())){
4768
- return state.DoS (1 ,error (" ContextualCheckBlock() : incorrect %s at height %d (%d)" , !block.IsProofOfStake () ? " proof-of-work" : " proof-of-stake" , nHeight, block.nBits ), REJECT_INVALID, " bad-diffbits" );
4769
- }
4770
4769
4771
4770
if (block.IsProofOfWork () && nHeight > Params ().GetConsensus ().nLastPOWBlock )
4772
4771
return state.DoS (10 , false , REJECT_INVALID, " check-pow-height" , " pow-mined blocks not allowed" );
0 commit comments