rust-bitcoin / rust-miniscript

Support for Miniscript and Output Descriptors for rust-bitcoin
Creative Commons Zero v1.0 Universal
343 stars 135 forks source link

Compiling thresh-policy with after(0) or older(0) (such as "thresh(2,after(0),pk(),pk())") causes panic #44

Closed practicalswift closed 4 years ago

practicalswift commented 5 years ago

Crash location:

https://github.com/apoelstra/rust-miniscript/blob/2aee5708e3e4f29a4d41301adc998d6b95fc4c76/src/policy/compiler.rs#L449-L452

When compiling thresh(2,after(0),pk(),pk()):

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: 
Error { fragment: [TYPECHECK FAILED]older(0), error: ZeroTime }', src/libcore/result.rs:1084:5

When compiling thresh(2,older(0),pk(),pk()):

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: 
Error { fragment: [TYPECHECK FAILED]older(0), error: ZeroTime }', src/libcore/result.rs:1084:5

FWIW, a related problem with after(N)/older(N) handling with invalid N was found and fixed in the C++ implementation: https://github.com/sipa/miniscript/pull/4

sanket1729 commented 4 years ago

Fixed by #50