19 votes
Accepted

What does the sequence in a transaction input mean?

Original meaning of nSequence in transactions nSequence is a 4 byte input level feature. The original meaning of nSequence was to allow modification of transactions in the mempool. So, if the ...
Ugam Kamat's user avatar
  • 7,398
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

Why does the time interval for OP_CSV need to be in the nSequence field when it is already in the script?

They do not serve the same function. Putting a relative locktime in the nSequence value means "this transaction cannot be mined until its input is at least that old". Putting a relative ...
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
5 votes
Accepted

What does nVersion represent in Bitcoin transaction?

The nVersion does not affect the serialization of transactions. So, which fields are present does not change depending on the nversion value. There is a mechanism for adding additional fields, but it'...
Pieter Wuille's user avatar
4 votes
Accepted

Why do Anchor Outputs need to enforce an nSequence of 1?

Because there must always be exactly one directly spendable output per party, in order to avoid one party to be able to "exhaust" the carve-out. With two CPFP-ble outputs, one party could ...
Antoine Poinsot's user avatar
4 votes

At what height exactly can a relative time-locked output be spent?

A transaction may spend an OP_CSV-locked TXO s blocks after it was created. I.e. if it was locked for s blocks, and created in block n, the transaction spending it may be included in block n+s. If ...
Murch's user avatar
  • 74.6k
3 votes
Accepted

What would happen if the non-upgraded node to BIP68 receives block with the transaction where one of its nSequence is different than 0xffffffff?

Not upgraded nodes will accept the block (since nSequence does not have meaning) and all other (upgraded) nodes will not? Yes, that is what happens. How is that solved? The answer is the same for ...
Pieter Wuille's user avatar
3 votes
Accepted

At what height exactly can a relative time-locked output be spent?

What is the lowest blockheight which may contain a transaction spending that UTXO? A UTXO created in block number n, can be spent in block number m (and not before), if the transaction input spending ...
Pieter Wuille's user avatar
3 votes

Does `0 OP_CSV` force the spending transaction to signal BIP125 replacability?

Yes, since the OP_CSV requires setting a non-maximal nSequence in the spending input, an input spending it is forced to signal replaceability. Ruben Somsen mentions that he used this construction in ...
Murch's user avatar
  • 74.6k
3 votes
Accepted

Does the bitcoin testnet3 network support Segwit and OP_CSV?

Yes, testnet3 supports SegWit as of block 834624. Yes, testnet3 supports both OP_CSV and OP_CLTV. You might also be interested to know that there is a segnet test network on another port number. See ...
amaclin's user avatar
  • 6,730
2 votes
Accepted

Is CheckSequenceVerify only a stop-gap measure?

CSV is not a stop-gap solution. Before you can say that, you first need to define what the problem is. CSV solves the problem that you can't use CLTV in contracts that need a spending delay where the ...
Pieter Wuille's user avatar
2 votes
Accepted

Bitcoin Script: mandatory-script-verify-flag-failed Script failed an OP_EQUALVERIFY operation

The failure is happening because hash160(30450221009b813cf658ec2c30e68fd23c369c348fd5f915f77b49581a945aa2f2f2d3c8aa022058f6a7eb78b2132d24cc260699fdc158fda6f3a0d10bc3c52bacccc03bb6b8cb) is not ...
Alistair Mann's user avatar
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
Accepted

Error: non-mandatory-script-verify-flag (unknown error) (code 64) with OP_CHECKSEQUENCEVERIFY (OP_CSV)

The error gets resolved when I use OP_10 instead of 030a0000 to push the number 10 on the stack. It appears that the bitcoin optimizes the size of the scripts. So to push any number from 2 to 16, OP_2 ...
Dhairya Mittal's user avatar
2 votes
Accepted

problem sending relative locktime (OP_CSV) transaction

OP_CHECKSEQUENCEVERIFY is only available for transactions with their version number set to 2. Your transactions have a version number of 1, and so they fail.
Ava Chow's user avatar
  • 70.1k
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
1 vote
Accepted

Is the image in BIP68 represented in context of little or big endian?

The image is most significant bit first, aka big endian. When discussing bit shifting, or numbers in general, in computer science, the notation is always big endian since that's the way that the vast ...
Ava Chow's user avatar
  • 70.1k
1 vote

Sequence valid before time

I just see that BIP68 states // Time-based relative lock-times are measured from the // smallest allowed timestamp of the block containing the // txout being spent, which is the median ...
monkeyUser's user avatar
1 vote
Accepted

Are both CSV and nLocktime unnecessary in Eltoo?

Anthony Towns' recent draft uses CLTV, which also uses nLocktime.
Janus Troelsen's user avatar
1 vote

Problem using op_checksequenceverify (op_csv) with relative time flag

i manage to find answer for myself. OP_CSV date consensus is based on median time past (mtp), not block's confirmed date. once funding tx above has been confirmed, it is located in block#1609592 ...
Atlas Chiew's user avatar
1 vote
Accepted

How many bytes long should nSequence be?

The sequence number is always 4 bytes, it is a fixed size, little endian, 32 bit integer which makes it always 4 bytes. What you are missing is the scriptSig. The scriptSig always begins with the ...
Ava Chow's user avatar
  • 70.1k
1 vote
Accepted

Could someone provide an example of a tx spending from an input with a relative LockTime?

If you look at https://blockstream.info/address/bc1qdv0fk4c73fem89s708pzdny8q25d7k5nrckckp87c8alwaw803fq3mqrpz you will see that there are two transactions. The first one https://blockstream.info/...
Rene Pickhardt's user avatar
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,398
1 vote
Accepted

What is transaction "finality"?

Why is a "bad" locktime ok as long as all sequences are final? The tx won't be mineable anyway, right? According to BIP 68, setting nSequence value to 0xFFFFFFFF for every input in the transaction ...
Ugam Kamat's user avatar
  • 7,398
1 vote

Why are some of my peers rejecting this CSV transaction?

First of all, the Bitcoin network does not have a time granularity of minutes. At best, you can expect things to be within hours of what you want the time to be. So timelocking something for 10 ...
Ava Chow's user avatar
  • 70.1k
1 vote

CHECKSEQUENCEVERIFY After x time of last transaction

Whereas it seems, that this is not directly possible, cause bitcoin script does not allow to reference a transaction "within last 30 days", one could think about a "workaround" with a business logic ...
pebwindkraft's user avatar
  • 5,076
1 vote

Question about nSequence with regard to bip-0112 and bip-0068

So turns out the sender has to set the same number in the nSequence that is in the script. In the case above 10 will be interpreted as 10 blocks because I was using bitcoinJS lib which converts the ...
MandelDuck's user avatar

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