<p>NBitcoin just follow BIP125</p>

<pre><code>public bool RBF
{
    get
    {
        return Inputs.Any(i =&gt; i.Sequence &lt; 0xffffffff - 1);
    }
}
</code></pre>

<p>If you are using the <code>TransactionBuilder</code> for creating a transaction, you have two ways:</p>

<p>One is to use <code>TransactionBuilder.SetLockTime(blockHeight)</code> where block height is the <code>currentHeight-1</code> (actually, if you put 0 it will be fine as well)</p>

<p>The other way is to build your transaction without signing first with <code>TransactionBuilder.BuildTransaction(false)</code> change one of the input sequence, then use <code>TransactionBuilder.SignTransaction</code> to sign.</p>

CC BY-SA 3.0
2017-10-21T09:40:06.700Z
2017-10-21T09:40:06.700Z
Nicolas Dorier
<p>TransactionBuilder API has an easier way now to set RBF on, simply:</p>
<pre><code>myTransactionBuilder.OptInRBF = true
</code></pre>

CC BY-SA 4.0
2020-11-08T09:18:12.573Z
2020-11-08T09:18:12.573Z
knocte
<p>According to <a href="https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki#summary" rel="nofollow noreferrer">BIP 125</a>: </p>

<blockquote>
  <p>Explicit signaling: A transaction is considered to have opted in to
  allowing replacement of itself if any of its inputs have an nSequence
  number less than (0xffffffff - 1). </p>
  
  <p>Inherited signaling: Transactions
  that don't explicitly signal replaceability are replaceable under this
  policy for as long as any one of their ancestors signals
  replaceability and remains unconfirmed.</p>
</blockquote>

<p>Does one of the inputs on your tx have a sequence number less than <code>0xffffffff - 1</code>?</p>

CC BY-SA 3.0
2016-11-24T23:35:40.650Z
2016-11-24T23:35:40.650Z
Chris Stewart
<p>I have a few transactions staying unconfirmed - been a few days now. </p>

<p>I suspect the minimum  mining fee was upped - 15 minutes prior I was still doing hundreds of transactions a day at that fee - but now it is not enough.</p>

<p>All documentation indicates this is an easy process - simply use the same TX as you used earlier.</p>

<p>I am now feeling that this is more involved.</p>

<p>I took the unconfirmed TX - and goot its prev_hash.</p>

<p>I loaded the TX of this prev_hash and resubmitted it to BlockCypher - and get the message :</p>

<pre><code>Error sending transaction: Unable to lock an input of transactions xxx, likely already spent by yyy..   
</code></pre>

<p>It correctly identifies that unconfirmed transaction in yyy placeholder.</p>

<p>Thus it does not want to spend it as its already spent.</p>

<p>Now there is a Readonly RBF property on NBitcoin.Transaction class.</p>

<p>RBF means "Replace by Fee" which is what I want to do - but I can't set it as it is read only.</p>

<p>How do I go about to indicate this is a RBF?</p>

<doublespend><nbitcoin>
NBitcoin - how to set RBF to true in order to give higher fee for transaction
Peter PitLock
# NBitcoin - how to set RBF to true in order to give higher fee for transaction

(Asked by: username_0 on 2016-11-24)

I have a few transactions staying unconfirmed - been a few days now.

I suspect the minimum mining fee was upped - 15 minutes prior I was still doing hundreds of transactions a day at that fee - but now it is not enough.

All documentation indicates this is an easy process - simply use the same TX as you used earlier.

I am now feeling that this is more involved.

I took the unconfirmed TX - and goot its prev\_hash.

I loaded the TX of this prev\_hash and resubmitted it to BlockCypher - and get the message :

```
Error sending transaction: Unable to lock an input of transactions xxx, likely already spent by yyy..   

```

It correctly identifies that unconfirmed transaction in yyy placeholder.

Thus it does not want to spend it as its already spent.

Now there is a Readonly RBF property on NBitcoin.Transaction class.

RBF means "Replace by Fee" which is what I want to do - but I can't set it as it is read only.

How do I go about to indicate this is a RBF?

**Tags:** doublespend, nbitcoin


---

## 3 answers

### Answer by username_1 on 2017-10-21. Score: 1

NBitcoin just follow BIP125

```
public bool RBF
{
    get
    {
        return Inputs.Any(i => i.Sequence < 0xffffffff - 1);
    }
}

```

If you are using the `TransactionBuilder` for creating a transaction, you have two ways:

One is to use `TransactionBuilder.SetLockTime(blockHeight)` where block height is the `currentHeight-1` (actually, if you put 0 it will be fine as well)

The other way is to build your transaction without signing first with `TransactionBuilder.BuildTransaction(false)` change one of the input sequence, then use `TransactionBuilder.SignTransaction` to sign.


---

### Answer by username_2 on 2020-11-08. Score: 0

TransactionBuilder API has an easier way now to set RBF on, simply:

```
myTransactionBuilder.OptInRBF = true

```


---

### Answer by username_3 on 2016-11-24. Score: 0

According to [BIP 125](https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki#summary):

> Explicit signaling: A transaction is considered to have opted in to
> allowing replacement of itself if any of its inputs have an nSequence
> number less than (0xffffffff - 1).
>
> Inherited signaling: Transactions
> that don't explicitly signal replaceability are replaceable under this
> policy for as long as any one of their ancestors signals
> replaceability and remains unconfirmed.

Does one of the inputs on your tx have a sequence number less than `0xffffffff - 1`?


---

