Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: Ilsk on January 26, 2017, 03:41:35 PM



Title: How does BIP0068 work?
Post by: Ilsk on January 26, 2017, 03:41:35 PM
I am trying to create a transaction with relative lock time using BIP 68 (https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki), but I have some problem setting the sequence number correctly.

I tried to leave the bit (1<<31) not set to have the sequence number interpreted as relative lock time, the bit (1<<22) not set so the relative lock-time specifies a number of blocks and not a timespan, and then since the BIP only interprets 16 bits of the sequence number as relative lock-time, I applied the mask 0x0000ffff to the sequence field, trying to set some very large number such as 0x0000afff.

I did some tests on both testnet and mainnet and every time the transaction was immediately recognised as valid, instead of remaining invalid until the number of blocks specified in the nsequence were passed.

Is there someone who can explain me what did I do wrong, or have an example of a correctly set relative lock time?

NB: At the moment I am not interested in the CSV, I'm just trying to understand how the relative lock time specified in BIP68 works.


Title: Re: How does BIP0068 work?
Post by: MattWin on February 15, 2017, 01:22:49 AM
I'm interested as well. Does anybody on this forum know?


Title: Re: How does BIP0068 work?
Post by: achow101 on February 15, 2017, 01:45:26 AM
Were your transactions Version 2 transactions?


Title: Re: How does BIP0068 work?
Post by: Ilsk on February 15, 2017, 02:49:38 AM
Were your transactions Version 2 transactions?

That was exactly my mistake, even if the BIP clearly says to do so I didn't noticed it. Now I tried a test transaction and the client gave me the following error when the sequence number was too high:

Code:
64: non-BIP68-final (code -26) 

Then I decreased the sequence number and the transaction has been correctly broadcasted.

Thank you so much for you help, much appreciated, I spent a lot of time trying to figure out what I was doing wrong


Title: Re: How does BIP0068 work?
Post by: cygan on August 05, 2023, 04:18:07 PM
how bip68 works and how the relative lock-time using nsequence actually looks like can be seen very well in the 4 following slides

https://www.talkimg.com/images/2023/08/05/G6rcC.jpeg https://www.talkimg.com/images/2023/08/05/G61qb.jpeg
https://www.talkimg.com/images/2023/08/05/G6cMv.jpeg https://www.talkimg.com/images/2023/08/05/G6hJH.jpeg