fix(dsl): handle invalid RelLockTime without panicking#404
fix(dsl): handle invalid RelLockTime without panicking#404ValuedMammal merged 1 commit intobitcoindevkit:masterfrom
RelLockTime without panicking#404Conversation
|
@AmosOO7 you need to squash these two commits |
3fc4208 to
0d20401
Compare
|
Done, thanks @luisschwab |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #404 +/- ##
==========================================
+ Coverage 79.77% 79.91% +0.14%
==========================================
Files 24 24
Lines 5266 5283 +17
Branches 241 241
==========================================
+ Hits 4201 4222 +21
+ Misses 988 984 -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:
|
9024418 to
442c242
Compare
|
Thank you @AmosOO7. As a follow-up you could consider fixing the |
Hello @ValuedMammal, thank you for the review, I will also take a look at the |
2a51030 to
2b3df6f
Compare
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 returns
`DescriptorError::Miniscript(Error::RelativeLockTimeError)` 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
2b3df6f to
e101b9e
Compare
RelLockTime without panicking
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 consensus limit. The new implementation returns a proper error instead, bringing the macro in line with usualResult-basederror handling elsewhere in the library.
Changes
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 newdescriptor_macro.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.