Open
Conversation
Member
|
@AmosOO7 you need to squash these two commits |
The `descriptor!` DSL previously used `.expect("valid \`RelLockTime\`")` when converting an integer into `miniscript::RelLockTime`, causing a panic
for out-of-range values (e.g. values with the high bit set).
This change matches on `RelLockTime::from_consensus(...)` and returns `DescriptorError::RelLockTime(...)` for invalid values, so callers can
handle errors cleanly instead of crashing.
Includes new tests verifying valid/invalid values and ensuring the macro no longer panics.
Ran cargo fmt and cargo clippy, and just p
3fc4208 to
0d20401
Compare
Author
|
Done, thanks @luisschwab |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #404 +/- ##
==========================================
- Coverage 79.77% 79.76% -0.02%
==========================================
Files 24 24
Lines 5266 5283 +17
Branches 241 241
==========================================
+ Hits 4201 4214 +13
- Misses 988 992 +4
Partials 77 77
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a panic that occurred when the
descriptor!DSL macro was invoked with an out-of-range relative locktime value. Prior to this change,older(<value>)used.expect("valid \RelLockTime`")onRelLockTime::from_consensus(), which panicked if the supplied value did not fit within the 24-bit consensus limit. The new implementation returns a proper error instead, bringing the macro in line with usualResult`-basederror handling elsewhere in the library.
Changes
DescriptorError::RelLockTime(miniscript::RelLockTimeError)variant plusDisplayandFromimpls.dsl.rsolderrule to match on the result ofRelLockTime::from_consensus()and propagate errors.tests/test_rellocktime_issue.rs:No public API changes were made; the fix affects only the macro and error enum.
Testing
All existing tests (
cargo test) continue to pass. Added a newtest_rellocktime_issue.rstest file exercising the DSL macro directly, and ran full descriptor and wallet test suites to ensure there are noregressions. All tests currently succeed.
Review Notes
RelLockTimeErroralready provides a helpfulDisplayimplementation courtesy of theminiscriptcrate; the error variant simply wraps it.Checklist
just pbefore pushingBugfixes:
Related issue
Closes #403
Thanks for the review! This is a small but important stability fix that prevents unexpected panics when using the DSL macros programmatically.