diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index c1af397872..7726d25099 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1015,10 +1015,6 @@ static RPCHelpMan submitblock() throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed"); } - if (block.vtx.empty() || !block.vtx[0]->IsCoinBase()) { - throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block does not start with a coinbase"); - } - ChainstateManager& chainman = EnsureAnyChainman(request.context); uint256 hash = block.GetHash(); { diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py index aca71933ec..decee34e99 100755 --- a/test/functional/mining_basic.py +++ b/test/functional/mining_basic.py @@ -239,9 +239,19 @@ class MiningTest(BitcoinTestFramework): bad_block.vtx[0].rehash() assert_template(node, bad_block, 'bad-cb-missing') - self.log.info("submitblock: Test invalid coinbase transaction") - assert_raises_rpc_error(-22, "Block does not start with a coinbase", node.submitblock, CBlock().serialize().hex()) - assert_raises_rpc_error(-22, "Block does not start with a coinbase", node.submitblock, bad_block.serialize().hex()) + self.log.info("submitblock: Test bad input hash for coinbase transaction") + bad_block.solve() + assert_equal("bad-cb-missing", node.submitblock(hexdata=bad_block.serialize().hex())) + + self.log.info("submitblock: Test block with no transactions") + no_tx_block = copy.deepcopy(block) + no_tx_block.vtx.clear() + no_tx_block.hashMerkleRoot = 0 + no_tx_block.solve() + assert_equal("bad-blk-length", node.submitblock(hexdata=no_tx_block.serialize().hex())) + + self.log.info("submitblock: Test empty block") + assert_equal('high-hash', node.submitblock(hexdata=CBlock().serialize().hex())) self.log.info("getblocktemplate: Test truncated final transaction") assert_raises_rpc_error(-22, "Block decode failed", node.getblocktemplate, {