<h2>Replacement transaction using unconfirmed inputs</h2>
<blockquote>
<p>Which from what I deduce, it basically means that a replacement transaction can only have one input of an unconfirmed transaction output. Is my understanding correct?</p>
</blockquote>
<p>The phrasing of BIP125#2 may not be the clearest. The short answer is that, no, this is not correct; specifically, a replacement transaction can have more than one unconfirmed input[1].</p>
<p>However, BIP125#2 requires that each of those unconfirmed inputs must be one of those that the transaction(s)[2] you are replacing has as an input.</p>
<h2>Bypassing BIP125#2 with a 1-input 1-output transaction</h2>
<p>Reproducing the scenario from <a href="https://github.com/bitcoin/bitcoin/pull/23121#issuecomment-929475999" rel="nofollow noreferrer">the comment</a> in question:</p>
<p><code>A</code> and <code>B</code> are unconfirmed transactions in a mempool.</p>
<p>A user wants to replace <code>A</code> with a transaction <code>C</code> by spending at least one of the UTXOs that <code>A</code> is attempting to spend[3].</p>
<h3>Case 1</h3>
<p>The user wants <code>C</code> to spend an unconfirmed output from <code>B</code>, perhaps to assist with increasing the fee-rate of <code>C</code> compared to <code>A</code>. However, according to BIP125#2, <code>C</code> can not have an unconfirmed input that is not one of the inputs of <code>A</code>. So <code>C</code> can not spend the unconfirmed output of <code>B</code>.</p>
<h3>Case 2</h3>
<p>Knowing the limitations in Case 1, the user instead creates a new intermediate 1-input 1-output transaction <code>C*</code> that just spends an unconfirmed output from <code>B</code>. Now, the user can construct a transaction <code>C</code> that replaces both <code>A</code> and <code>C*</code>. Supposing that the fees are sufficient, this is now possible to do as the only unconfirmed inputs of <code>C</code> are from the transactions it is replacing, namely, <code>A</code> and <code>C</code>.</p>
<p>Once replaced, we have the effect of <code>C</code> having replaced <code>A</code> <em>and</em> spending an unconfirmed output of <code>B</code>.</p>
<hr />
<p>[1]: An unconfirmed input is any input spending an unconfirmed UTXO. (Stated in parentheses in BIP125#2).</p>
<p>[2]: You can replace more than one transaction with a single transaction.</p>
<p>[3]: <em><strong>Not</strong></em> one of its outputs as this wouldn't be a replacement. We're talking about actually &quot;double-spending&quot; <code>A</code> here. At the end of a replacement, <code>A</code> should no longer be in the mempool as the two transactions conflict.</p>

CC BY-SA 4.0
2023-03-31T18:25:39.197Z
2023-04-10T09:04:34.360Z
2023-04-10T09:04:34.360Z
dunxen
<p>I was reading <a href="https://gist.github.com/glozow/25d9662c52453bd08b4b4b1d3783b9ff#sighash_anyonecanpay-pinning" rel="nofollow noreferrer">this</a> github gist about rbf improvements written by glozow. I had difficulty understanding parts of it.
The main confusion I have is for this paragraph:</p>
<blockquote>
<p>BIP125#2 can be bypassed by creating intermediary transactions to be replaced together. Anyone can simply split a 1-input 1-output transaction off from the replacement transaction, then broadcast the transaction as is. This can always be done, and quite cheaply. More details in <a href="https://github.com/bitcoin/bitcoin/pull/23121#issuecomment-929475999" rel="nofollow noreferrer">this comment</a>.</p>
</blockquote>
<p>The <a href="https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki#implementation-details" rel="nofollow noreferrer">BIP125#2</a> is:</p>
<blockquote>
<p>The replacement transaction may only include an unconfirmed input if that input was included in one of the original transactions. (An unconfirmed input spends an output from a currently-unconfirmed transaction.)</p>
</blockquote>
<p>Which from what I deduce, it basically means that a replacement transaction can only have one input of an unconfirmed transaction output. Is my understanding correct?</p>
<p>I also have taken a look on the comment glozow mentioned in the gist, but that doesn't helped me understanding how is it possible for one to bypass the restriction. Can someone explain it in simple language to me?</p>
<p>Thanks in advance</p>

<mempool><replace-by-fee>
How is it possible to bypass bip125#2?
Amir reza Riahi
# How is it possible to bypass bip125#2?

(Asked by: username_0 on 2023-03-24)

I was reading [this](https://gist.github.com/glozow/25d9662c52453bd08b4b4b1d3783b9ff#sighash_anyonecanpay-pinning) github gist about rbf improvements written by glozow. I had difficulty understanding parts of it.
The main confusion I have is for this paragraph:

> BIP125#2 can be bypassed by creating intermediary transactions to be replaced together. Anyone can simply split a 1-input 1-output transaction off from the replacement transaction, then broadcast the transaction as is. This can always be done, and quite cheaply. More details in [this comment](https://github.com/bitcoin/bitcoin/pull/23121#issuecomment-929475999).

The [BIP125#2](https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki#implementation-details) is:

> The replacement transaction may only include an unconfirmed input if that input was included in one of the original transactions. (An unconfirmed input spends an output from a currently-unconfirmed transaction.)

Which from what I deduce, it basically means that a replacement transaction can only have one input of an unconfirmed transaction output. Is my understanding correct?

I also have taken a look on the comment glozow mentioned in the gist, but that doesn't helped me understanding how is it possible for one to bypass the restriction. Can someone explain it in simple language to me?

Thanks in advance

**Tags:** mempool, replace-by-fee


---

## 1 answers

### Answer by username_1 on 2023-03-31. Score: 4 | Accepted answer

## Replacement transaction using unconfirmed inputs

> Which from what I deduce, it basically means that a replacement transaction can only have one input of an unconfirmed transaction output. Is my understanding correct?

The phrasing of BIP125#2 may not be the clearest. The short answer is that, no, this is not correct; specifically, a replacement transaction can have more than one unconfirmed input[1].

However, BIP125#2 requires that each of those unconfirmed inputs must be one of those that the transaction(s)[2] you are replacing has as an input.

## Bypassing BIP125#2 with a 1-input 1-output transaction

Reproducing the scenario from [the comment](https://github.com/bitcoin/bitcoin/pull/23121#issuecomment-929475999) in question:

`A` and `B` are unconfirmed transactions in a mempool.

A user wants to replace `A` with a transaction `C` by spending at least one of the UTXOs that `A` is attempting to spend[3].

### Case 1

The user wants `C` to spend an unconfirmed output from `B`, perhaps to assist with increasing the fee-rate of `C` compared to `A`. However, according to BIP125#2, `C` can not have an unconfirmed input that is not one of the inputs of `A`. So `C` can not spend the unconfirmed output of `B`.

### Case 2

Knowing the limitations in Case 1, the user instead creates a new intermediate 1-input 1-output transaction `C*` that just spends an unconfirmed output from `B`. Now, the user can construct a transaction `C` that replaces both `A` and `C*`. Supposing that the fees are sufficient, this is now possible to do as the only unconfirmed inputs of `C` are from the transactions it is replacing, namely, `A` and `C`.

Once replaced, we have the effect of `C` having replaced `A` *and* spending an unconfirmed output of `B`.

---

[1]: An unconfirmed input is any input spending an unconfirmed UTXO. (Stated in parentheses in BIP125#2).

[2]: You can replace more than one transaction with a single transaction.

[3]: ***Not*** one of its outputs as this wouldn't be a replacement. We're talking about actually "double-spending" `A` here. At the end of a replacement, `A` should no longer be in the mempool as the two transactions conflict.


---

