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.
252# The node will broadcast each transaction, still abiding by its peer's fee filter253peer.wait_for_broadcast([tx["tx"].wtxid_hex for tx in package_txns])255self.log.info("Check a package that passes mempoolminfee but is evicted immediately after submission")256mempoolmin_feerate = node.getmempoolinfo()["mempoolminfee"]257current_mempool = node.getrawmempool(verbose=False)258worst_feerate_btcvb = Decimal("21000000")259for txid in current_mempool:260entry = node.getmempoolentry(txid)261worst_feerate_btcvb = min(worst_feerate_btcvb, entry["fees"]["descendant"] / entry["descendantsize"])262# Needs to be large enough to trigger eviction263# (note that the mempool usage of a tx is about three times its vsize)264target_vsize_each = 50000265assert_greater_than(target_vsize_each * 2 * 3, node.getmempoolinfo()["maxmempool"] - node.getmempoolinfo()["bytes"])266# Should be a true CPFP: parent's feerate is just below mempool min feerate267parent_feerate = mempoolmin_feerate - Decimal("0.0000001") # 0.01 sats/vbyte below min feerate268# Parent + child is above mempool minimum feerate269child_feerate = (worst_feerate_btcvb * 1000) - Decimal("0.0000001") # 0.01 sats/vbyte below worst feerate270# However, when eviction is triggered, these transactions should be at the bottom.271# This assertion assumes parent and child are the same size.272miniwallet.rescan_utxos()273tx_parent_just_below = miniwallet.create_self_transfer(fee_rate=parent_feerate, target_vsize=target_vsize_each)274tx_child_just_above = miniwallet.create_self_transfer(utxo_to_spend=tx_parent_just_below["new_utxo"], fee_rate=child_feerate, target_vsize=target_vsize_each)275# This package ranks below the lowest descendant package in the mempool276package_fee = tx_parent_just_below["fee"] + tx_child_just_above["fee"]277package_vsize = tx_parent_just_below["tx"].get_vsize() + tx_child_just_above["tx"].get_vsize()278assert_greater_than(worst_feerate_btcvb, package_fee / package_vsize)279assert_greater_than(mempoolmin_feerate, tx_parent_just_below["fee"] / (tx_parent_just_below["tx"].get_vsize()))280assert_greater_than(package_fee / package_vsize, mempoolmin_feerate / 1000)281res = node.submitpackage([tx_parent_just_below["hex"], tx_child_just_above["hex"]])282for wtxid in [tx_parent_just_below["wtxid"], tx_child_just_above["wtxid"]]:283assert_equal(res["tx-results"][wtxid]["error"], "mempool full")285self.log.info('Test passing a value below the minimum (5 MB) to -maxmempool throws an error')286self.stop_node(0)287self.nodes[0].assert_start_raises_init_error(["-maxmempool=4"], "Error: -maxmempool must be at least 5 MB")289self.test_mid_package_eviction_success()290self.test_mid_package_replacement()293if __name__ == '__main__':294MempoolLimitTest(__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.