descriptors: lifting *can* fail
Not sure what i was thinking when writing this.
This commit is contained in:
parent
8d33f49935
commit
f7924fb9dc
@ -25,6 +25,7 @@ pub enum LianaPolicyError {
|
||||
/// The spending policy is not a valid Miniscript policy: it may for instance be malleable, or
|
||||
/// overflow some limit.
|
||||
InvalidPolicy(compiler::CompilerError),
|
||||
PolicyAnalysis(miniscript::Error),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for LianaPolicyError {
|
||||
@ -54,6 +55,7 @@ impl std::fmt::Display for LianaPolicyError {
|
||||
"Descriptor is not compatible with a Liana spending policy."
|
||||
),
|
||||
Self::InvalidPolicy(e) => write!(f, "Invalid Miniscript policy: {}", e),
|
||||
Self::PolicyAnalysis(e) => write!(f, "Analyzing the policy of the miniscript: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -452,7 +454,7 @@ impl LianaPolicy {
|
||||
};
|
||||
let policy = ms
|
||||
.lift()
|
||||
.expect("Lifting can't fail on a Miniscript")
|
||||
.map_err(LianaPolicyError::PolicyAnalysis)?
|
||||
.normalized();
|
||||
|
||||
// The policy must always be "1 of N spending paths" with at least an always-available
|
||||
|
||||
@ -1405,5 +1405,10 @@ mod tests {
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unliftable_miniscript() {
|
||||
LianaDescriptor::from_str("wsh(0)").unwrap_err();
|
||||
}
|
||||
|
||||
// TODO: test error conditions of deserialization.
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user