# Locktime and sequence

> Pearl's locktime and sequence fields: absolute time locks, opt-in replace-by-fee and BIP-68 relative locks. What the wallet writes (0 and ffffffff) and why.

Source: https://pearlcodex.com/technical/transaction/locktime-and-sequence/ · Last updated: 2026-10-20 · Checked against Pearl's source code at v1.5.5

Most transactions can be mined the moment they’re broadcast. Two small fields let a transaction say otherwise: “not before block such-and-such”, or “not until this coin is so many blocks old”.

The [locktime](https://pearlcodex.com/glossary/#locktime) sits at the very end of the transaction and applies to the whole thing. The [sequence](https://pearlcodex.com/glossary/#sequence) sits in each input and has grown three jobs over Bitcoin’s history. Pearl inherited both unchanged, switched on from block 1. Its wallet, though, leaves them at their “off” values.

## Try it

The OP_RETURN example signals replace-by-fee. Find its sequence field.

_Interactive: Transaction decoder. Try it on the page: <https://pearlcodex.com/technical/transaction/locktime-and-sequence/>_

## What is the locktime?

- **Size:** 4 bytes
- **Type:** Unsigned integer
- **Format:** Little-endian
- **Range:** 0 to 4,294,967,295

The last four bytes of every transaction. The value is read three ways:

| Value              | Meaning                                                                                   |
| ------------------ | ----------------------------------------------------------------------------------------- |
| 0                  | No lock. What Pearl’s wallet always writes.                                               |
| 1 to 499,999,999   | A block height: the transaction can only be in a block whose height is greater than this. |
| 500,000,000 and up | A Unix time: only in a block whose median time past is later than this.                   |

There’s an escape hatch: if every input’s sequence is `ffffffff`, the locktime is ignored altogether.

Here are the locktime bytes of a real payment, `00000000`:

**A typical payment: 1 input, 2 outputs · 205 bytes**

```
01000000 00 01 01 5939557091bae792be66f26cbd83fc78f16a690a854109e8a1d115e253812133 ab020000 00 ffffffff 02 b0359f1100000000 22 5120d7ab02c96a342bdddb5d07b9f3ebd6c04e077ff41418110b9a1e5997439416b2 00c2eb0b00000000 22 512062e9da3682aab288392cf7218bafc36287288abb3ce200c5d1a50aa234073b2b 01 40 4686c7014749649b25555874c7772ecb7a44e85454893ed5888db11ebcdc82a22d74ce1a1671d02810f5ba1dca3277409e95a653ba9644099f7da26be7a86ba2 00000000
```

| Field                                             | Bytes          | Value                                                                                                                                                                                                                  |
| ------------------------------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Version (`version`)                               | 4, offset 0    | 1 · int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2.                                                                                                                   |
| Marker (`marker`)                                 | 1, offset 4    | 0x00 · Segwit marker (BIP-144): says witness data follows the outputs.                                                                                                                                                 |
| Flag (`flag`)                                     | 1, offset 5    | 0x01 · Witness flag; 0x01 is the only value Pearl accepts.                                                                                                                                                             |
| Input count (`vin.length`)                        | 1, offset 6    | 1 · CompactSize number of inputs.                                                                                                                                                                                      |
| Previous txid (`vin[0].txid`)                     | 32, offset 7   | 33218153e215d1a1e80941850a696af178fc83bd6cf266be92e7ba9170553959 · The transaction being spent, stored byte-reversed (internal order); shown here in normal display order.                                             |
| Output index (`vin[0].vout`)                      | 4, offset 39   | 683 · Which output of that transaction is spent (uint32 LE).                                                                                                                                                           |
| scriptSig length (`vin[0].scriptSig.length`)      | 1, offset 43   | 0 · Always 0 for non-coinbase inputs in Pearl: every spend uses the witness instead.                                                                                                                                   |
| Sequence (`vin[0].sequence`)                      | 4, offset 44   | 0xffffffff · Final (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this.                                                                                  |
| Output count (`vout.length`)                      | 1, offset 48   | 2 · CompactSize number of outputs.                                                                                                                                                                                     |
| Amount (`vout[0].value`)                          | 8, offset 49   | 295,646,640 grains (2.95646640 PRL) · int64 little-endian, in grains (1 PRL = 100,000,000 grains).                                                                                                                     |
| Script length (`vout[0].scriptPubKey.length`)     | 1, offset 57   | 34 · CompactSize length of the locking script.                                                                                                                                                                         |
| Locking script (`vout[0].scriptPubKey`)           | 34, offset 58  | prl1p674s9jt2xs4amk6aq7ul867kcp8qwll5zsvpzzu6revewsu5z6eqv9d5z4 · OP_1 OP_PUSHBYTES_32 \<output key Q>: a Taproot output.                                                                                              |
| Amount (`vout[1].value`)                          | 8, offset 92   | 200,000,000 grains (2.00000000 PRL) · int64 little-endian, in grains (1 PRL = 100,000,000 grains).                                                                                                                     |
| Script length (`vout[1].scriptPubKey.length`)     | 1, offset 100  | 34 · CompactSize length of the locking script.                                                                                                                                                                         |
| Locking script (`vout[1].scriptPubKey`)           | 34, offset 101 | prl1pvt5a5d5z42egswfv7uscht7rv2rj3z4m8n3qp3w35592ydq88v4seuhn70 · OP_1 OP_PUSHBYTES_32 \<output key Q>: a Taproot output.                                                                                              |
| Witness items (`witness[0].length`)               | 1, offset 135  | 1 · Number of witness stack items for input 0.                                                                                                                                                                         |
| Schnorr signature length (`witness[0][0].length`) | 1, offset 136  | 64 · CompactSize length of this witness item.                                                                                                                                                                          |
| Schnorr signature (`witness[0][0]`)               | 64, offset 137 | 4686c7014749649b25555874c7772ecb7a44e85454893ed5888db11ebcdc82a22d74ce1a1671d02810f5ba1dca3277409e95a653ba9644099f7da26be7a86ba2 · 64-byte BIP-340 signature (R.x ‖ s) with SIGHASH_DEFAULT: a Taproot key-path spend. |
| Locktime (`locktime`)                             | 4, offset 201  | 0 · 0: no time lock.                                                                                                                                                                                                   |

- **txid:** d919e02a4adfd739ceef31d98803f0ddd24e1b1fa67b0fe572cdec42c1b384c9
- **Size:** 205 bytes · 154 vbytes
- **Block:** 130,825
- **Fee:** 7,915 grains

### Which clock do time locks use?

Not the block’s own timestamp, which a miner could fudge. Time locks are compared with the [median time past](https://pearlcodex.com/glossary/#median-time-past): the median timestamp of the previous 11 blocks (BIP-113).

Pearl adds a twist. Each block’s timestamp must be at least one second after its parent’s, so timestamps only go up, and the median of 11 is simply the 6th most recent. At the 194-second target, that’s roughly five block intervals, about 16 minutes, behind the latest block. (An estimate from the rules, not a measurement.)

## What is the sequence number?

- **Size:** 4 bytes per input
- **Type:** Unsigned integer
- **Format:** Little-endian

Satoshi meant it for updating unconfirmed transactions. That idea was dropped, and the field was later reused, bit by bit:

| Sequence                   | What it means                                                                                                           |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `ffffffff`                 | Final. No replace-by-fee signal, no relative lock; if all inputs say this, locktime is off. **Pearl’s wallet default.** |
| `fffffffe`                 | Locktime enabled, no replace-by-fee signal.                                                                             |
| `fffffffd` or less         | Signals opt-in replace-by-fee (BIP-125).                                                                                |
| top bit clear, version ≥ 2 | A relative lock (BIP-68), described below.                                                                              |

A real transaction from block 130,809 uses `fdffffff`, that is 0xfffffffd: it signals replace-by-fee, and since its top bit is set, it isn’t a relative lock.

**Carries an OP_RETURN data output · 253 bytes**

```
02000000 00 01 01 45e83fb8acdfc3cbe7a71b17fe2a05a807fc2222100aab42081ad4e40f344ead 02000000 00 fdffffff 03 b881db2f0b000000 22 5120894b4852db6a243fb705236b47da5ccb18c3ba896c5b0838b9d5c2e93a2efcf4 0000000000000000 27 6a2550524c5501be1688fc1b2fc0671d18c396f9daed531579848f1f8cf002d1579ee333d9ae87 87214249d7050000 22 5120a26b47f694abf29858cc7d1eb44319fc31c12f8bd093d042003b27f9ba91731b 01 40 834fa0d9eb91ac59fcf21e911b43eca33608b6b8393c6a304a959cfaeebbb505ff38d095905be416e78c70ae3fe6d018d823d6ff36467f3199bea33f91976c71 00000000
```

| Field                                             | Bytes          | Value                                                                                                                                                                                                                  |
| ------------------------------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Version (`version`)                               | 4, offset 0    | 2 · int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2.                                                                                                                   |
| Marker (`marker`)                                 | 1, offset 4    | 0x00 · Segwit marker (BIP-144): says witness data follows the outputs.                                                                                                                                                 |
| Flag (`flag`)                                     | 1, offset 5    | 0x01 · Witness flag; 0x01 is the only value Pearl accepts.                                                                                                                                                             |
| Input count (`vin.length`)                        | 1, offset 6    | 1 · CompactSize number of inputs.                                                                                                                                                                                      |
| Previous txid (`vin[0].txid`)                     | 32, offset 7   | ad4e340fe4d41a0842ab0a102222fc07a8052afe171ba7e7cbc3dfacb83fe845 · The transaction being spent, stored byte-reversed (internal order); shown here in normal display order.                                             |
| Output index (`vin[0].vout`)                      | 4, offset 39   | 2 · Which output of that transaction is spent (uint32 LE).                                                                                                                                                             |
| scriptSig length (`vin[0].scriptSig.length`)      | 1, offset 43   | 0 · Always 0 for non-coinbase inputs in Pearl: every spend uses the witness instead.                                                                                                                                   |
| Sequence (`vin[0].sequence`)                      | 4, offset 44   | 0xfffffffd · signals opt-in replace-by-fee (BIP-125).                                                                                                                                                                  |
| Output count (`vout.length`)                      | 1, offset 48   | 3 · CompactSize number of outputs.                                                                                                                                                                                     |
| Amount (`vout[0].value`)                          | 8, offset 49   | 48,047,555,000 grains (480.47555000 PRL) · int64 little-endian, in grains (1 PRL = 100,000,000 grains).                                                                                                                |
| Script length (`vout[0].scriptPubKey.length`)     | 1, offset 57   | 34 · CompactSize length of the locking script.                                                                                                                                                                         |
| Locking script (`vout[0].scriptPubKey`)           | 34, offset 58  | prl1p3995s5kmdgjrldc9yd450kjuevvv8w5fd3dssw9e6hpwjw3wln6qstfvct · OP_1 OP_PUSHBYTES_32 \<output key Q>: a Taproot output.                                                                                              |
| Amount (`vout[1].value`)                          | 8, offset 92   | 0 grains (0.00000000 PRL) · int64 little-endian, in grains (1 PRL = 100,000,000 grains).                                                                                                                               |
| Script length (`vout[1].scriptPubKey.length`)     | 1, offset 100  | 39 · CompactSize length of the locking script.                                                                                                                                                                         |
| Locking script (`vout[1].scriptPubKey`)           | 39, offset 101 | OP_RETURN data (unspendable) · OP_RETURN data carrier: provably unspendable, never enters the UTXO set.                                                                                                                |
| Amount (`vout[2].value`)                          | 8, offset 140  | 6,422,205,178,247 grains (64222.05178247 PRL) · int64 little-endian, in grains (1 PRL = 100,000,000 grains).                                                                                                           |
| Script length (`vout[2].scriptPubKey.length`)     | 1, offset 148  | 34 · CompactSize length of the locking script.                                                                                                                                                                         |
| Locking script (`vout[2].scriptPubKey`)           | 34, offset 149 | prl1p5f450a5540efskxv050tgscelscuztut6zfaqssq8vnlnw53wvdsmw4yvs · OP_1 OP_PUSHBYTES_32 \<output key Q>: a Taproot output.                                                                                              |
| Witness items (`witness[0].length`)               | 1, offset 183  | 1 · Number of witness stack items for input 0.                                                                                                                                                                         |
| Schnorr signature length (`witness[0][0].length`) | 1, offset 184  | 64 · CompactSize length of this witness item.                                                                                                                                                                          |
| Schnorr signature (`witness[0][0]`)               | 64, offset 185 | 834fa0d9eb91ac59fcf21e911b43eca33608b6b8393c6a304a959cfaeebbb505ff38d095905be416e78c70ae3fe6d018d823d6ff36467f3199bea33f91976c71 · 64-byte BIP-340 signature (R.x ‖ s) with SIGHASH_DEFAULT: a Taproot key-path spend. |
| Locktime (`locktime`)                             | 4, offset 249  | 0 · 0: no time lock.                                                                                                                                                                                                   |

- **txid:** 4ce980a19e940dadd3ecb0ca5c59e05880c252c254ae5f690bfaac7d6c642e0c
- **Size:** 253 bytes · 202 vbytes
- **Block:** 130,809
- **Fee:** 10,200 grains

## How does a relative lock work?

A [relative lock](https://pearlcodex.com/glossary/#relative-locktime) says “the coin this input spends must be at least N blocks (or N × 512 seconds) old”. It’s written in the sequence number when the transaction’s version is 2 or higher:

| Field     | Size    | Description                                                                                                    |
| --------- | ------- | -------------------------------------------------------------------------------------------------------------- |
| bit 31    | 1 bit   | Disable flag. Set: no relative lock (true of every value from `80000000` up, including `fffffffd`–`ffffffff`). |
| bit 22    | 1 bit   | Type flag. Clear: the value counts blocks. Set: it counts units of 512 seconds.                                |
| bits 0–15 | 16 bits | The value: up to 65,535 blocks or 65,535 × 512 seconds (about 388 days).                                       |

> **Scenario · made-up numbers: Two relative locks**
>
> Sequence `00000090` (0x90 = 144) in a version-2 transaction: the spent coin must be 144 blocks old, about eight hours at Pearl’s 194-second target. Sequence `00400090` (type bit set): 144 × 512 seconds, about 20.5 hours. Made-up examples, not taken from the chain.

Scripts can demand these locks too: `OP_CHECKLOCKTIMEVERIFY` (BIP-65) and `OP_CHECKSEQUENCEVERIFY` (BIP-112) work in Pearl’s tapscript, as in Bitcoin. All of these rules are on from the first block; Pearl never had a soft-fork activation for them.

## What is replace-by-fee on Pearl?

[Replace-by-fee](https://pearlcodex.com/glossary/#rbf) lets you swap an unconfirmed transaction for a new version that pays a higher fee. On Pearl it’s **opt-in only**, as in Bitcoin’s BIP-125:

- A transaction is replaceable if any of its inputs has a sequence of `fffffffd` or less, or if an unconfirmed ancestor signals.
- The replacement must pay a strictly higher fee rate than each transaction it replaces, and an absolute fee at least their total plus the minimum relay fee for its own size.
- It may evict at most 100 transactions, may not add new unconfirmed inputs, and may not spend the outputs it replaces.
- A node started with `-rejectreplacement` refuses all replacements.

There is no “full RBF” mode, in which any transaction can be replaced whether it signals or not.

> **Note: Pearl wallet transactions can't be bumped**
>
> Oyster writes sequence `ffffffff` on every input, so its transactions don’t signal replace-by-fee. If one is stuck at a low fee, it can’t be replaced; it waits. Pick a sensible fee rate up front; see [fees and vsize](https://pearlcodex.com/technical/transaction/fees-and-vsize/).

## What does Pearl’s wallet write?

| Field    | Oyster’s value | Effect                   |
| -------- | -------------- | ------------------------ |
| version  | 1              | BIP-68 never applies     |
| locktime | 0              | no absolute lock         |
| sequence | `ffffffff`     | no RBF, no relative lock |

Bitcoin Core’s wallet does differently: version 2, and a locktime set to the current height to discourage miners from rewriting recent blocks (“anti-fee-sniping”). Pearl’s wallet does neither.

> **Pearl vs Bitcoin**
>
> - **Same rules** for locktime, sequence, BIP-65, 68, 112 and 113, but active from block 1 with no activation history.
> - **Opt-in RBF only.** Bitcoin Core now defaults to full RBF; Pearl’s mempool has no full-RBF mode.
> - **Wallet defaults differ:** version 1, locktime 0, sequence `ffffffff`.
> - **Faster median time:** with 194-second blocks, the 11-block median trails the tip by minutes, not an hour.

## In short

- Locktime (4 bytes, at the end) says the earliest block height (below 500,000,000) or Unix time (from 500,000,000) at which a transaction may be mined. 0 means no lock.
- Time locks are compared with the median time of the previous 11 blocks, not the clock.
- Each input’s sequence (4 bytes) does three jobs: ffffffff means final; anything up to fffffffd signals opt-in replace-by-fee; with the top bit clear and version ≥ 2, it’s a relative lock.
- Pearl’s wallet writes version 1, locktime 0 and sequence ffffffff: its transactions can’t be replaced and never use relative locks.
- Pearl supports opt-in RBF only. There is no full-RBF mode.

## Read the code

- [IsFinalizedTransaction: height or time, and the ffffffff escape](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L126-L158) `node/blockchain/validate.go:126-158`
- [LockTimeThreshold = 500,000,000](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/txscript/consensus.go#L12) `node/txscript/consensus.go:12`
- [Sequence flags: disable bit 31, type bit 22, mask 0xffff](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/wire/msgtx.go#L32-L51) `node/wire/msgtx.go:32-51`
- [calcSequenceLock: BIP-68, only for version 2 and up](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/chain.go#L390-L477) `node/blockchain/chain.go:390-477`
- [Replace-by-fee: signaling and the replacement rules](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/mempool/mempool.go#L647-L735) `node/mempool/mempool.go:647-735`
- [The wallet's inputs: sequence ffffffff](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/wallet/wallet/createtx.go#L42-L71) `wallet/wallet/createtx.go:42-71`

## Sources

### Bitcoin standards

- [BIP-65: OP_CHECKLOCKTIMEVERIFY](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki)
- [BIP-68: Relative lock-time using consensus-enforced sequence numbers](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)
- [BIP-112: OP_CHECKSEQUENCEVERIFY](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki)
- [BIP-113: Median time-past as endpoint for lock-time calculations](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki)
- [BIP-125: Opt-in full replace-by-fee signaling](https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki)
