Understanding Timelock/Locktime
A Timelock, also known as Locktime, is a predetermined schedule that governs the processing of cryptocurrency transactions on the blockchain by miners.
Miners include transactions in the Merkle Tree, a data structure used for efficient verification of transaction data, only after approving a specific block height.
Transactions are considered approved only after they are included in the Merkle Tree.
Satoshi Nakamoto, the creator of Bitcoin, made Timelocks a mandatory feature in all transactions.
The default blocking time is set to 0x00000000 (0).
The main purpose of Timelocks is to ensure that transactions are not verified until a certain time or block height is reached.
There are two types of Timelocks: absolute and time-relative.
Absolute Timelocks define blocks relative to a specific time.
Time-relative Timelocks determine the amount of time that must pass before transactions can be verified.
Bitcoin transactions measure time in two ways: block number and timestamp.
When a Timelock is based on a block number, miners receive a specific block number to determine the Timelock.
For Timelocks based on timestamps, miners must wait until a specific time period has elapsed before confirming the transaction.
Unix time is used to measure this time period.
There are four methods to determine timeblocks in Bitcoin: nSequence, nLocktime, CheckLockTimeVerify, and CheckSquenceVerify.
nLockTime involves absolute blocking at the transaction level.
nSequence is a Timelock relative to transaction levels.
CheckLockTimeVerify involves absolute time blocking at the script level.
CheckSquenceVerify is a Timelock relative to the script level.