Reading the following BIPs: 68, 112, 125, I got a few questions about the sematics of sequence numbers. As far as I understood, in version 1 transactions, sequence numbers have the following meaning:
- If any input has a sequence less than
0xfffffffe
, than the whole transaction is signalling replaceability
On the other hand, in version >=2 transactions, the above rule applies, plus:
- If a sequence number has the disable flag (
1 << 31
) set to1
, then the sequence has no additional meaning (but can still be used to signal replaceability, right?) - If the disable flag is not set, then the sequence number is interpreted as a relative locktime with the format specified in BIP68. This means that transaction will not be included in a block until the output it spends reaches the specified age.
So, putting it all together, if one wants to signal replaceability in a version >=2 transaction, one can just use a sequence number which is less than 0xfffffffe
but has an active disable flag (i.e. is greater than 0x80000000
), on the other hand, how should one set the sequence number if one wants to both signal replaceability and also spend a relative timelocked output? Would it be ok to use a sequence number according to BIP68 and increase the bits that have no meaning in that format to replace the transaction? (i.e. changing all bits except 1 << 31
, 1 << 22
and 0xffff
)