From 4ea1be7fb84a397222754473c2bc315e3665ff18 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 16 Oct 2014 03:50:33 +0000 Subject: CreateNewBlock and miner_tests: Also check generated template is valid by CheckBlockHeader, ContextualCheckBlockHeader, CheckBlock, and ContextualCheckBlock --- src/miner.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/miner.cpp') diff --git a/src/miner.cpp b/src/miner.cpp index b5bfa9c7be..d7ecd5e40e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -326,8 +326,17 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) indexDummy.nHeight = pindexPrev->nHeight + 1; CCoinsViewCache viewNew(pcoinsTip); CValidationState state; + // NOTE: CheckBlockHeader is called by CheckBlock + if (!ContextualCheckBlockHeader(*pblock, state, pindexPrev)) + throw std::runtime_error("CreateNewBlock() : ContextualCheckBlockHeader failed"); + if (!CheckBlock(*pblock, state, false, false)) + throw std::runtime_error("CreateNewBlock() : CheckBlock failed"); + if (!ContextualCheckBlock(*pblock, state, pindexPrev)) + throw std::runtime_error("CreateNewBlock() : ContextualCheckBlock failed"); if (!ConnectBlock(*pblock, state, &indexDummy, viewNew, true)) throw std::runtime_error("CreateNewBlock() : ConnectBlock failed"); + if (!state.IsValid()) + throw std::runtime_error("CreateNewBlock() : State is not valid"); } return pblocktemplate.release(); -- cgit v1.2.3