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.
501for incremental_setting in (0, 5, 10, 50, 100, 234, 1000, 5000, 21000):502incremental_setting_decimal = incremental_setting / Decimal(COIN)503self.log.info(f"-> Test -incrementalrelayfee={incremental_setting:.8f}sat/kvB...")504self.restart_node(0, extra_args=[f"-incrementalrelayfee={incremental_setting_decimal:.8f}", "-persistmempool=0"])506# When incremental relay feerate is higher than min relay feerate, min relay feerate is automatically increased.507min_relay_feerate = node.getmempoolinfo()["minrelaytxfee"]508assert_greater_than_or_equal(min_relay_feerate, incremental_setting_decimal)510low_feerate = min_relay_feerate * 2511confirmed_utxo = self.wallet.get_utxo(confirmed_only=True)512# Use different versions to avoid creating an identical transaction when failed_replacement_tx is created.513# Use a target vsize that is small, but something larger than the minimum so that we can create a transaction that is 1vB smaller later.514replacee_tx = self.wallet.create_self_transfer(utxo_to_spend=confirmed_utxo, fee_rate=low_feerate, version=3, target_vsize=200)515node.sendrawtransaction(replacee_tx['hex'])517replacement_placeholder_tx = self.wallet.create_self_transfer(utxo_to_spend=confirmed_utxo, target_vsize=200)518replacement_expected_size = replacement_placeholder_tx['tx'].get_vsize()519replacement_required_fee = get_fee(replacement_expected_size, incremental_setting_decimal) + replacee_tx['fee']521# Show that replacement fails when paying 1 satoshi shy of the required fee522failed_replacement_tx = self.wallet.create_self_transfer(utxo_to_spend=confirmed_utxo, fee=replacement_required_fee - Decimal("0.00000001"), version=2, target_vsize=200)523assert_raises_rpc_error(-26, "insufficient fee", node.sendrawtransaction, failed_replacement_tx['hex'])524replacement_tx = self.wallet.create_self_transfer(utxo_to_spend=confirmed_utxo, fee=replacement_required_fee, version=2, target_vsize=200)526if incremental_setting == 0:527# When incremental relay feerate is 0, additional fees are not required, but higher feerate is still required.528assert_raises_rpc_error(-26, "insufficient fee", node.sendrawtransaction, replacement_tx['hex'])529replacement_tx_smaller = self.wallet.create_self_transfer(utxo_to_spend=confirmed_utxo, fee=replacement_required_fee, version=2, target_vsize=199)530node.sendrawtransaction(replacement_tx_smaller['hex'])531else:532node.sendrawtransaction(replacement_tx['hex'])534def test_fullrbf(self):535# BIP125 signaling is not respected537confirmed_utxo = self.make_utxo(self.nodes[0], int(2 * COIN))538assert self.nodes[0].getmempoolinfo()["fullrbf"]540# Create an explicitly opt-out BIP125 transaction, which will be ignored541optout_tx = self.wallet.send_self_transfer(542from_node=self.nodes[0],543utxo_to_spend=confirmed_utxo,544sequence=MAX_BIP125_RBF_SEQUENCE + 1,545fee_rate=Decimal('0.01'),546)547assert_equal(False, self.nodes[0].getmempoolentry(optout_tx['txid'])['bip125-replaceable'])549conflicting_tx = self.wallet.create_self_transfer(550utxo_to_spend=confirmed_utxo,551fee_rate=Decimal('0.02'),552)554# Send the replacement transaction, conflicting with the optout_tx.555self.nodes[0].sendrawtransaction(conflicting_tx['hex'], 0)557# Optout_tx is not anymore in the mempool.558assert optout_tx['txid'] not in self.nodes[0].getrawmempool()559assert conflicting_tx['txid'] in self.nodes[0].getrawmempool()561if __name__ == '__main__':562ReplaceByFeeTest(__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.