Absolute Transaction Timelocks
- An absolute transaction timelock determines from which time on a transaction can be broadcast and mined on the Bitcoin network.
- This type of timelock can either be created by the transaction signer(s), or the signers of the previous outputs:
- TX Locktime Field
- Describes the absolute time in unix time or blockheight, from when on the transaction is valid.
- OP_CHECKLOCKTIMEVERIFY
- An output script operator, which describes what locktime the spending transaction must have.
Transaction Locktime Field
- The locktime field is set and signed by the signer(s) of the transaction.
- TX Locktime Field
- If locktime is set < 500million:
- Locktime value is interpreted as blockheight.
- If locktime is set >= 500million:
- Locktime value is interpreted as unix time.
- Encoded as 4Byte, little endian value
Check Locktime Verify
- Checklocktimeverify is a script operator which prevents a confirmed UXTO from being spent until locktime is expired.
- OP_CHECKLOCKTIMEVERIFY
- Validates:
- Spending TX Locktime >= top stack element
- Success: Continues without modifying stack
- Failure: Script verification fails
Relative Transaction Timelocks
- A relative transaction timelock determines the delay between confirmation of a UXTO and its spending.
- This type of timelock can be created by the transaction input signer(s), or the signers of the previous output(s):
- TX Input Sequence Field
- Describes the relative delay time in unix time or blocks, from which on a timelocked transaction is valid.
- OP_CHECKSEQUENCEVERIFY
- An output script operator, which describes what relative locktime the spending transaction input must have.
Transaction Input Sequence Field
- The input sequence field is set and endorsed by the signer(s) of the transaction input.
- TX Input Sequence Field
- For sequence field to be interpreted as relative timelock:
- Timelock encoded in 16 least signficant bits of sequence field.
- For delay in multiples of 512 seconds, typeflag bit (1 << 22) in sequence field must be activated.
- Otherwise, delay interpreted as blocks (e.g. 0x00000014 = 20 block delay)
Check Sequence Verify
- Checksequenceverify is a script operator which prevents a confirmed UXTO from being spent until the delay since its confirmation has passed.
- OP_CHECKSEQUENCEVERIFY
- Validates:
- Spending TX Input Sequence Delay >= top stack element
- Script [Delay] Encoding:
- 3 Bytes Little Endian (not 4 Bytes)
- Same typeflag bit (1 << 22) function as in sequence field.
- Relative timelock encoded in 16 least signficant bits.