Author

Topic: Question regarding BIP-112, BIP68 CSV and nSequence (Read 142 times)

newbie
Activity: 9
Merit: 0
thanks for the reply I seem to have gotten it working and also found a bip68 lib for bitcoinjs as well
staff
Activity: 3458
Merit: 6793
Just writing some code
convert the lock number of 169 into binary
10101001

pad some zeros at the end to make it 16 bits long
0000000010101001
Bitcoin uses little endian numbers, so these need to be reversed.

Otherwise, that looks correct.
newbie
Activity: 9
Merit: 0
Hi

I have a question about BIP112 and BIP68 (I am using bitcoin-js lib to implement)

I locked up an output using csv and set the lock time to decimal 169, if I understand correctly this should be around 1 day (as 512 * 169 is the num of seconds in a day roughly)

bitcoin.script.number.encode(169),
bitcoin.opcodes.OP_NOP3,
bitcoin.opcodes.OP_DROP

I understand in the tx that spends the utxo I need to set the nSequence number according to bip68

Here I get a little confused, but I created the following decimal number 4194473 to set the nSequence based on the following logic

create a string to represent the 32 byte sequence and set the disable flag to 0 and the version flag to 1 (to interpret as time and not blocks)
0xxxxxxxx1xxxxxx

convert the lock number of 169 into binary
10101001

pad some zeros at the end to make it 16 bits long
0000000010101001

append it to the end of the first binary number with disable and version flag
00000000010000000000000010101001

convert to decimal so I can set the number easily in bitcoin-js
input["sequence"]=4194473

I guess I will find out if I can redeem in a day but is this the correct understanding of BIP 112 and BIP 68?

Thanks
Jump to: