<p>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</p>

<p>00000000000000000000000000001010</p>

<p>according to bip68 <a href="https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki" rel="nofollow noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki</a></p>

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

<p>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 </p>

<p>however if I did this</p>

<p>00000000010000000000000000001010</p>

<p>it would be interpreted as time span, i.e. 10 * 512 seconds</p>

<p>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</p>

<p><a href="https://github.com/bitcoinjs/bip68" rel="nofollow noreferrer">https://github.com/bitcoinjs/bip68</a></p>

CC BY-SA 3.0
2018-03-04T06:50:32.580Z
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
CC BY-SA 4.0
2018-06-26T10:32:04.577Z
yep I tried but wasnt allowed to as my account was too new or something
MandelDuck
CC BY-SA 3.0
2018-01-30T08:00:01.383Z
2018-01-30T08:00:01.383Z
MandelDuck
<p>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).</p>

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

<p><code>10
OP_NOP3,
OP_DROP,
alicePubKey,
OP_CHECKSIG</code></p>

<p>Does this mean that the spender, who sets the nSequence type flag (1&lt;&lt;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? </p>

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

<p>Thanks</p>

<checksequenceverify>
Question about nSequence with regard to bip-0112 and bip-0068
MandelDuck
# Question about nSequence with regard to bip-0112 and bip-0068

(Asked by: username_0 on 2017-12-21)

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

**Tags:** checksequenceverify


---

## 1 answers

### Answer by username_0 on 2018-01-30. Score: 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>

> **Comments:**
> **username_1**: 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".  
> **username_0**: yep I tried but wasnt allowed to as my account was too new or something  

---

