| 4274 | } |
| 4275 | |
| 4276 | bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW) { |
| 4277 | // Get prev block index |
| 4278 | |
| 4279 | int nBlockHeight = 0; |
| 4280 | const CChainParams& chainparams = Params(); |
| 4281 | CBlockIndex* pindexPrev = LookupBlockIndex(block.hashPrevBlock); |
| 4282 | if (pindexPrev) { |
| 4283 | nBlockHeight = pindexPrev->nHeight + 1; |
| 4284 | bool isScVersioned = block.nVersion & (1 << consensusParams.vDeployments[Consensus::SMART_CONTRACTS_HARDFORK].bit); |
| 4285 | if (nBlockHeight >= chainparams.FirstSCBlock() && !isScVersioned) { |
| 4286 | return error("invalid block version after smart-contract hardfork"); |
| 4287 | } |
| 4288 | if (nBlockHeight >= chainparams.FirstSCBlock() && (block.hashStateRoot == uint256(0) || block.hashUTXORoot == uint256(0))) { |
| 4289 | return error("utxo root or state root uninitialized after smart-contract hardfork"); |
| 4290 | } |
| 4291 | } |
| 4292 | |
| 4293 | |
| 4294 | if (chainActive.Height()<nBlockHeight-1 && fReindex) { |
| 4295 | chainActive.SetTip(LookupBlockIndex(block.hashPrevBlock));} |
| 4296 | |
| 4297 | |
| 4298 | if (fCheckPOW && !CheckProofOfWork(block.GetHash(nBlockHeight,2), block.nBits, consensusParams)) |
| 4299 | return state.DoS(50, false, REJECT_INVALID, "high-hash", false, "proof of work failed"); |
| 4300 | |
| 4301 | if (fReindex ) |
| 4302 | chainActive.SetTip(LookupBlockIndex(pcoinsTip->GetBestBlock())); |
| 4303 | return true; |
| 4304 | } |
| 4305 | |
| 4306 | bool CheckForMasternodePayment(const CTransaction& tx, const CBlockHeader& header) { |
| 4307 | // Regular transactions don't have to share anything with masternodes |
no test coverage detected