Bitcoin Forum
September 21, 2018, 05:17:13 AM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Question regarding BIP-112, BIP68 CSV and nSequence  (Read 29 times)
mandelduck
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
January 03, 2018, 02:45:01 PM
 #1

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

Posts: 1537507033

View Profile Personal Message (Offline)

Ignore
1537507033
Reply with quote  #2

1537507033
Report to moderator
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1537507033
Hero Member
*
Offline Offline

Posts: 1537507033

View Profile Personal Message (Offline)

Ignore
1537507033
Reply with quote  #2

1537507033
Report to moderator
1537507033
Hero Member
*
Offline Offline

Posts: 1537507033

View Profile Personal Message (Offline)

Ignore
1537507033
Reply with quote  #2

1537507033
Report to moderator
1537507033
Hero Member
*
Offline Offline

Posts: 1537507033

View Profile Personal Message (Offline)

Ignore
1537507033
Reply with quote  #2

1537507033
Report to moderator
achow101
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1638


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
January 03, 2018, 07:06:16 PM
 #2

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.

mandelduck
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
January 11, 2018, 08:20:03 AM
 #3

thanks for the reply I seem to have gotten it working and also found a bip68 lib for bitcoinjs as well
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!