Skip to content

Commit 05d3cc2

Browse files
committed
descriptor: fix key parsing error handling in parse_desc
1 parent e49c1db commit 05d3cc2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/descriptor/mod.rs

+1-1
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

+11
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,17 @@ impl<E> TranslateErr<E> {
364364
}
365365
}
366366

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

0 commit comments

Comments
 (0)