NBitcoin - how to set RBF to true in order to give higher fee for transaction

3

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?

Peter PitLock

Posted 2016-11-24T11:02:34.990

Reputation: 155

Answers

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.

Nicolas Dorier

Posted 2016-11-24T11:02:34.990

Reputation: 729

0

According to BIP 125:

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?

Chris Stewart

Posted 2016-11-24T11:02:34.990

Reputation: 975

0

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

myTransactionBuilder.OptInRBF = true

knocte

Posted 2016-11-24T11:02:34.990

Reputation: 1 581