Skip to content

Commit e8b4e5e

Browse files
feat: add updateOutputWithDescriptor to WrapPsbt
Issue: BTC-1451
1 parent d8b182b commit e8b4e5e

File tree

1 file changed

+20
-0
lines changed
  • packages/wasm-miniscript/src

1 file changed

+20
-0
lines changed

packages/wasm-miniscript/src/psbt.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ impl WrapPsbt {
4343
}
4444
}
4545

46+
#[wasm_bindgen(js_name = updateOutputWithDescriptor)]
47+
pub fn update_output_with_descriptor(
48+
&mut self,
49+
output_index: usize,
50+
descriptor: WrapDescriptor,
51+
) -> Result<(), JsError> {
52+
match descriptor.0 {
53+
WrapDescriptorEnum::Definite(d) => self
54+
.0
55+
.update_output_with_descriptor(output_index, &d)
56+
.map_err(JsError::from),
57+
WrapDescriptorEnum::Derivable(_, _) => Err(JsError::new(
58+
"Cannot update output with a derivable descriptor",
59+
)),
60+
WrapDescriptorEnum::String(_) => {
61+
Err(JsError::new("Cannot update output with a string descriptor"))
62+
}
63+
}
64+
}
65+
4666
#[wasm_bindgen(js_name = finalize)]
4767
pub fn finalize_mut(&mut self) -> Result<(), JsError> {
4868
self.0

0 commit comments

Comments
 (0)