Bitcoin Forum
May 06, 2024, 05:00:49 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Question regarding BIP-112, BIP68 CSV and nSequence  (Read 123 times)
mandelduck (OP)
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
1715014849
Hero Member
*
Offline Offline

Posts: 1715014849

View Profile Personal Message (Offline)

Ignore
1715014849
Reply with quote  #2

1715014849
Report to moderator
"With e-currency based on cryptographic proof, without the need to trust a third party middleman, money can be secure and transactions effortless." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715014849
Hero Member
*
Offline Offline

Posts: 1715014849

View Profile Personal Message (Offline)

Ignore
1715014849
Reply with quote  #2

1715014849
Report to moderator
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6581


Just writing some code


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 (OP)
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:  

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