Skip to main content
18 votes
Accepted

Why Bitcoin core creates time locked transactions by default?

TL;DR: The aim is to discourage reorganizations and increase privacy. In wallet.cpp, just above where nLockTime gets set, it says: // Discourage fee sniping. // // For a large miner the value of ...
Murch's user avatar
  • 76k
9 votes
Accepted

What does "lock time" mean?

A specified locktime indicates that the transaction is only valid after a given blockheight. Since the locktime field indicated is 419382 and currently the latest blockheight as of 12th July 2016 1108 ...
rny's user avatar
  • 2,428
9 votes

nLockTime in Bitcoin Core

I believe you are correct, both about the fact that height-based logic came first and time was added later, and the fact that this is a hard-forking change. A transaction with a locktime > 500000000 ...
Pieter Wuille's user avatar
7 votes

CLTV vs nLockTime

Setting the nLockTime field of a transaction restricts confirmation of the current transaction until a certain block height. Using a CLTV op in the locking script of an output of the current ...
Antoine Poinsot's user avatar
7 votes
Accepted

Why CHECKLOCKTIMEVERIFY and CHECKSEQUENCEVERIFY opcodes have to be succeeded with DROP Opcode?

This is because CSV and CLTV are NOP opcodes that were redefined in a softfork. As a softfork can only change the validity of transactions from valid to invalid, the only effect this redefinition was ...
Pieter Wuille's user avatar
7 votes
Accepted

nLockTime in Bitcoin Core

The Wiki was incorrect (I wrote the original text and I apologize). As indicated in the question, the ordering on the Wiki was backwards. However, upon investigating, I don't believe it was a hard ...
David A. Harding's user avatar
7 votes
Accepted

Why is the locktime set at transaction level while the sequence is set at input level?

See @RedGrittyBrick's answer for historical context for why there is a per-input nSequence field. The evolution since includes: nLockTime's meaning has been unchanged since the early days; it ...
Pieter Wuille's user avatar
6 votes
Accepted

How does nSequence/Check Sequence Verify work?

In order to use a relative time lock, you need to provide the requirements in the scriptPubKey to which the Bitcoin is sent. Example scriptPubKey for escrow with 30 day timeout: IF 2 <Alice's ...
JBaczuk's user avatar
  • 7,418
6 votes
Accepted

Sequence number semantics

If you're creating a version 2 transaction with the disable flag not set, then by definition the whole nSequence value will be less than 0xFFFFFFFE (because it will be at most 0x7FFFFFFF). This ...
Pieter Wuille's user avatar
6 votes
Accepted

What does the 'n' in nLockTime and nSequence stand for?

It stand for a number, it is commonly used in programming to designate a variable that gonna hold an amount of something see: https://en.bitcoin.it/wiki/NLockTime and https://en.bitcoinwiki.org/wiki/...
Saxtheowl's user avatar
  • 2,810
6 votes
Accepted

Why are miners setting the locktime in coinbase transactions?

Wang Chun of f2pool (@satofishi) said on Twitter: “We repurpose those 4 bytes to hold the stratum session data for faster reconnect.” He went on to say: "The coinbase locktime is set to: ...
bordalix's user avatar
  • 627
6 votes

Why is the locktime set at transaction level while the sequence is set at input level?

I'm not sure if you will have already seen this: From: Satoshi Nakamoto <[email protected] Date: Wed, Mar 9, 2011 at 5:15 PM To: Mike Hearn [email protected] Subject: Re: Open sourced my Java SPV ...
RedGrittyBrick's user avatar
5 votes

How can I make transaction output time locked?

Yes, you can use OP_CHECKLOCKTIMEVERIFY opcode in the locking script of the output. This opcode takes either blocks or Unix Epoch Time (seconds since 1-Jan-1970) as the parameter to lock. If the ...
Ugam Kamat's user avatar
  • 7,417
5 votes
Accepted

Strange LockTime values in Electrum transactions?

