Skip to content

Commit

Permalink
feat: portalSingleSigSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
cakesoft-vaibhav committed Feb 21, 2025
1 parent 086a9b4 commit b0925b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/hardware/portal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const isReading = () => {
return keepReading;
};

export const getPortalDetailsFromDescriptor = (descriptor: string) => {
export const getPortalDetailsFromDescriptor = (descriptor: string, isMultisig: boolean) => {
const regex = /\[([0-9a-fA-F]+)\/([0-9'\/]+)\]([xtyz][A-Za-z0-9]+)/;
// /^\[(\w+\/(?:\d+'?\/)*\d+')\](tpub[a-zA-Z0-9]+)$/; // single sig
const match = descriptor.match(regex);
Expand All @@ -178,8 +178,7 @@ export const getPortalDetailsFromDescriptor = (descriptor: string) => {
const mfp = match[1].toUpperCase();
const derivationPath = 'm/' + match[2];
const xpub = match[3];
xpubDetails[XpubTypes.P2WSH] = { xpub, derivationPath };

xpubDetails[isMultisig ? XpubTypes.P2WSH : XpubTypes.P2WPKH] = { xpub, derivationPath };
return { xpub, derivationPath, masterFingerprint: mfp?.toUpperCase(), xpubDetails };
} else {
throw new Error('Invalid descriptor format');
Expand Down
6 changes: 3 additions & 3 deletions src/screens/SigningDevices/SetupPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function SetupPortal({ route }) {
mode,
signer,
isMultisig,
accountNumber,
accountNumber = 0,
signTransaction,
addSignerFlow = false,
vaultId,
Expand Down Expand Up @@ -201,8 +201,8 @@ function SetupPortal({ route }) {
const getPortalDetails = async () => {
await PORTAL.startReading();
await checkAndUnlock(cvc, setPortalStatus);
const descriptor = await PORTAL.getXpub({ accountNumber, isMultisig: true });
const signer = PORTAL.getPortalDetailsFromDescriptor(descriptor.xpub);
const descriptor = await PORTAL.getXpub({ accountNumber, isMultisig });
const signer = PORTAL.getPortalDetailsFromDescriptor(descriptor.xpub, isMultisig);
return signer;
};

Expand Down

0 comments on commit b0925b4

Please sign in to comment.