Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
751assert_equal(raw_txs_wtxid.result[1].hex(), tx2["hex"])752assert_equal(raw_txs_wtxid.result[2], b'')754self.log.debug("Mined transactions are not returned")755self.generate(self.nodes[0], 1)756self.sync_all()757raw_txs = await mining.getTransactionsByTxID(ctx, [tx1["tx"].txid])758assert_equal(raw_txs.result[0], b'')759raw_txs = await mining.getTransactionsByWitnessID(ctx, [tx1["tx"].wtxid])760assert_equal(raw_txs.result[0], b'')762asyncio.run(capnp.run(async_routine()))764def run_low_height_test(self):765"""Test that IPC createNewBlock() works at low block heights on a766clean chain, in particular with regard to bad-cb-length.768createNewBlock pads the scriptSig with a dummy extranonce to pass769its internal CheckBlock(). This dummy is omitted from the770getCoinbaseTx() script_sig_prefix field. The client provides its771own extraNonce via submitSolution()."""772self.log.info("Running low block height test")774node = self.nodes[0]775self.stop_node(0)776# Clear chain data to start from genesis777self.cleanup_folder(node.chain_path)778node.start()779node.wait_for_rpc_connection()780assert_equal(node.getblockcount(), 0)782async def async_routine():783ctx, mining = await make_mining_ctx(self)784opts = self.capnp_modules['mining'].BlockCreateOptions()786# Mine blocks 1-17 to exercise the boundary at height 16, where the787# internal scriptSig padding is no longer needed.788for height in range(1, 18):789async with AsyncExitStack() as stack:790# Disable cooldown to avoid hanging in the IBD loop on a fresh chain791template = await mining_create_block_template(mining, stack, ctx, opts, cooldown=False)792assert template is not None793block = await mining_get_block(template, ctx)794# Heights <= 16 need extra nonce padding.795extra_nonce = b'\xaa\xbb\xcc\xdd' if height <= 16 else b""796coinbase = await self.build_coinbase_test(template, ctx, self.miniwallet, extra_nonce=extra_nonce)797block.vtx[0] = coinbase798block.hashMerkleRoot = block.calc_merkle_root()799block.solve()800result = await template.submitSolution(ctx, block.nVersion, block.nTime, block.nNonce, coinbase.serialize())801assert_equal(result.result, True)802assert_equal(result.reason, "")803assert_equal(result.debug, "")804assert_equal(node.getblockcount(), height)806asyncio.run(capnp.run(async_routine()))808def run_test(self):809self.miniwallet = MiniWallet(self.nodes[0])810# Amount of time in milliseconds the test is allowed to wait or be idle before it should fail.811self.default_ipc_timeout = 1000.0 * self.options.timeout_factor812self.default_block_create_options = self.capnp_modules['mining'].BlockCreateOptions()813self.default_block_wait_options = self.capnp_modules['mining'].BlockWaitOptions()814self.default_block_wait_options.timeout = self.default_ipc_timeout815self.default_block_wait_options.feeThreshold = 1816self.run_mining_interface_test()817self.run_early_startup_test()818self.run_block_template_test()819self.run_coinbase_and_submission_test()820self.run_waitnext_mining_policy_test()821self.run_block_max_weight_test()822self.run_ipc_option_override_test()823self.run_transaction_lookup_test()825# Needs to run last because it resets the chain.826self.run_low_height_test()829if __name__ == '__main__':830IPCMiningTest(__file__).main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.