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 ...
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 ...
9
votes
Accepted
Why is OP_CHECKLOCKTIMEVERIFY disabled by maximum sequence number?
the purpose of OP_CHECKLOCKTIMEVERIFY is kind of the opposite to the purpose of tx.nLockTime. tx.nLockTime prevents transactions with future dates from entering the blockchain, whereas ...
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 ...
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 ...
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 ...
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 ...
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 ...
6
votes
Is it possible to schedule a transaction in the future?
Yes, there is tx.nLockTime. A transaction mined before its nLockTime is invalid, so you can send your funds to yourself on some newly created address, then send it back with a locktime and destroy the ...
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 ...
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 ...
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/...
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: ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
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 ...
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 ...
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 ...
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)...
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 ...
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 ...
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)...
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. ...
3
votes
Accepted
Understanding GreenAddress nLocktime/recovery transactions
When using a multisig Green Address wallet your funds are locked in a 2-of-2 multisig account, i.e. if you want to spend money from that account you need both your signature and Green Address' ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
locktime × 91transactions × 18
sequence × 17
checklocktimeverify × 16
script × 12
bitcoin-core × 7
timestamp × 7
checksequenceverify × 7
lightning-network × 6
blockchain × 5
multi-signature × 5
contracts × 5
mempool × 3
replace-by-fee × 3
hash-time-locked-contract × 3
bitcoind × 2
signature × 2
blockchain-fork × 2
raw-transaction × 2
bitcoin-cli × 2
doublespend × 2
transaction-verification × 2
utxo × 2
consensus × 2
coinbase-transaction × 2