Author

Topic: nSequence and opt-in ReplaceByFee: difference between maxint and maxint-1? (Read 630 times)

staff
Activity: 4326
Merit: 8951
Please try to get that code corrected. Lots of people copy and paste, and the pasted code can live for a long time.
staff
Activity: 3458
Merit: 6793
Just writing some code
Thanks!

Just to be sure: opt-in RBF is flagged by anything less than MAX_INT-2, so that's any value below 0xFFFFFFFD (but not 0xFFFFFFFD itself) ?

In that case, I'm wondering if there's any specific meaning to 0xFFFFFFFD, does that behave differently than 0xFFFFFFFE?
No, it includes MAX_INT - 2.

(edit) I happened to stumble upon some random code on github that is supposed to check a transaction for RBF-ability.
But it seems to check if (sequences !== 0xffffffff) which, if I understand you correctly, is plain wrong?
Yes, that is wrong.
newbie
Activity: 3
Merit: 0
Thanks!

Just to be sure: opt-in RBF is flagged by anything less than MAX_INT-2, so that's any value below 0xFFFFFFFD (but not 0xFFFFFFFD itself) ?

In that case, I'm wondering if there's any specific meaning to 0xFFFFFFFD, does that behave differently than 0xFFFFFFFE?

(edit) I happened to stumble upon some random code on github that is supposed to check a transaction for RBF-ability.
But it seems to check if (sequences !== 0xffffffff) which, if I understand you correctly, is plain wrong?
staff
Activity: 3458
Merit: 6793
Just writing some code
MAX_INT (0xFFFFFFFF) indicates a transaction is final, which means that that transaction is a normal transaction. MAX_INT - 1 (0xFFFFFFFE) signals that that transaction is not final and that the transaction can have a locktime. The locktime prevents the transaction from confirming until a specific time or block height. It also indicates that if there is an OP_CLTV in an input script that that script can be evaluated. However it does not signal Opt-in RBF. Anything less than MAX_INT -2 (0xFFFFFFFD) signals that the transaction can be replaced in the mempool (opt-in RBF) and if it has a locktime, that locktime should be evaluated.
newbie
Activity: 3
Merit: 0
If I understood correctly, an nSequence below 4294967294 (or 0xFFFFFFFE in hex) indicates the transaction as opt-in RBF. However there are many transactions with nSequence 4294967294 or 4294967295 (0xFFFFFFFE or 0xFFFFFFFF respectively). What's the meaning of these two nSequence values? I thought 0xFFFFFFFF (i.e. max uint) used to be the default for regular transactions. Why are there also many txs with 0xFFFFFFFE (i.e. max uint -1) ?

When I look at recent transactions, e.g. unconfirmed ones in the mempool, or txs that were confirmed in recent blocks, I'd say about 50% has nSequence=0xFFFFFFFE and 50% has nSequence=0xFFFFFFFF. However for older transactions (like 1 year or even further back) practically 100% of all txs have nSequence=0xFFFFFFFF. What's up with that?

Or am I mistaken, and does nSequence=0xFFFFFFFE (rather than below 0xFFFFFFFE) represent the opt-in RBF flag?
Jump to: