@@ -339,6 +339,7 @@ static RPCHelpMan generateblock()
339339 }
340340
341341 NodeContext& node = EnsureAnyNodeContext (request.context );
342+ Mining& miner = EnsureMining (node);
342343 const CTxMemPool& mempool = EnsureMemPool (node);
343344
344345 std::vector<CTransactionRef> txs;
@@ -389,8 +390,8 @@ static RPCHelpMan generateblock()
389390 LOCK (cs_main);
390391
391392 BlockValidationState state;
392- if (!TestBlockValidity (state, chainman. GetParams (), chainman. ActiveChainstate (), block, chainman. m_blockman . LookupBlockIndex (block. hashPrevBlock ), false , false )) {
393- throw JSONRPCError (RPC_VERIFY_ERROR, strprintf (" TestBlockValidity failed: %s" , state.ToString ()));
393+ if (!miner. testBlockValidity (state, block, /* check_merkle_root= */ false )) {
394+ throw JSONRPCError (RPC_VERIFY_ERROR, strprintf (" testBlockValidity failed: %s" , state.ToString ()));
394395 }
395396 }
396397
@@ -664,6 +665,7 @@ static RPCHelpMan getblocktemplate()
664665{
665666 NodeContext& node = EnsureAnyNodeContext (request.context );
666667 ChainstateManager& chainman = EnsureChainman (node);
668+ Mining& miner = EnsureMining (node);
667669 LOCK (cs_main);
668670
669671 std::string strMode = " template" ;
@@ -706,11 +708,12 @@ static RPCHelpMan getblocktemplate()
706708 }
707709
708710 CBlockIndex* const pindexPrev = active_chain.Tip ();
709- // TestBlockValidity only supports blocks built on the current Tip
710- if (block.hashPrevBlock != pindexPrev->GetBlockHash ())
711+ // testBlockValidity only supports blocks built on the current Tip
712+ if (block.hashPrevBlock != pindexPrev->GetBlockHash ()) {
711713 return " inconclusive-not-best-prevblk" ;
714+ }
712715 BlockValidationState state;
713- TestBlockValidity (state, chainman. GetParams (), active_chainstate, block, pindexPrev, false , true );
716+ miner. testBlockValidity (state, block);
714717 return BIP22ValidationResult (state);
715718 }
716719
@@ -726,7 +729,6 @@ static RPCHelpMan getblocktemplate()
726729 if (strMode != " template" )
727730 throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid mode" );
728731
729- Mining& miner = EnsureMining (node);
730732 if (!miner.isTestChain ()) {
731733 const CConnman& connman = EnsureConnman (node);
732734 if (connman.GetNodeCount (ConnectionDirection::Both) == 0 ) {
0 commit comments