Skip to content

Commit 8cd9e06

Browse files
Merge pull request #49 from BitGo/BTC-1743.fix-wrap-psbt
fix: pass descriptor by reference in update_*_with_descriptor
2 parents 16695f2 + 574de10 commit 8cd9e06

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

packages/wasm-miniscript/src/psbt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ impl WrapPsbt {
2727
pub fn update_input_with_descriptor(
2828
&mut self,
2929
input_index: usize,
30-
descriptor: WrapDescriptor,
30+
descriptor: &WrapDescriptor,
3131
) -> Result<(), JsError> {
32-
match descriptor.0 {
32+
match &descriptor.0 {
3333
WrapDescriptorEnum::Definite(d) => self
3434
.0
3535
.update_input_with_descriptor(input_index, &d)
@@ -47,9 +47,9 @@ impl WrapPsbt {
4747
pub fn update_output_with_descriptor(
4848
&mut self,
4949
output_index: usize,
50-
descriptor: WrapDescriptor,
50+
descriptor: &WrapDescriptor,
5151
) -> Result<(), JsError> {
52-
match descriptor.0 {
52+
match &descriptor.0 {
5353
WrapDescriptorEnum::Definite(d) => self
5454
.0
5555
.update_output_with_descriptor(output_index, &d)

packages/wasm-miniscript/test/psbt.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ function describeUpdateInputWithDescriptor(
4343
describe("Wrapped PSBT updateInputWithDescriptor", function () {
4444
it("should update the input with the descriptor", function () {
4545
const wrappedPsbt = toWrappedPsbt(psbt);
46-
wrappedPsbt.updateInputWithDescriptor(0, descriptor.atDerivationIndex(index));
47-
wrappedPsbt.updateOutputWithDescriptor(0, descriptor.atDerivationIndex(index));
46+
const descriptorAtDerivation = descriptor.atDerivationIndex(index);
47+
wrappedPsbt.updateInputWithDescriptor(0, descriptorAtDerivation);
48+
wrappedPsbt.updateOutputWithDescriptor(0, descriptorAtDerivation);
4849
const updatedPsbt = toUtxoPsbt(wrappedPsbt);
4950
assertEqualPsbt(updatedPsbt, getFixtureAtStage("unsigned").psbt);
5051
updatedPsbt.signAllInputsHD(rootWalletKeys.triple[0]);

0 commit comments

Comments
 (0)