<p>For a replacement to be accepted into the mempool, it has to improve the mempool for miners. Therefore, it has to pay more fees than all the ousted transactions, additionally must pay for its own relay, and finally cannot oust too many transactions at once. Specifically:</p>
<ul>
<li>If the node works in Opt-in Full RBF mode, the directly conflicting transactions must all signal replaceability, otherwise the replacement attempt fails.</li>
<li>The replacement transaction must pay at least as much fees as all replaced transactions (including the descendants of the directly conflicting transactions!) <strong>plus</strong> its own vsize times the node’s <em>incremental relay feerate</em>.</li>
<li>The replacement transaction does not spend any new unconfirmed inputs that were not already spent by one of the directly conflicting transactions.</li>
<li>The replacement transaction must pay a greater feerate than each directly conflicting transaction</li>
<li>The sum of the conflicting transactions' descendant counts doesn’t exceed 100.</li>
</ul>
<p>You can read more about this topic for example in the policy documentation for <a href="https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md" rel="noreferrer">Mempool Replacements</a> for Bitcoin Core, and in glozow’s gist collecting her thoughts on <a href="https://gist.github.com/glozow/25d9662c52453bd08b4b4b1d3783b9ff" rel="noreferrer">RBF Improvements</a>.</p>
<p>This answer omits FSS RBF, because I am not aware of any nodes implementing that policy on the network.</p>

CC BY-SA 4.0
2023-12-05T23:04:56.177Z
I have 2 small questions. 1) Isn't 5th condition redundant/unnecessary since with 3rd condition you already satisfy it? 2) In last, 6th, condition you only mentioned that the sum of all descendant of all confliction transactions can't exceed 100. However, you didn't mention the conflicting transactions themselves. In the material you linked they say `The number of original transactions does not exceed 100.` and by *original transaction* they denote **conflict transaction + its descendants**, so I would say that the sum of all confliction transaction + their descendants can't exceed 100?
LeaBit
CC BY-SA 4.0
2023-12-05T23:14:33.553Z
I just saw that [glozow's gist collection](https://gist.github.com/glozow/25d9662c52453bd08b4b4b1d3783b9ff) doesn't even mention the 5th condition, only the 3rd one. I guess then the answer to my first question is *yes*, i.e., it is redundant/unnecessary.
LeaBit
CC BY-SA 4.0
2023-12-06T01:06:23.340Z
A transaction’s descendant count always includes the transaction itself. So, the sum of multiple transactions descendant count is potentially an overestimate, if they have overlapping descendants. What do you mean with "3rd and 5th condition"? My list has only five bulletpoints, but what you call "6th condition" appears to refer to the last bulletpoint. If you are referring to the rule about absolute fees and the rule about feerates, you should consider how things play out when transactions have differing sizes, i.e. what if the replacement is larger or smaller than the originals?
Murch
CC BY-SA 4.0
2023-12-06T01:48:44.247Z
1) If two (three or more) directly conflicting transactions have some same/overlapping descendants, that descendants will be count as 2 (3 or more), not just as 1?
LeaBit
CC BY-SA 4.0
2023-12-06T01:48:53.800Z
2) Sorry, I did not denote it good. By this question I actually refer to 2nd and 4th bulletpoints (conditions). If I understood correctly, you want to say that even if the fee of the replacement transaction (calculated by rules from 2nd bulletproof) is bigger than the sum of all fees (directly conflicting transaction + their descendants), in case when replacement transaction is too big it can still have smaller feerate than some of directly conflicting transaction. So 5th bulletproof is also required.
LeaBit
CC BY-SA 4.0
2023-12-06T02:40:25.233Z
Yes, if the transactions A, B, and C are all ancestors of a transaction D, and R replaces A, B, and C, their sum of descendant counts would be 6 in context of this check. You got it right: If R is bigger than A+B+C+D, even if it pays a total higher fee than A+B+C+D + vsize(R)×incrementalRelayFeeRate, R's feerate may still be lower than one of A, B, or C—so both the absolute fee and the feerate criteria are needed to ensure that the mempool is getting more attractive to miners.
Murch
CC BY-SA 4.0
2023-12-06T09:07:20.830Z
All clear, thanks
LeaBit
CC BY-SA 4.0
2023-12-04T23:47:12.237Z
2023-12-04T23:53:45.140Z
2023-12-04T23:53:45.140Z
Murch
<p>RBF (Full RBF, Opt-in Full RBF, FSS-RBF) is applied to a transaction when one of its inputs &quot;matches&quot; one of the inputs in the replacement transaction.</p>
<p>However, what happens if the inputs of a replacement transaction &quot;hit&quot; the inputs of two (three or more) different transactions?</p>
<ol>
<li><p>Does the replacement transaction then replace all those &quot;hit&quot; transactions (transactions covered by replacement)?</p>
</li>
<li><p>In order for replacement to occur, does the fee of replacement transaction have to be greater than the largest fee among all &quot;covered&quot; transactions, or perhaps the fee of replacement transaction must be greater than the sum of the fees of all &quot;covered&quot; transactions (or something else)?</p>
</li>
<li><p>What would happen if the node works in Opt-in Full RBF mode and some of the transactions &quot;included&quot; in replacement do not accept the possibility of replacement (nSequence of all inputs is <code>0xffffffff</code>)? I assume that the replacement then will not even occur and the replacement transaction will be just rejected.</p>
</li>
</ol>

