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.
251# block containing A and B is disconnected, AND B is not accepted back252# into node1's mempool because its ancestor count is too high.254# Create 8 transactions, like so:255# Tx0 -> Tx1 (vout0)256# \--> Tx2 (vout1) -> Tx3 -> Tx4 -> Tx5 -> Tx6 -> Tx7257#258# Mine them in the next block, then generate a new tx8 that spends259# Tx1 and Tx7, and add to node1's mempool, then disconnect the260# last block.262# Prep for fork263fork_blocks = create_empty_fork(self.nodes[0])265# Create tx0 with 2 outputs266tx0 = self.wallet.send_self_transfer_multi(from_node=self.nodes[0], num_outputs=2)268# Create tx1269tx1 = self.wallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=tx0["new_utxos"][0])271# Create tx2-7272tx7 = self.wallet.send_self_transfer_chain(from_node=self.nodes[0], utxo_to_spend=tx0["new_utxos"][1], chain_length=6)[-1]274# Mine these in a block275self.generate(self.nodes[0], 1)277# Now generate tx8, with a big fee278self.wallet.send_self_transfer_multi(from_node=self.nodes[0], utxos_to_spend=[tx1["new_utxo"], tx7["new_utxo"]], fee_per_output=40000)279self.sync_mempools()281# Now try to disconnect the tip on each node...282self.trigger_reorg(fork_blocks, self.nodes[0])283self.sync_blocks()285if __name__ == '__main__':286MempoolPackagesTest(__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.