MASTERING-BITCOIN ยท Unit 6 ยท Video 3 ยท Interactive Practice

Four Bytes, Three Lives: Bitcoin's Sequence Field

IKey Reference

Concept Encoding Meaning
Final 0xFFFFFFFF No replacement, no timelock
RBF disable, timelock disable 0xFFFFFFFE One below max โ€” reserved
Classic BIP 125 RBF signal 0xFFFFFFFD Replaceable, no timelock
BIP 68 disable flag bit 31 = 1 Timelock OFF for this input
BIP 68 type flag bit 22 = 0 / 1 Blocks / 512-second multiples
BIP 68 lock value bits 15..0 Up to 65,535 units
Time-mode unit 512 seconds โ‰ˆ 8.5 minutes per unit

IIVisualization 1: Sequence Field Decoder

The sequence field is a packed bitfield โ€” different bits carry different meanings. Pick a sequence value below and watch how the network interprets it.

Conceptual question: What information does a single 32-bit number actually communicate to Bitcoin nodes?

โš™ interactive visualization โ€” coming to this page format soon

Notice: the same four bytes change role entirely depending on a few key bits. 0xFFFFFFFD and 0x0000001E differ by billions in numeric value, but the network reads them as fundamentally different instructions.

IIIVisualization 2: BIP 68 Relative Timelock Encoder

Build your own relative timelock. Pick a mode (blocks or time) and a lock value, and watch the encoded sequence value emerge โ€” along with the real-world delay it imposes.

Conceptual question: Why does the time-mode unit of 512 seconds matter, and what's the tradeoff against block-mode?

โš™ interactive visualization โ€” coming to this page format soon

Reflect: Try setting the lock value to 65535 in both modes. The block mode caps near 455 days; time mode caps near 388 days. Both modes deliberately top out around one year โ€” that's the maximum relative lock Bitcoin's consensus rules allow on a single input.

IVQuiz

Question 1

A wallet wants to broadcast a transaction that signals classic BIP 125 opt-in replace-by-fee while keeping all timelock features disabled. Which sequence value should it set on its input?

โœ… Correct! 0xFFFFFFFD signals RBF while keeping timelocks disabled (bit 31 set).

โŒ Not quite. Remember: RBF is signaled when sequence is strictly less than 0xFFFFFFFE, and 0xFFFFFFFE itself is reserved.

Show solution

Solution:

BIP 125 says a transaction signals replaceability if any input has sequence below 0xFFFFFFFE. The standard choice is 0xFFFFFFFD โ€” the maximum minus two.

  • 0xFFFFFFFF is final (not replaceable).
  • 0xFFFFFFFE is reserved for "no RBF, timelock disabled" โ€” it does not signal RBF.
  • 0xFFFFFFFD is the classic BIP 125 signal: bit 31 is set, so the BIP 68 relative timelock disable flag is on, but the value is below the BIP 125 threshold so RBF is signaled.
  • 0x00000000 would signal RBF and activate a relative timelock (bit 31 = 0).

Question 2

In a BIP 68 relative timelock, what role does bit 22 of the sequence field play?

โœ… Correct! Bit 22 is the type flag selecting block-based vs. time-based locks.

โŒ Not quite. The disable flag is bit 31, not bit 22. Bit 22 picks the unit of the lock.

Show solution

Solution:

BIP 68 partitions the 32-bit sequence field as follows:

  • Bit 31 โ€” disable flag (1 = timelock OFF, 0 = timelock ON)
  • Bits 30..23 โ€” reserved
  • Bit 22 โ€” type flag (0 = blocks, 1 = 512-second units)
  • Bits 21..16 โ€” reserved
  • Bits 15..0 โ€” lock value (up to 65,535)

So bit 22 chooses between counting blocks or counting 512-second time units.

Question 3

A transaction input has sequence value 0x00400007. Bit 31 is 0 (timelock active), bit 22 is 1 (time mode), and the lower 16 bits hold the value 7.

Approximately how long after the funding output is confirmed does this input become spendable?

โœ… Correct! 7 ร— 512 s = 3,584 s โ‰ˆ 1 hour.

โŒ Not quite. Each time-mode unit is 512 seconds, not 1 second or 1 minute. Multiply 7 ร— 512 to get the delay in seconds.

Show solution

Solution:

In time mode, each unit equals 512 seconds.

7ร—512โ€…โ€Šs=3,584โ€…โ€Šsโ‰ˆ59.7โ€…โ€Šminutesโ‰ˆ1โ€…โ€Šhour7 \times 512\;\text{s} = 3{,}584\;\text{s} \approx 59.7\;\text{minutes} \approx 1\;\text{hour}

So the input becomes spendable about one hour after its funding output is confirmed. This is exactly the encoding shown in the video for a "one-hour time lock."

Question 4

True or False: A relative timelock (BIP 68) and an absolute timelock (nLockTime) measure the same kind of delay โ€” they both lock a transaction until a specific block height or calendar date.

โœ… Correct! Absolute timelocks pin to a fixed point; relative timelocks count from confirmation and are per-input.

โŒ Not quite. A relative timelock starts counting from the moment the funding output is confirmed โ€” it is not a fixed calendar date.

Show solution

Solution:

False. The two locks measure fundamentally different things:

  • nLockTime (absolute): a transaction-level field. The lock points to a specific block height or Unix timestamp โ€” e.g., "not before block 700,000." It is the same for everyone, regardless of when the inputs were confirmed.
  • BIP 68 relative timelock (sequence field): a per-input delay measured from the moment that input's funding output was confirmed. "30 blocks after confirmation" means different absolute heights for different transactions.

Both can coexist in the same transaction, but they are independent mechanisms.

Solved: 0 / 4