NLocktime and nSequence

Revision as of 16:06, 28 January 2020 by Wei (talk | contribs)

nLocktime and nSequence are interlocks that can be applied to Bitcoin Transactions.

nSequence

nSequence is a parameter applied to each input of a transaction. If a transaction's nLocktime interlock is active, a transaction which has inputs where nSequence is less than UINT_MAX (0xFFFFFFFF), then the transaction cannot be accepted into a block.

nLocktime

nLockTime is a parameter applied to each transaction 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.

If nLockTime < 500,000,000, the integer is interpreted as the block height after which this transaction can be accepted. Otherwise the integer is interpreted as the UNIX timestamp after which this transaction can be included in a block.

Use in Payment Channels

In transactions where nLockTime is set in the future, and any inputs have nSequence number fields less than 0xFFFFFFFF they are considered non-final and held in a transaction pool until either nLockTime expires or all inputs have their nSequence finalised. Non-final transactions are replaceable with transactions that include the same inputs with a higher nSequence number. This function can be used to build payment channels allowing dynamic exchange of data between parties in a peer to peer manner.