Network, fees & speed

Bitcoin Timelock Converter (nLockTime, nSequence, CLTV, CSV)

Bitcoin has two kinds of timelocks. An absolute lock (nLockTime in the transaction, OP_CHECKLOCKTIMEVERIFY in a script) says "not before block X" or "not before date Y". A relative lock (nSequence on an input, OP_CHECKSEQUENCEVERIFY in a script) says "not until N blocks or N ร— 512 seconds after the coin was confirmed". Paste a value in decimal or hex to see what it means, or build a relative lock from blocks or seconds.

Decimal or hex (0xโ€ฆ).

Block height 1,050,000: valid once the chain reaches it

1050000 = 0x00100590 ยท threshold 500,000,000

Decimal or hex (0xโ€ฆ).

Signals RBF (BIP125): Yes. Relative lock disabled (bit 31 set)

4294967293 = 0xfffffffd

Build a relative lock (BIP68)

nSequence
144 ยท 0x00000090

Date โ†’ nLockTime

UTC โ†’ nLockTime
1798761600 ยท 0x6b36ec80

nLockTime: height or time

nLockTime is a 32-bit field. Values below 500,000,000 are block heights; values from 500,000,000 up are Unix timestamps in seconds, compared with the median time of the last 11 blocks (BIP113). Zero means no lock. A lock is only enforced when at least one input has an nSequence below 0xFFFFFFFF โ€” otherwise the field is ignored.

OP_CHECKLOCKTIMEVERIFY (BIP65) uses the same encoding inside a script: the spending transaction must set nLockTime at least that high, of the same kind (height or time).

nSequence and BIP68 relative locks

Since BIP68, nSequence can carry a relative lock. If bit 31 (the disable flag) is set, there is no relative lock. Otherwise bit 22 chooses the unit โ€” 0 for blocks, 1 for units of 512 seconds โ€” and the lowest 16 bits hold the value, so the maximum is 65,535 blocks or 65,535 ร— 512 seconds, about 388 days. OP_CHECKSEQUENCEVERIFY (BIP112) checks the same encoding in a script.

nSequence also signals replace-by-fee: under BIP125 an input with nSequence below 0xFFFFFFFE marks the transaction as replaceable. 0xFFFFFFFE enables nLockTime without RBF, and 0xFFFFFFFF disables both. Many recent nodes allow replacement regardless of the signal (full-RBF), so do not treat a non-signalling transaction as final before it confirms.

nLockTime < 500,000,000 โ†’ block height, else Unix time nSequence bit 31 = 1 โ†’ relative lock disabled bit 22 = 0 โ†’ value = blocks; bit 22 = 1 โ†’ value ร— 512 s value = nSequence & 0xFFFF

Typical uses

  • Inheritance and vault scripts: a recovery key that can spend only after a date or after N blocks of inactivity.
  • Lightning channels: relative locks give the other side time to react to an old channel state.
  • Anti-fee-sniping: wallets set nLockTime to the current height so a transaction cannot be mined in an earlier block.

Sources: BIP65, BIP68, BIP112, BIP113 and BIP125 at github.com/bitcoin/bips.

Frequently asked questions

+How do I know if nLockTime is a block height or a date?

Below 500,000,000 it is a block height; from 500,000,000 up it is a Unix timestamp in seconds.

+What does nSequence 0xFFFFFFFD mean?

It signals replace-by-fee under BIP125 and has bit 31 set, so it carries no relative lock. It also enables nLockTime.

+What is the longest relative timelock?

65,535 blocks (about 455 days at 10 minutes) or 65,535 ร— 512 seconds (about 388 days).

+Why are time-based relative locks in 512-second units?

BIP68 uses 512-second granularity so that 16 bits can cover more than a year while keeping room in the field for flags.

Calculations run entirely in your browser; nothing you type is sent to KOT.CASH. Results are estimates for information only and are not financial, tax or legal advice.

โ† All 92 crypto tools

Bitcoin Timelock Converter: nLockTime, nSequence, CSV