<replace-by-fee>
What happens when two or more transactions are covered ("hit") by RBF?
LeaBit
# What happens when two or more transactions are covered ("hit") by RBF?

(Asked by: username_0 on 2023-12-04)

RBF (Full RBF, Opt-in Full RBF, FSS-RBF) is applied to a transaction when one of its inputs "matches" one of the inputs in the replacement transaction.

However, what happens if the inputs of a replacement transaction "hit" the inputs of two (three or more) different transactions?

1. Does the replacement transaction then replace all those "hit" transactions (transactions covered by replacement)?
2. In order for replacement to occur, does the fee of replacement transaction have to be greater than the largest fee among all "covered" transactions, or perhaps the fee of replacement transaction must be greater than the sum of the fees of all "covered" transactions (or something else)?
3. What would happen if the node works in Opt-in Full RBF mode and some of the transactions "included" in replacement do not accept the possibility of replacement (nSequence of all inputs is `0xffffffff`)? I assume that the replacement then will not even occur and the replacement transaction will be just rejected.

**Tags:** replace-by-fee


---

## 1 answers

### Answer by username_1 on 2023-12-04. Score: 6 | Accepted answer

For a replacement to be accepted into the mempool, it has to improve the mempool for miners. Therefore, it has to pay more fees than all the ousted transactions, additionally must pay for its own relay, and finally cannot oust too many transactions at once. Specifically:

* If the node works in Opt-in Full RBF mode, the directly conflicting transactions must all signal replaceability, otherwise the replacement attempt fails.
* The replacement transaction must pay at least as much fees as all replaced transactions (including the descendants of the directly conflicting transactions!) **plus** its own vsize times the node’s *incremental relay feerate*.
* The replacement transaction does not spend any new unconfirmed inputs that were not already spent by one of the directly conflicting transactions.
* The replacement transaction must pay a greater feerate than each directly conflicting transaction
* The sum of the conflicting transactions' descendant counts doesn’t exceed 100.

You can read more about this topic for example in the policy documentation for [Mempool Replacements](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md) for Bitcoin Core, and in glozow’s gist collecting her thoughts on [RBF Improvements](https://gist.github.com/glozow/25d9662c52453bd08b4b4b1d3783b9ff).

This answer omits FSS RBF, because I am not aware of any nodes implementing that policy on the network.

> **Comments:**
> **username_0**: I have 2 small questions. 1) Isn't 5th condition redundant/unnecessary since with 3rd condition you already satisfy it? 2) In last, 6th, condition you only mentioned that the sum of all descendant of all confliction transactions can't exceed 100. However, you didn't mention the conflicting transactions themselves. In the material you linked they say `The number of original transactions does not exceed 100.` and by *original transaction* they denote **conflict transaction + its descendants**, so I would say that the sum of all confliction transaction + their descendants can't exceed 100?  
> **username_0**: I just saw that [glozow's gist collection](https://gist.github.com/glozow/25d9662c52453bd08b4b4b1d3783b9ff) doesn't even mention the 5th condition, only the 3rd one. I guess then the answer to my first question is *yes*, i.e., it is redundant/unnecessary.  
> **username_1**: A transaction’s descendant count always includes the transaction itself. So, the sum of multiple transactions descendant count is potentially an overestimate, if they have overlapping descendants. What do you mean with "3rd and 5th condition"? My list has only five bulletpoints, but what you call "6th condition" appears to refer to the last bulletpoint. If you are referring to the rule about absolute fees and the rule about feerates, you should consider how things play out when transactions have differing sizes, i.e. what if the replacement is larger or smaller than the originals?  
> **username_0**: 1) If two (three or more) directly conflicting transactions have some same/overlapping descendants, that descendants will be count as 2 (3 or more), not just as 1?  
> **username_0**: 2) Sorry, I did not denote it good. By this question I actually refer to 2nd and 4th bulletpoints (conditions). If I understood correctly, you want to say that even if the fee of the replacement transaction (calculated by rules from 2nd bulletproof) is bigger than the sum of all fees (directly conflicting transaction + their descendants), in case when replacement transaction is too big it can still have smaller feerate than some of directly conflicting transaction. So 5th bulletproof is also required.  
> **username_1**: Yes, if the transactions A, B, and C are all ancestors of a transaction D, and R replaces A, B, and C, their sum of descendant counts would be 6 in context of this check. You got it right: If R is bigger than A+B+C+D, even if it pays a total higher fee than A+B+C+D + vsize(R)×incrementalRelayFeeRate, R's feerate may still be lower than one of A, B, or C—so both the absolute fee and the feerate criteria are needed to ensure that the mempool is getting more attractive to miners.  
> **username_0**: All clear, thanks  

---

