Bitcoin Forum
July 04, 2024, 09:26:01 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: nSequence and opt-in ReplaceByFee: difference between maxint and maxint-1?  (Read 606 times)
Mike Lee Torris (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
February 27, 2016, 01:31:16 PM
 #1

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?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3444
Merit: 6745


Just writing some code


View Profile WWW
February 27, 2016, 03:31:36 PM
 #2

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.

Mike Lee Torris (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
February 27, 2016, 04:22:24 PM
 #3

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?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3444
Merit: 6745


Just writing some code


View Profile WWW
February 27, 2016, 04:52:52 PM
 #4

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.

gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4200
Merit: 8442



View Profile WWW
February 27, 2016, 08:41:47 PM
 #5

Please try to get that code corrected. Lots of people copy and paste, and the pasted code can live for a long time.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!