Skip to content

Commit

Permalink
feat: add updateOutputWithDescriptor to WrapPsbt
Browse files Browse the repository at this point in the history
Issue: BTC-1451
  • Loading branch information
OttoAllmendinger committed Oct 24, 2024
1 parent d8b182b commit e8b4e5e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/wasm-miniscript/src/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ impl WrapPsbt {
}
}

#[wasm_bindgen(js_name = updateOutputWithDescriptor)]
pub fn update_output_with_descriptor(
&mut self,
output_index: usize,
descriptor: WrapDescriptor,
) -> Result<(), JsError> {
match descriptor.0 {
WrapDescriptorEnum::Definite(d) => self
.0
.update_output_with_descriptor(output_index, &d)
.map_err(JsError::from),
WrapDescriptorEnum::Derivable(_, _) => Err(JsError::new(
"Cannot update output with a derivable descriptor",
)),
WrapDescriptorEnum::String(_) => {
Err(JsError::new("Cannot update output with a string descriptor"))
}
}
}

#[wasm_bindgen(js_name = finalize)]
pub fn finalize_mut(&mut self) -> Result<(), JsError> {
self.0
Expand Down

0 comments on commit e8b4e5e

Please sign in to comment.