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.
751# Now find that address in each subsequent tx, and no other change752bumped_total_tx = rbf_node.bumpfee(rbfid, fee_rate=ECONOMICAL)753assert_equal(change_addresses, get_change_address(bumped_total_tx['txid'], rbf_node))754bumped_rate_tx = rbf_node.bumpfee(bumped_total_tx["txid"])755assert_equal(change_addresses, get_change_address(bumped_rate_tx['txid'], rbf_node))756self.clear_mempool()759def spend_one_input(node, dest_address, change_size=Decimal("0.00049000"), data=None, dest_amount=Decimal("0.00050000")):760tx_input = dict(761sequence=MAX_BIP125_RBF_SEQUENCE, **next(u for u in node.listunspent() if u["amount"] == Decimal("0.00100000")))762destinations = {dest_address: dest_amount}763if change_size > 0:764destinations[node.getrawchangeaddress()] = change_size765if data:766destinations['data'] = data767rawtx = node.createrawtransaction([tx_input], destinations)768signedtx = node.signrawtransactionwithwallet(rawtx)769txid = node.sendrawtransaction(signedtx["hex"])770return txid773def test_no_more_inputs_fails(self, rbf_node, dest_address):774self.log.info('Test that bumpfee fails when there are no available confirmed outputs')775# feerate rbf requires confirmed outputs when change output doesn't exist or is insufficient776self.generatetoaddress(rbf_node, 1, dest_address)777# spend all funds, no change output778rbfid = rbf_node.sendall(recipients=[rbf_node.getnewaddress()])['txid']779assert_raises_rpc_error(-4, "Unable to create transaction. The total exceeds your balance when the 0.00001051 transaction fee is included.", rbf_node.bumpfee, rbfid)780self.clear_mempool()783def test_feerate_checks_replaced_outputs(self, rbf_node, peer_node):784# Make sure there is enough balance785peer_node.sendtoaddress(rbf_node.getnewaddress(), 60)786self.generate(peer_node, 1)788self.log.info("Test that feerate checks use replaced outputs")789outputs = []790for i in range(50):791outputs.append({rbf_node.getnewaddress(address_type="bech32"): 1})792tx_res = rbf_node.send(outputs=outputs, fee_rate=5)793tx_details = rbf_node.gettransaction(txid=tx_res["txid"], verbose=True)795# Calculate the minimum feerate required for the bump to work.796# Since the bumped tx will replace all of the outputs with a single output, we can estimate that its size will 31 * (len(outputs) - 1) bytes smaller797tx_size = tx_details["decoded"]["vsize"]798est_bumped_size = tx_size - (len(tx_details["decoded"]["vout"]) - 1) * 31799inc_fee_rate = rbf_node.getmempoolinfo()["incrementalrelayfee"]800# RPC gives us fee as negative801min_fee = (-tx_details["fee"] + get_fee(est_bumped_size, inc_fee_rate)) * Decimal(1e8)802min_fee_rate = (min_fee / est_bumped_size).quantize(Decimal("1.000"))804# Attempt to bumpfee and replace all outputs with a single one using a feerate slightly less than the minimum805new_outputs = [{rbf_node.getnewaddress(address_type="bech32"): 49}]806assert_raises_rpc_error(-8, "Insufficient total fee", rbf_node.bumpfee, tx_res["txid"], {"fee_rate": min_fee_rate - 1, "outputs": new_outputs})808# Bumpfee and replace all outputs with a single one using the minimum feerate809rbf_node.bumpfee(tx_res["txid"], {"fee_rate": min_fee_rate, "outputs": new_outputs})810self.clear_mempool()813def test_bumpfee_with_feerate_ignores_walletincrementalrelayfee(self, rbf_node, peer_node):814self.log.info('Test that bumpfee with fee_rate ignores walletincrementalrelayfee')815# Make sure there is enough balance816peer_node.sendtoaddress(rbf_node.getnewaddress(), 2)817self.generate(peer_node, 1)819dest_address = peer_node.getnewaddress(address_type="bech32")820tx = rbf_node.send(outputs=[{dest_address: 1}], fee_rate=2)822# Ensure you can not fee bump with a fee_rate below or equal to the original fee_rate823assert_raises_rpc_error(-8, "Insufficient total fee", rbf_node.bumpfee, tx["txid"], {"fee_rate": 1})824assert_raises_rpc_error(-8, "Insufficient total fee", rbf_node.bumpfee, tx["txid"], {"fee_rate": 2})826# Ensure you can not fee bump if the fee_rate is more than original fee_rate but the additional fee does827# not cover incrementalrelayfee for the size of the replacement transaction828assert_raises_rpc_error(-8, "Insufficient total fee", rbf_node.bumpfee, tx["txid"], {"fee_rate": 2.09})830# You can fee bump as long as the new fee set from fee_rate is at least (original fee + incrementalrelayfee)831rbf_node.bumpfee(tx["txid"], {"fee_rate": 2.1})832self.clear_mempool()835if __name__ == "__main__":836BumpFeeTest(__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.