Replace By Fee and Double spending in Bitcoin
Tags: bitcoin
Published: 2020-03-21 22:00:08

---
title: Replace By Fee and Double spending in Bitcoin
published: true
date: 2020-03-21 21:53:02 UTC
tags: Bitcoin,bitcoin
canonical_url: https://blog.coincodecap.com/what-is-replace-by-fee-in-bitcoin/?utm_source=rss&utm_medium=rss&utm_campaign=what-is-replace-by-fee-in-bitcoin
---

In this article, we will be focusing on Bitcoin’s Replace By Fee ( also known as RBF). This feature was proposed in [BIP125](https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki) and implemented in [Bitcoin](https://blog.coincodecap.com/tag/bitcoin/) Core 0.12.0. It has seen a lot of controversies and is open to debate. So, let’s dive in.

> **Also Read: [A Candid Explanation of Bitcoin](https://blog.coincodecap.com/a-candid-explanation-of-bitcoin/)**

## What is Replace By Fee?

In simple words, by enabling RBF in a transaction, if a transaction doesn’t get mined, it can be resent by the sender with a higher mining fee with keeping the input data of the UTXO(Unspent Transaction Output) same as before.

Let’s understand RBF using an example.

Consider two people named Alice and Bob. Alice is in urgent need of Bitcoins, so he asks Bob to send 1 BTC. 

Bob is willing to pay 0.000001 BTC as the mining fees. So, he signs the transaction and waits for it to get mined by the miners. Hours passed by, but the transaction didn’t get confirmed. 

> **Also Read: [What is Bitcoin mining?](https://blog.coincodecap.com/what-is-bitcoin-mining-and-how-it-works/)**

After 72 hours, Bob came to know that miners didn’t pick his transaction. There are two possible reasons for miner not picking a transaction.

Note: When you create a Bitcoin transaction, it goes into Mempool. Transactions reside in Mempool before miners pick them.

### **Low Transaction Fee**

In the Bitcoin network, there are certain limitations. The block size cannot exceed 2 MB. Each miner gets 12.5 BTC for successfully mining a block along with the mining fees. So, Miners usually pick transactions that have a high mining fee to maximize their profit and to compensate for the resources used during mining. If a transaction does not have enough mining fees, it will be rejected by the miners.

### **Mempool has a lot of transaction**

Let’s say a lot of people started buying bitcoin, and the mempool gets loaded with a tremendous amount of transaction data. To make the transaction faster, many would bet high transaction fees. 

So, in those cases, transactions with moderate transaction fees will not be picked by bitcoin miners.

Now, let’s say Bob has enabled the Replace By Fee feature(Which is provided by most of the [bitcoin wallets](https://blog.coincodecap.com/tag/bitcoin-wallet/)) while signing the transaction. Initially, he sends 0.000001 BTC as mining fees. His transaction didn’t get mined. Since he had enabled RBF, he now has the option to use the same inputs of the UTXO to make another transaction with a higher mining fee. 

As this is an emergency, So Bob decides to hike the transaction fee to 0.001 BTC. This time the transaction was mined because the miners found the mining fees lucrative.

## What are the different types of RBF?

- **Full RBF: ** This allows a transaction to be replaced with a new transaction as long as the mining fee associated with it is sufficient.
- **Opt-in RBF: ** RBF can be optional in some cases. It usually depends on the wallet you are using. You have the option to either enable RBF or not.
- **First-seen-safe RBF: ** In this case, one is allowed to initiate another transaction with a higher fee only if the transaction data in the new one is identical to the older one.

> [**Bitcoin wallets with the RBF feature**](https://blog.coincodecap.com/best-btc-wallets-for-android/)

## **Double spending with RBF**

Suppose a malicious user has ordered an item from an online shop, and he paid using bitcoin (RBF enabled) with a low transaction fee. He informs the shop keeper that the transaction will be approved soon. 

So, the shopkeeper sents the item hoping that the transaction will be mined. Considering the malicious user used Full RBF or Opt-in-RBF, he can use the same input of the UTXO to send the same amount to his own account. This leads to double-spending.

<iframe title="Bitcoin Double-Spend Tool Now Available to All: Interview w/ Glass Hunt's Hackers" width="640" height="360" src="https://www.youtube.com/embed/ysVCU1b-UBA?start=376&amp;feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

The above video highlights the problem with RBF. That’s why RBF has been criticized hugely. So, it is highly advised to wait for at least six confirmations to consider a transaction is valid and be cautious about transactions marked with RBF.

Let us know your opinion about the Replace by Fee feature in Bitcoin and should every wallet enable it?
.

**Also Read** :

- **[Best Crypto Wallets [2020]](https://blog.coincodecap.com/best-crypto-wallets-app/)**
- **[What is Bitcoin and How Bitcoin Works?](https://blog.coincodecap.com/what-is-bitcoin-and-how-it-works/)**
- **[An ultimate guide to Bitcoin Paper Wallet](https://blog.coincodecap.com/what-is-bitcoin-paper-wallet/)**
- [**Best hardware wallet to secure your bitcoin**](https://blog.coincodecap.com/best-hardware-wallet-bitcoin/)


The post [Replace By Fee and Double spending in Bitcoin](https://blog.coincodecap.com/what-is-replace-by-fee-in-bitcoin/) appeared first on [CoinCodeCap Blog](https://blog.coincodecap.com).