Difference between revisions of "NLockTime"
(Updated the page to reflect the actual consensus meaning of the `nLockTime` field.) |
(Correct the BIP68 additions) |
||
Line 4: | Line 4: | ||
− | Since [https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki BIP68], | + | Since [https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki BIP68], the '''nLockTime''' can specify a relative lock time. Given a transaction, |
− | * If the most significant bit (1<<31) is set | + | * If the most significant bit (1<<31) is not set |
** If the 23rd bit (1<<22) is set | ** If the 23rd bit (1<<22) is set | ||
− | *** | + | *** The last 16 bits of the '''nLockTime''' field specify a relative time in units of 512 seconds. The transaction can only be included in a block if <code>spending_tx_block_time > spent_tx_block_time + nLockTime * 512</code>. |
** Otherwise | ** Otherwise | ||
− | *** | + | *** The last 16 bits of the '''nLockTime''' field specify a relative block height before which the transaction can not be included in a block. In other words it can be included if <code>spending_tx_block_height > spent_tx_block_height + nLockTime</code> |
* Otherwise | * Otherwise | ||
** the transaction can be included in any block | ** the transaction can be included in any block |
Revision as of 12:49, 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, the nLockTime can specify a relative lock time. Given a transaction,
- If the most significant bit (1<<31) is not set
- If the 23rd bit (1<<22) is set
- The last 16 bits of the nLockTime field specify a relative time in units of 512 seconds. The transaction can only be included in a block if
spending_tx_block_time > spent_tx_block_time + nLockTime * 512
.
- The last 16 bits of the nLockTime field specify a relative time in units of 512 seconds. The transaction can only be included in a block if
- Otherwise
- The last 16 bits of the nLockTime field specify a relative block height before which the transaction can not be included in a block. In other words it can be included if
spending_tx_block_height > spent_tx_block_height + nLockTime
- The last 16 bits of the nLockTime field specify a relative block height before which the transaction can not be included in a block. In other words it can be included if
- If the 23rd bit (1<<22) is set
- Otherwise
- the transaction can be included in any block
See Also
- lock_time in the protocol specification
- Timelock
- BIP68
- The CHECKLOCKTIMEVERIFY opcode in BIP65
- The CHECKSEQUENCEVERIFY opcode in BIP112