Author

Topic: Can some one help explain OP_CSV and nSequence number? (Read 241 times)

newbie
Activity: 9
Merit: 0
Just to help anybody who may be having a similar issue I think I found the answer to my question

So there are two transactions in question, the first is the P2SH transaction containing the OP_CSV and the second is the spending transaction

In the first transaction if you set an input script to 10 OP_CSV you are saying that you want the second spending transaction that uses this input (or output at this point) as a utxo to have an nSequence number the same or greater.

In other words the stack will validate if your spending transactions inputs nSequence number is not less than the value (10 in this case) placed in the locking script

Reference is here
https://bitcoin.stackexchange.com/questions/45806/op-checksequenceverify-why-to-put-it-into-nsequence-field-if-it-is-already-into

Furthermore the number (10 in this case) can be interpreted as number of blocks or as an actual timespan in seconds according to BIP68 https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki

To me it seems to think of the nSequence number not as a single decimal number but as a list of bits, certain bits in this list of bits are used to represent the number you want to lock the time to, and other certain bits in this list of bits are more like switches that you turn on or off to change the interpretation of the number to number of blocks or timespan in seconds

specifically if you think of your nSequence number as this binary number, the zeros towards the end can be set to represent the value, the 0 towards the middle can be set to change the interpretation and the zero at the end can be set to enable or disable any interpretation at all

0xxxxxxxx0xxxxxx0000000000000000

again more detail is in the official BIP68

anyway i'm sure I made some inaccuracies but thats my understanding so far
newbie
Activity: 9
Merit: 0
Hi
I read about CSV and got totally confused by the who flag, nsequence number part of it

so if you could help me on a few points id be much obliged!

Say I want a utxo to be spendable after say 10 blocks
so my script would be as so? OP_10 OPCSV OP_DROP

1.)what do I set nSequence to on the input?
2.) I have to worry about setting the nSequence value on the spend transaction inputs correct?

Any sample code that anybody has would be helpful to see if anybody has it

Thanks
Jump to: