Skip to content

Commit 40514f5

Browse files
committed
descriptor: fix key parsing error handling in parse_desc
1 parent 4ff0840 commit 40514f5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/descriptor/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ impl Descriptor<DescriptorPublicKey> {
771771
let descriptor = Descriptor::<String>::from_str(s)?;
772772
let descriptor = descriptor
773773
.translate_pk(&mut keymap_pk)
774-
.map_err(|e| e.expect_translator_err("No Outer context errors"))?;
774+
.map_err(TranslateErr::flatten)?;
775775

776776
Ok((descriptor, keymap_pk.0))
777777
}

src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,17 @@ impl<E> TranslateErr<E> {
365365
}
366366
}
367367

368+
impl TranslateErr<Error> {
369+
/// If we are doing a translation where our "outer error" is the generic
370+
/// Miniscript error, eliminate the `TranslateErr` type which is just noise.
371+
pub fn flatten(self) -> Error {
372+
match self {
373+
Self::TranslatorErr(e) => e,
374+
Self::OuterError(e) => e,
375+
}
376+
}
377+
}
378+
368379
impl<E> From<E> for TranslateErr<E> {
369380
fn from(v: E) -> Self { Self::TranslatorErr(v) }
370381
}

0 commit comments

Comments
 (0)