Replace by Fee (RBF) is a Bitcoin protocol feature that allows a sender to replace an unconfirmed transaction with a new transaction that pays a higher fee.
Here's how it works:
- A sender creates a transaction and broadcasts it to the Bitcoin network.
- The transaction is added to the memory pool (mempool) and is waiting to be confirmed by a miner.
- If the sender wants to increase the priority of the transaction, they can use the RBF feature to replace the original transaction with a new one that includes a higher fee.
- The sender creates a new transaction with the same inputs (the same bitcoins) and outputs (the same amount of bitcoins as the original transaction), but with a higher fee.
- The sender sends the new transaction to the network, and it is added to the mempool.
- If the miner who is confirming the second transaction (the new one with the higher fee) also confirms the original transaction (the one with the lower fee), the network will use the new transaction with the higher fee instead of the original one.
Now, let's say a second identical transaction (with the same inputs and outputs) but with a higher fee is broadcast to the network while the first transaction is still in the mempool unconfirmed. In this case, the network will use the second transaction with the higher fee instead of the first one.
Here's why: when the second transaction with the higher fee is broadcast, it becomes the "replacement transaction." The network will use the replacement transaction instead of the original transaction, even if the original transaction has a lower fee. This is because the sender has explicitly instructed the network to prioritize the replacement transaction by paying a higher fee.
The difference between the RBF and "Full RBF" features is that RBF only replaces the transaction with a new one that has the same inputs and outputs, while Full RBF replaces the transaction with a new one that has different inputs and outputs.
Here's an example to illustrate the difference:
Let's say Alice wants to send 1 BTC to Bob, and she creates a transaction with a fee of 0.001 BTC. If Bob also wants to send 1 BTC to Charlie, and he creates a transaction with a fee of 0.005 BTC, Alice can use the RBF feature to replace her original transaction with Bob's transaction (which has a higher fee). The new transaction will have the same inputs (Alice's bitcoins) and outputs (Bob's bitcoins), but with a higher fee.
On the other hand, if Bob wants to send 2 BTC to Charlie, and he creates a new transaction with different inputs (2 BTC from Alice) and outputs (Charlie's bitcoins), Alice cannot use the Full RBF feature to replace Bob's original transaction with her new transaction. The new transaction will have different inputs and outputs, and Alice cannot replace a transaction that has different inputs and outputs with a new one.
In summary, RBF allows a sender to replace an unconfirmed transaction with a new one that has the same inputs and outputs but with a higher fee, while Full RBF allows a sender to replace an unconfirmed transaction with a new one that has different inputs and outputs.