• Hash256
  • Hash160
  • Reverse Bytes
  • Hexadecimal
  • Satoshis

Locktime

Field in a transaction used for post-dating.

Setting a locktime is like post-dating a bitcoin transaction

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
< 500000000 Unlocked at block height.
>= 500000000 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 0x00000000 (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 0x00000000.

Nonetheless:

Locktime Decimal Description
0xede80600 452845 This transaction could only be relayed on the network after the blockchain reached a height of 452,845. (tx)
0x06241559 1494557702 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)
0xb154c233 868373681 This is Tue, 08 Jul 1997 14:54:41 in Unix Time. This is effectively like setting the locktime to 0x00000000, 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 sequence values (for one of the inputs in the transaction data) to anything below the default maximum (0xffffffff).

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,498 years before we hit block 500,000,000.
  • The current unix time is 1,679,399,062 (also known as 21 March 2023, 11:44:22), which is already above 500,000,000.

Resources

Source Code

By Greg Walker,

Last Updated: 04 Feb 2021
  • 04 Feb 2021: spelling fixes
  • 22 Oct 2020: typo
  • 21 Jul 2020: renamed /guide/ to /technical/
Back to Top

Hey there, it's Greg.

I'll let you know about cool website updates, or if something seriously interesting happens in bitcoin.


Don't worry, it doesn't happen very often.