9

I'm having a hard time understanding how nLockTime works. The Bitcoin wiki has an explanation that is confusing to me:

nLockTime is a parameter that can be attached to a transaction, that mandates a minimal time (specified in either unix time or block height), that before this time, the transaction cannot be accepted into a block.

Can someone explain it in plain English, with an example?

2

From the wiki it basically states that you can make a transaction to another bitcoin address and add nlocktime. The way that this would work in real life would be if you get paid on salary and are paid bi-weekly, the bitcoins will be on the network but won't reach you until the nlocktime is up Edit: read example 1 from https://en.bitcoin.it/wiki/Contracts

  • 8
    "The bitcoins will be on the network" is false. nLockTime'd transactions are not kept in the mempools of miners nor are they relayed between miners, until the nLockTime has almost elapsed. It is your responsibility to keep the signed transaction and publish it when the time is right. – dionyziz Nov 30 '15 at 14:26
0

In order for the transaction to be final, i.e., not reversible, the transaction needs to be included in a block. The nLockTime parameter can be used to guarantee that the transaction cannot be mined prior to a certain block height or a certain unix time stamps. In other words, the protocol guarantees that a specific transaction cannot be finalized prior to a certain time.

Imagine that you deposit 1 BTC into a 2/2 multisignature account and you intend to use this to make incremental payments to some other party. One of the keys in the multisig account is held by you and another one is held by the other party. Each time you want to make a payment to the other party, you sign a transaction from the multisig to the other party and give the signature to them. The other party can then, at any time, choose to publish the transaction you just signed by adding their own signature and handing the transaction to miners, or they can wait to see if any more payments (i.e. signatures) come from you.

Before depositing the bitcoins to the multisig address, the other party should send you a signature of a transaction with nLockTime set to 1000 blocks in the future. This transaction transfers the entire deposit of 1 BTC back to you. If they do that, then you can always get your deposit back (after 1000 blocks) even if the other party for some reason dissapears or chooses to act destructively.

The parameter nLockTime makes it possible to create trust-free payment channels.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.