Skip to content

support to set nSequence as a number of second chunks #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mr-zwets opened this issue Mar 3, 2025 · 1 comment
Open

support to set nSequence as a number of second chunks #289

mr-zwets opened this issue Mar 3, 2025 · 1 comment
Labels
enhancement New feature or request javascript-sdk Relates to the CashScript JavaScript SDK

Comments

@mr-zwets
Copy link
Member

mr-zwets commented Mar 3, 2025

support to set nSequence as a number of second chunks

Currently this is not supported a laid out in the docs:

Because of the way time locks work, a corresponding time lock needs to be added to the transaction. This can be done in the CashScript SDK through [addInput()][addInput()] by passing the sequence as optional argument. However, the value passed into this function will always be treated as a number of blocks, so it is currently not supported to use this.age as a number of second chunks.

@mr-zwets mr-zwets added enhancement New feature or request javascript-sdk Relates to the CashScript JavaScript SDK labels Mar 3, 2025
@mr-zwets
Copy link
Member Author

mr-zwets commented May 4, 2025

@kiok46 mentioned the following

I was testing out the nSequence parameter for both block-based and time-based relative locking by setting 22nd bit, so I set it to 0x400001 i.e 4193405 it worked, and in bitcann I have already enforced that at the contract level to always ensure that the nsequence is added as the correct value so it always work. (forced that it must be added in input correctly)

I was this comment in the cashscript next documentation: https://next.cashscript.org/docs/language/globals#thisage

but I tested with the values I mentioned above for 4193405 and for 4193406, it did was is expected increase in relative locking time of 512 seconds for increasing by 1 bit.

so it seems this behavior is supported in a roundabout way, the user needs to pass a correctly encoded hex number (or the corresponding decimal number) to the sequence InputOption but can use 'seconds-chunks' instead of a 'block' value for the sequence number

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript-sdk Relates to the CashScript JavaScript SDK
Projects
None yet
Development

No branches or pull requests

1 participant