Skip to content

Commit

Permalink
fix xpub handling
Browse files Browse the repository at this point in the history
  • Loading branch information
netbonus committed Jan 17, 2025
1 parent 1e17d74 commit 98e7033
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/__test__/e2e/xpub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ describe('XPUB', () => {
flag: LatticeGetAddressesFlag.secp256k1Xpub,
});
expect(xpub).toHaveLength(1);
expect(xpub[0]).toMatch(/^xpub/); // XPUB should start with "xpub"
});
expect(xpub[0].startsWith('xpub')).toBe(true);
});
});
7 changes: 6 additions & 1 deletion src/functions/getAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ export const decodeGetAddressesResponse = (
// Return the UTF-8 representation
const len = addrBytes.indexOf(0); // First 0 is the null terminator
if (len > 0) {
addrs.push(addrBytes.slice(0, len).toString());
// Clean control characters from the string before adding to array
const cleanStr = addrBytes
.slice(0, len)
.toString()
.replace(/[\x00-\x1F\x7F-\x9F]/g, '');

Check failure on line 205 in src/functions/getAddresses.ts

View workflow job for this annotation

GitHub Actions / Build

Unexpected control character(s) in regular expression: \x00, \x1f
addrs.push(cleanStr);
}
}
}
Expand Down

0 comments on commit 98e7033

Please sign in to comment.