NLockTime: Difference between revisions

From Bitcoin Wiki
Jump to navigation Jump to search
Belcher (talk | contribs)
Add link to timelock page
Darosior (talk | contribs)
Updated the page to reflect the actual consensus meaning of the `nLockTime` field.
Line 2: Line 2:


'''nLockTime''' is a parameter of a transaction, that, if any input indicates so (by having nSequence not equal to UINT_MAX), mandates a minimal time (specified in either unix time or block height), before which the transaction cannot be accepted into a block.  If all inputs in a transaction have nSequence equal to UINT_MAX, then nLockTime is ignored.
'''nLockTime''' is a parameter of a transaction, that, if any input indicates so (by having nSequence not equal to UINT_MAX), mandates a minimal time (specified in either unix time or block height), before which the transaction cannot be accepted into a block.  If all inputs in a transaction have nSequence equal to UINT_MAX, then nLockTime is ignored.
Since [https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki BIP68], a new meaning has been given to the '''nLockTime''' and '''nSequence''' fields. Given a transaction,
* If the most significant bit (1<<31) is set
** If the 23rd bit (1<<22) is set
*** Specifies a time in units of 512 seconds. The transaction can only be included in a block if <code>block_time > nLockTime * 512</code>.
** Otherwise
*** Specifies a block height before which the transaction can not be included in a block.
* Otherwise
** the transaction can be included in any block


==See Also==
==See Also==
* lock_time in [[Protocol_specification#tx|the protocol specification]]
* lock_time in [[Protocol_specification#tx|the protocol specification]]
* [[Timelock]]
* [[Timelock]]
* [https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki BIP68]
* The CHECKLOCKTIMEVERIFY opcode in [https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki BIP65]
* The CHECKSEQUENCEVERIFY opcode in [https://github.com/bitcoin/bips/blob/master/bip-00112.mediawiki BIP112]


[[Category:Technical]]
[[Category:Technical]]
{{lowercase}}
{{lowercase}}

Revision as of 11:47, 23 September 2019

This page is a stub. Help by expanding it.

nLockTime is a parameter of a transaction, that, if any input indicates so (by having nSequence not equal to UINT_MAX), mandates a minimal time (specified in either unix time or block height), before which the transaction cannot be accepted into a block. If all inputs in a transaction have nSequence equal to UINT_MAX, then nLockTime is ignored.


Since BIP68, a new meaning has been given to the nLockTime and nSequence fields. Given a transaction,

  • If the most significant bit (1<<31) is set
    • If the 23rd bit (1<<22) is set
      • Specifies a time in units of 512 seconds. The transaction can only be included in a block if block_time > nLockTime * 512.
    • Otherwise
      • Specifies a block height before which the transaction can not be included in a block.
  • Otherwise
    • the transaction can be included in any block

See Also