1

So far my understanding is that when you create an op_csv output the value entered before the OP_NOP3 is an arbitary number, lets say 10. This number can be interpreted as block based of time based depending on the nSequence value set when spending (according to bip-0068).

What I am confused about is the following, say my first transaction has a redeem script as follows

10 OP_NOP3, OP_DROP, alicePubKey, OP_CHECKSIG

Does this mean that the spender, who sets the nSequence type flag (1<<22) to either on or off whilst creating the spend transaction, effectively has the ability to decide whether the 10 is interpreted as block based or time based?

It seems the granularity of the time based option is 512 seconds, so close to an average block time.

Thanks

1

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 decimal 10 to a 32 bit integer which would be

00000000000000000000000000001010

according to bip68 https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki

the last 16 bits is the value i.e. 10 in binary signed twos compliment is 0000000000001010

the first 16 bits represents the flags, so as they are all 0s it means the disable flag is set to off and the type flag is set to off which means the number is interpreted as blocks

however if I did this

00000000010000000000000000001010

it would be interpreted as time span, i.e. 10 * 512 seconds

for anybody like me who needs to stop thinking in terms of decimal/ints and start using 32 uint and thinking in bits/bitshift operations etc there's a handy bitcoin-js lib which will convert it for you

https://github.com/bitcoinjs/bip68

  • If your answer is correct and addresses the question you can help Bitcoin.SE by marking it as accepted so that the question does not remain as "unanswered". – Willtech Mar 4 '18 at 6:50
  • yep I tried but wasnt allowed to as my account was too new or something – MandelDuck Jun 26 '18 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.