The locktime value is deliberately set to discourage a subtle attack known as "Fee sniping" and randomly set to an earlier block height to improve privacy (eg for CoinJoin users that need more setup ...
Jonathan Cross's user avatar
5 votes
Accepted

Are attempts to spend from a timelocked UTXO rejected?

I'm going to only address the first part of your question, as I think the root of your confusion can be addressed there. Time locking in Bitcoin refers to two related and interacting, but ...
Pieter Wuille's user avatar
5 votes
Accepted

Question about Bitcoin's Median Time Past

It is a bit weird, but it is simply not possible to have everyone's clocks be in sync, and so there must be leeway for a block to have a timestamp earlier than its predecessor. If my clock is a few ...
Ava Chow's user avatar
  • 70.9k
5 votes
Accepted

Can a signed raw transaction's locktime be changed?

A transaction's locktime is part of the data committed to by the transaction's signatures. If you change it, the signatures become invalid, and so the transaction becomes invalid. If the locktime ...
Vojtěch Strnad's user avatar
5 votes

What will happen if I try to broadcast a transaction before the established locktime block height passed?

The transaction will not be relayed across the network and it will simply be as if the transaction never happened in the first place.
Ava Chow's user avatar
  • 70.9k
5 votes
Accepted

What is the logic (if there is) behind linking the nSequence and nLockTime?

While the full policy side of the original nSequence replacement idea was never implemented, it does appear Bitcoin's creator had a design in mind, and the corresponding consensus rules were ...
Pieter Wuille's user avatar
4 votes

Can someone explain nLockTime?

The locktime is a transaction field that can be used to prevent a transaction from being included in the blockchain until some point in the future. If every input’s sequence number is set to the ...
Murch's user avatar
  • 76k
4 votes
Accepted

Can you "undo" an nlockTime transaction by spending a single UTXO of it before lockTime's block happens?

Since one of the inputs of the nLockTime transaction has been spent already, the nLockTime transaction becomes invalid, as not all referenced inputs are available for spending. This is described in ...
Murch's user avatar
  • 76k
4 votes
Accepted

Lightning: why do we need decrementing timelocks in multi-hop payments?

I use the following scenario for both questions: Alice wants to pay 1 BTC to Dave via the route: Alice -> Bob -> Carol -> Dave Why do we need timelocks? Lets assume that the payment route has just ...
Thomas Braunberger's user avatar
4 votes
Accepted

Reference an UTXO of a transaction that has not been yet mined

The UTXO is referenced as an outpoint(TXID, Index) in the input of your time-locked spending transaction. So, when creating your time-locked transaction, you need to know the TXID of the (unconfirmed)...
James C.'s user avatar
  • 2,521
4 votes
Accepted

what if the timelock is in the past?

If the nLockTime is less than or equal to the next block height, it can be included in the next block. To explicitly answer your questions: The CLTV op restricts the nLockTime field of the spending ...
Antoine Poinsot's user avatar
4 votes

Why are OP_RETURN transactions discouraged? Does using version or locktime make any difference?

Whether OP_RETURN transactions are discouraged or not is a matter of opinion. Personally, I think transactions should not store any data that isn't needed for the world to verify them, which is by ...
Pieter Wuille's user avatar
4 votes
Accepted

UNIX END TIME January 19, 2038 - Will it affect Timelock nLOCKTIME smart contracts past that date?

Timestamps in Bitcoin, including block timestamps and nLocktime values, are unsigned 32-bit. The last possible timestamp is Feb 7th 2106, at 06:28:15 UTC.
Pieter Wuille's user avatar
4 votes
Accepted

What are all the meanings of the nSequence field?

You are right in saying nodes nowadays do not enforce the original ordering meaning given to the nSequence field, though note this was never implemented as part of block validation (couldn't have been)...
Antoine Poinsot's user avatar
3 votes
Accepted

Simple explanation of how a hash timelock function works with an atomic trade of bitcoin / litecoin trade without a 3rd party?

I am leaving out a few details here, but this will get you thinking on the right path... Alice and Bob have accounts on both the Bitcoin and Litecoin networks. Bob has Bitcoin, but wants Litecoin. ...
jmjatlanta's user avatar
3 votes
Accepted

BIP 113 - monotonic guarantee

The guarantee comes from the consensus rule that a block's timestamp must be greater than the median timestamp of the last 11 blocks. This median timestamp is known as the median time of the block. ...
Ava Chow's user avatar
  • 70.9k

Only top scored, non community-wiki answers of a minimum length are eligible