Skip to content
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

test(wallet): create tx locktime cltv for a specific time #1682

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

f3r10
Copy link

@f3r10 f3r10 commented Nov 13, 2024

Description

This PR adds a unit test that checks the satisfaction of timestamp-based timelocks. The goal is to test the absolute time therefore the variable passed to the miniscript fragment after has to be equal to or greater that 500_000_000 otherwise it would be checking the block height.

Notes to the reviewers

This unit test tries to check if #642 is still an issue.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

@f3r10 f3r10 changed the title test: create tx locktime cltv for a specific time test(wallet): create tx locktime cltv for a specific time Nov 13, 2024
@f3r10 f3r10 marked this pull request as ready for review November 13, 2024 16:44
/// the parameter passed to miniscript fragment `after` has to equal or grather than 500_000_000
/// in order to use a lock based on unix time
pub fn get_test_single_sig_cltv_for_specific_time() -> &'static str {
"wsh(and_v(v:pk(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW),after(500000000)))"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ just a nit but we should use a timestamp that's sometime after the genesis block. Sometimes people use these tests as examples so will make more sense to use a more recent time. Also the number is easier to read in the code with the underscores.

Suggested change
"wsh(and_v(v:pk(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW),after(500000000)))"
"wsh(and_v(v:pk(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW),after(1_734_230_218)))"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to update the descriptor as you mentioned, but there is an error with the format:
descriptors must be valid: Miniscript(Unexpected("unexpected «1_734_230_218»"))
It looks like miniscript does not have support for numbers with underscores.

@@ -160,6 +160,13 @@ pub fn get_test_single_sig_cltv() -> &'static str {
"wsh(and_v(v:pk(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW),after(100000)))"
}

/// `wsh` descriptor with policy `and(pk(A),after(500_000_000))`
/// the parameter passed to miniscript fragment `after` has to equal or grather than 500_000_000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// the parameter passed to miniscript fragment `after` has to equal or grather than 500_000_000
/// the parameter passed to miniscript fragment `after` has to equal or greater than 500_000_000

@notmandatory notmandatory added this to the 1.0.0-beta milestone Nov 15, 2024
@notmandatory notmandatory removed this from the 1.0.0-beta milestone Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants