Skip to content

Commit

Permalink
Merge pull request #49 from BitGo/BTC-1743.fix-wrap-psbt
Browse files Browse the repository at this point in the history
fix: pass descriptor by reference in update_*_with_descriptor
  • Loading branch information
OttoAllmendinger authored Jan 14, 2025
2 parents 16695f2 + 574de10 commit 8cd9e06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/wasm-miniscript/src/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ impl WrapPsbt {
pub fn update_input_with_descriptor(
&mut self,
input_index: usize,
descriptor: WrapDescriptor,
descriptor: &WrapDescriptor,
) -> Result<(), JsError> {
match descriptor.0 {
match &descriptor.0 {
WrapDescriptorEnum::Definite(d) => self
.0
.update_input_with_descriptor(input_index, &d)
Expand All @@ -47,9 +47,9 @@ impl WrapPsbt {
pub fn update_output_with_descriptor(
&mut self,
output_index: usize,
descriptor: WrapDescriptor,
descriptor: &WrapDescriptor,
) -> Result<(), JsError> {
match descriptor.0 {
match &descriptor.0 {
WrapDescriptorEnum::Definite(d) => self
.0
.update_output_with_descriptor(output_index, &d)
Expand Down
5 changes: 3 additions & 2 deletions packages/wasm-miniscript/test/psbt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ function describeUpdateInputWithDescriptor(
describe("Wrapped PSBT updateInputWithDescriptor", function () {
it("should update the input with the descriptor", function () {
const wrappedPsbt = toWrappedPsbt(psbt);
wrappedPsbt.updateInputWithDescriptor(0, descriptor.atDerivationIndex(index));
wrappedPsbt.updateOutputWithDescriptor(0, descriptor.atDerivationIndex(index));
const descriptorAtDerivation = descriptor.atDerivationIndex(index);
wrappedPsbt.updateInputWithDescriptor(0, descriptorAtDerivation);
wrappedPsbt.updateOutputWithDescriptor(0, descriptorAtDerivation);
const updatedPsbt = toUtxoPsbt(wrappedPsbt);
assertEqualPsbt(updatedPsbt, getFixtureAtStage("unsigned").psbt);
updatedPsbt.signAllInputsHD(rootWalletKeys.triple[0]);
Expand Down

0 comments on commit 8cd9e06

Please sign in to comment.