What Is RBF – Replace By Fee?

replace by fee

Share this article

When you perform a bitcoin transaction, it needs to be verified by the bitcoin network before it can be completed. This verification process is done by a node that broadcasts the transaction to the network. If the transaction meets bitcoin consensus requirements and the fees are attractive, miners will pick it up and add it to the next block. Once a miner has won a block and confirmed the transactions to the blockchain, the settlement is final and cannot be reversed.

If the transaction has not gone through this entire process, it is not included in a block and is considered unconfirmed and stays in the network’s mempool along with other unconfirmed transactions. Most Bitcoin wallets will not let you spend unconfirmed transactions, so you will need to wait for a miner to include your transaction in a block before it can be completed.

If your transaction has not been finalised, you can still make changes to it using the Replace-By-Fee (RBF) feature. Replace-By-Fee (RBF) is a node policy that allows an unconfirmed transaction in a mempool to be replaced with a different transaction that spends at least one of the same inputs and pays a higher transaction fee.

What is replace-by-fee?

In bitcoin, RBF allows the sender to replace this transaction with another similar transaction which pays a higher fee. This mechanism exists so users can respond if the network becomes congested and fees rise unexpectedly. If a user sends a transaction with a low fee and finds that it is taking too long to confirm, they can adjust the fee upwards to make their transaction more attractive for miners.

Once the new transaction has propagated the network, the previous one is invalidated by sharing the same entries. 

How does replace-by-fee work?

Opt-in RBF is a change to the memory pool and network relay code that allows those wallets to optionally add a signal to their transactions which tells full nodes that those particular transactions may be updated (replaced) up until the point that they get confirmed in a new block.

Different node software can use different RBF rules, and there have been several variations available.

The most common form of RBF today is BIP125 opt-in RBF implemented in Bitcoin Core 0.12.0 and subsequent versions. This allows the transaction creators to signal that they’re willing to allow it to be replaced by a higher-paying version.

An alternative form of RBF is full-RBF which allows any transaction to be replaced whether or not it signals BIP125 replaceability. BIP125 requires a replacement transaction to pay both a higher fee rate (BTC/vbyte) and a higher absolute fee (total BTC).

What are the conditions for using replace-by-fee?

RBF only works while the transaction is in the mempool and soon as a transaction enters a block, it cannot be replaced by fee. Additionally, the original transaction that was first sent, it must specify that it is available to be replaced by fee in the future.

This is achieved by setting the nSequence, a small part of each transaction, to any value below 0xfffffffe. The nSequence of a transaction is intended to allow a transaction to be updated after it has been broadcast.

For RBF to occur, transactions must meet the following conditions:

  1. Original transactions must not be confirmed. And they must indicate their replaceability explicitly or through inheritance. That is, if any of the entries in the original transaction has an nSequence number less than (0xffffffff – 1). Or, that its predecessor transactions indicate replacement ability (inheritance).
  2. The new transaction created for replacement can only include an unconfirmed entry if it was included in the original transaction.
  3. The commission for the new transaction is higher than the original transaction.
  4. When the number of transactions to replace does not exceed 100 of them.
  5. Transaction replacement is an optional process.

Why would you use replace-by-fee?

The most popular use for RBF is speeding up bitcoin transaction clearing times. Suppose you generated a bitcoin transaction and set a fee. Still, instead of the usual 10 minutes to confirmation, you’ve waited longer, but your transaction has not been secured in a new block and dwells in the mempool. You check the current fee rate in your block explorer and see that fees are double what you set to get into the next block.

Since your transaction is time sensitive, you broadcast a new one with a higher fee to encourage miners to add it to the next block.

Another use for RBF is to spare your blushes should you have committed a transaction to the wrong address and noticed in time. You could replace the old transaction with a new one so that your funds are sent to the intended address and not the mistaken one.

What are the risks of replace-by-fee?

Since RBF is not only to increase fees, but you can also replace the entire transaction, there is the option to reverse a transaction within a short period. To give you an idea, let’s consider the following:

Alice will purchase some items from Bob, so she sends him 1 BTC with 0.0001 BTC as fees for the miners. After a couple of minutes, Alice changes her mind and wants her money back. Hence, as the transaction is still unconfirmed, she decides to replace the original transaction with a new one with a higher fee and change the receiving address to one she owns and send the funds back to her wallet.

In the meantime, Bob has already shipped the items to Alice’s address. In this case, Alice can effectively defraud bob since he acted before waiting for complete confirmation. When dealing with bitcoin transactions, it’s always essential to wait for a confirmation or, better yet, several confirmations before you are confident that funds have been cleared.

Do your own research.

If you want to learn more about replace-by-fee on bitcoin, use this article as a jumping-off point and don’t trust what we say as the final say. Take the time to research other sources, and you can start by checking out the resources below.

Do you take self-custody of your stack?

If you’re new to bitcoin and have not ventured down the self-custody rabbit hole, what is stopping you? If you’re already self-sovereign, how has the experience been since you took hold of your funds? Let us know in the comments down below. We’re always keen to hear from bitcoiners from around the world.

Disclaimer: This article should not be taken as, and is not intended to provide any investment advice. It is for educational and entertainment purposes only. As of the time posting, the writers may or may not have holdings in some of the coins or tokens they cover. Please conduct your own thorough research before investing in any cryptocurrency, as all investments contain risk. All opinions expressed in these articles are my own and are in no way a reflection of the opinions of The Bitcoin Manual

Leave a Reply

Related articles

You may also be interested in

Etching runes drive up on-chain fees

Rune Etching Mania Spiking Fees

The Bitcoin blockchain has just undergone its fifth halving event, marking a significant shift in the network’s ability to satisfy any growing demand for the

Cookie policy
We use our own and third party cookies to allow us to understand how the site is used and to support our marketing campaigns.