Bitcoin Forum
April 24, 2024, 01:12:59 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Can some one help explain OP_CSV and nSequence number?  (Read 223 times)
mandelduck (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
November 24, 2017, 05:22:07 PM
Last edit: November 25, 2017, 06:44:36 AM by mandelduck
 #1

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
1713921179
Hero Member
*
Offline Offline

Posts: 1713921179

View Profile Personal Message (Offline)

Ignore
1713921179
Reply with quote  #2

1713921179
Report to moderator
"I'm sure that in 20 years there will either be very large transaction volume or no volume." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713921179
Hero Member
*
Offline Offline

Posts: 1713921179

View Profile Personal Message (Offline)

Ignore
1713921179
Reply with quote  #2

1713921179
Report to moderator
mandelduck (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
December 19, 2017, 06:10:43 AM
Last edit: December 21, 2017, 03:28:43 PM by mandelduck
 #2

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
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!