Skip to content

Commit

Permalink
include addressType for valid PSBT translation in SignMultisigTransac…
Browse files Browse the repository at this point in the history
…tion (#159)
  • Loading branch information
chadchapnick authored Dec 12, 2024
1 parent 48da7df commit 3e4b783
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-berries-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@caravan/wallets": patch
---

include addressType for accurate PSBT translation in SignMultisigTransaction
1 change: 1 addition & 0 deletions packages/caravan-wallets/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ export function SignMultisigTransaction({
bip32Paths,
psbt,
keyDetails,
addressType: walletConfig.addressType,
returnSignatureArray,
});
default:
Expand Down
2 changes: 1 addition & 1 deletion packages/caravan-wallets/src/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ export class LedgerSignMultisigTransaction extends LedgerBitcoinInteraction {

const translatedPsbt = translatePSBT(
network,
P2SH,
v2Options?.addressType || P2SH,
this.psbt,
keyDetails
);
Expand Down
12 changes: 9 additions & 3 deletions packages/caravan-wallets/src/trezor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,12 @@ describe("trezor", () => {
});
});

function psbtInteractionBuilder(tx, keyDetails, returnSignatureArray) {
function psbtInteractionBuilder(
tx,
keyDetails,
returnSignatureArray,
addressType
) {
return new TrezorSignMultisigTransaction({
network: tx.network,
inputs: [],
Expand All @@ -310,6 +315,7 @@ describe("trezor", () => {
psbt: tx.psbt,
keyDetails,
returnSignatureArray,
addressType,
});
}

Expand All @@ -319,7 +325,7 @@ describe("trezor", () => {
xfp: ROOT_FINGERPRINT,
path: "m/45'/1'/100'",
};
const interaction = psbtInteractionBuilder(tx, keyDetails, false);
const interaction = psbtInteractionBuilder(tx, keyDetails, false, tx.braidDetails.addressType);
const [method, params] = interaction.connectParams();
expect(method).toEqual(TrezorConnect.signTransaction);
expect((params as any).coin).toEqual(trezorCoin(tx.network));
Expand All @@ -337,7 +343,7 @@ describe("trezor", () => {
xfp: ROOT_FINGERPRINT,
path: "m/45'/0'/100'",
};
const interaction = psbtInteractionBuilder(tx, keyDetails, true);
const interaction = psbtInteractionBuilder(tx, keyDetails, true, tx.braidDetails.addressType);
const [method, params] = interaction.connectParams();
expect(method).toEqual(TrezorConnect.signTransaction);
expect((params as any).coin).toEqual(trezorCoin(tx.network));
Expand Down
3 changes: 2 additions & 1 deletion packages/caravan-wallets/src/trezor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ export class TrezorSignMultisigTransaction extends TrezorInteraction {
psbt,
keyDetails,
returnSignatureArray,
addressType,
}) {
super({ network });
if (!psbt || !keyDetails) {
Expand All @@ -715,7 +716,7 @@ export class TrezorSignMultisigTransaction extends TrezorInteraction {
}
const translatedPsbt = translatePSBT(
network,
P2SH,
addressType,
this.psbt,
keyDetails
);
Expand Down

0 comments on commit 3e4b783

Please sign in to comment.