Locktime bitcoin - interesting
Locktime bitcoin -
Locktime
Field in a transaction used for post-dating.
Locktime sets the earliest time a transaction can be mined in to a block.
It’s the last field in a piece of transaction data.
Usage
You can use locktime to make sure that a transaction is locked until a specific block height, or a point in time.
Locktime | Description |
---|---|
Unlocked at block height. | |
Unlocked at specific time (in Unix time) |
If you do not want your transaction to be locked until a specific block or time, set the locktime field to (or anything below the current block height or unix time).
Nodes validate every transaction (and block) they receive. So if they receive a transaction (or a block containing a transaction) with a locktime in the future, they will reject it.
Examples
Most transactions do not make use of locktime, so their locktime is set to .
Nonetheless:
Locktime | Decimal | Descrpition |
---|---|---|
This transaction could only be relayed on the network after the blockchain reached a height of 452,845. (tx) | ||
This is Fri, 12 May 2017 02:55:02 in Unix Time. The transaction could only be relayed on the network after the median time of the last 11 blocks (according to the time field in their block headers) is greater than this. (tx) | ||
This is Tue, 08 Jul 1997 14:54:41 in Unix Time. This is effectively like setting the locktime to , as the first ever block was mined on 02 Feb 2011 23:16:42. (tx) |
Notes
In order for the locktime to be effective, you need to set one of the values (for one of the inputs in the transaction data) to anything below the defaut maximum ().
Unix Time is the number of seconds since 1st January 1970.
As mentioned, the locktime has a dual-purpose for setting either a block height or time. This works because:
- It’s going to take 9,500 years before we hit block 500,000,000.
- The current unix time is (also known as 15 January 2021, 15:39:54), which is already above .
Resources
Source Code
By Greg Walker,
-
-
-