Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
9 votes
Accepted

Are Micropayment channels still subject to malleability after BIP65?

There are a variety of different ways to construct a micropayment channel, but there are two designs that I think are particularly relevant to your question about "simple, one-directional, ...
David A. Harding'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

BIP 65 - how standard is it?

The softfork defined by BIP 65 activated in december 2015. This means that the whole network enforces the new rules proposed by BIP 65, and it is safe to use CLTV opcodes in scripts since then.
Pieter Wuille'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
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

How to check OP_CHECKLOCKTIMEVERIFY?

OP_CHECKLOCKTIMEVERIFY verifies, as the name implies, the locktime. It does not verify the time. In other words, it checks the transaction's nLockTime field against the value provided in the opcode. ...
Pieter Wuille'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,407
5 votes

Do transactions including CHECKLOCKTIMEVERIFY get mined immediately?

Taking a stab at answering my own question. Both the transaction using OP_CHECKLOCKTIMEVERIFY in its output script and the one spending OP_CHECKLOCKTIMEVERIFY can be mined immediately in most cases. ...
Scott Driscoll's user avatar
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
  • 75.7k
4 votes
Accepted

Clarification on execution of complex script with OP_CHECKLOCKTIMEVERIFY

Bitcoin uses a stack based language due to which the logical condition that will execute the IF or ELSE statements comes prior to the operator IF or ELSE. Let's take both your cases one by one and see ...
Ugam Kamat's user avatar
  • 7,407
4 votes
Accepted

Does the nSequence of the input that consumes the CLTV output have to be different from 0xffffffff?

Citing BIP65, which introduced OP_CHECKLOCKTIMEVERIFY: When executed, if any of the following conditions are true, the script interpreter will terminate with an error: the stack is empty; or the top ...
Pieter Wuille's user avatar
3 votes
Accepted

What is the relation between nLockTime and nSequence?

Yes it's still a consensus rule, as it's been since 2009. You indeed need to set at least one input's nSequence to something else than 0xffffffff for the absolute timelock to be taken into account. ...
Antoine Poinsot'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.7k
3 votes

Why is OP_CHECKLOCKTIMEVERIFY disabled by maximum sequence number?

mulllhausen's answer is great, but here's a shorter example that illustrates why the vin seq number can't be final or maxed. Suppose I want to spend a CLTV output. I wait until the CLTV time has ...
Scott Driscoll's user avatar
3 votes
Accepted

Can I program OP_CHECKLOCKTIMEVERIFY to trigger based on external verifiable events?

Maybe not with OP_CHECKLOCKTIMEVERIFY, as it is not possible to consume an external input with that particular operation. But you can write a third-party oracle that will release some secret (i.e. a ...
rny's user avatar
  • 2,428
3 votes

Can a spend before a timestamp condition be put on a Bitcoin UTXO?

You can do this by creating a P2WSH output with the following script: OP_IF <condition 1> OP_ELSE <timestamp> OP_CHECKLOCKTIMEVERIFY OP_DROP <condition 2> OP_ENDIF Then ...
Vojtěch Strnad's user avatar
2 votes
Accepted

Is it safe to keep ONLY a time-locked tx?

It should be, since all changes to the Bitcoin protocol should be agreed on by the entire community. However, there is no way to guarantee a softfork can't be abused, or even necessarily invalidate ...
Luke Dashjr's user avatar
  • 1,269
2 votes
Accepted

How is the clock reset in the Complex Script Example?

If at least two of the partners are cooperative with each other, they can move the funds at any time, even before the 30 days have elapsed. They can spend the output at any time using the second ...
meshcollider's user avatar
  • 11.8k
2 votes

How is the clock reset in the Complex Script Example?

They 'reset' the clock by moving the funds to a new output before the period ends.
Claris's user avatar
  • 15.4k
2 votes

Is the bit encoding format for the graphic in BIP 68 implicitly little-endian?

All fields in a Bitcoin transaction are little-endian encoded except for the signature fields and the public key fields which are both DER and big-endian encoded since they were originally produced by ...
Thorkil Værge's user avatar
2 votes

How does CLTV prevent spender from spending the output?

if nLockTime field is greater than the CLTV argument the execution fails, otherwise will continue as if NOP had been executed. This is backwards. If the transaction's nLockTime is greater than or ...
Ava Chow's user avatar
  • 70.7k
2 votes

What are the default timelocks in Lightning implementations today? How are they negotiated on channel opening?

For eclair, those values are set in your eclair.conf, and you can set the maximum values you expect from your peers: https://github.com/ACINQ/eclair/blob/5b1c69cc8483626564b03805c2d92b11d0930e93/...
t-bast's user avatar
  • 21
2 votes

Can a spend before a timestamp condition be put on a Bitcoin UTXO?

It's not possible to set spend conditions which expire on a Script. It's sometimes referred to as an "inverse timelock". It is widely believed to not be desirable as a valid Script becoming ...
Antoine Poinsot's user avatar
1 vote

How does CLTV prevent spender from spending the output?

The nLockTime transaction field allows you to specify the time before which the transaction cannot be part of the blockchain. You can define that time through the height of the block or in UNIX ...
dassd's user avatar
  • 1,099
1 vote
Accepted

How to add an address to a CheckLockTimeValue (CLTV) transaction output using bitcore-lib (or any other js lib)

You're putting a script directly in the scriptPubKey. That's both discouraged, non-standard, and hard to use, as you've noticed there is no corresponding address. There are only three types of ...
Pieter Wuille's user avatar
1 vote
Accepted

Using CLTV can I freeze some funds from a wallet, and make them available, in a single transaction?

When you lock coins in CLTV you still have to provide an address in the output. In that field, you can just include the address that your wallet controls. When you spend those coins, all you need to ...
Ugam Kamat's user avatar
  • 7,407
1 vote
Accepted

How to make a transaction with locktime on testnet?

Note: Although this answer is written for testnet, it is absolutely valid for the mainnet as well. The script will be similar, just the address encoding will be different (P2PKH start with 1 vs m for ...
Ugam Kamat's user avatar
  • 7,407
1 vote
Accepted

OP_CHECKLOCKTIMEVERIFY . Include / reject or will not included in block?

A transaction with a CLTV output can be created at any time, and can be accepted and confirmed immediately. Spending such an output requires a transaction whose nLocktime field is at least the CLTV-...
Pieter Wuille's user avatar
1 vote

Is it safe to keep ONLY a time-locked tx?

It's not that simple. Even after a new version is released, breaking backwards compatibility, it has to be adopted. It would have to be decided by the bitcoin community to go ahead and run the new ...
Timothy Gonzalez's user avatar
1 vote

BIP 113 - monotonic guarantee

Block timestamps are allowed be to slightly off (up to 2 hours). This poses an issue for locktime transactions, since a miner could claim the block timestamp to be up to two hours in the future, and ...
Raghav Sood's user avatar
  • 17.1k

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