Skip to content

Commit

Permalink
🐛 (signer-btc): Fix wallet & pub key
Browse files Browse the repository at this point in the history
  • Loading branch information
jdabbech-ledger committed Jan 6, 2025
1 parent 76bdcfd commit 62cd518
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const GET_EXTENDED_PUBLIC_KEY_VALID_RESPONSE = new Uint8Array([
0x59, 0x6d, 0x6b, 0x53, 0x48, 0x4c, 0x66, 0x52, 0x31, 0x56, 0x51, 0x59, 0x6a,
0x35, 0x6a, 0x61, 0x79, 0x71, 0x77, 0x53, 0x59, 0x41, 0x52, 0x6e, 0x75, 0x42,
0x4a, 0x69, 0x50, 0x53, 0x44, 0x61, 0x62, 0x79, 0x79, 0x54, 0x69, 0x43, 0x44,
0x37, 0x42, 0x33, 0x63, 0x6a, 0x50, 0x71, 0x90, 0x00,
0x37, 0x42, 0x33, 0x63, 0x6a, 0x50, 0x71,
]);

describe("GetExtendedPublicKeyCommand", () => {
Expand Down Expand Up @@ -146,7 +146,7 @@ describe("GetExtendedPublicKeyCommand", () => {
// GIVEN
command = new GetExtendedPublicKeyCommand(defaultArgs);
const response = new ApduResponse({
data: GET_EXTENDED_PUBLIC_KEY_VALID_RESPONSE.slice(0, 2),
data: Uint8Array.from([]),
statusCode: new Uint8Array([0x90, 0x00]),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
} from "@internal/app-binder/command/utils/bitcoinAppErrors";
import { BtcCommandUtils } from "@internal/utils/BtcCommandUtils";

const STATUS_CODE_LENGTH = 2;

export type GetExtendedPublicKeyCommandArgs = {
checkOnDevice: boolean;
derivationPath: string;
Expand Down Expand Up @@ -83,7 +81,7 @@ export class GetExtendedPublicKeyCommand
this._errorHelper.getError(response),
).orDefaultLazy(() => {
const parser = new ApduParser(response);
const length = parser.getUnparsedRemainingLength() - STATUS_CODE_LENGTH;
const length = parser.getUnparsedRemainingLength();

if (length <= 0) {
return CommandResultFactory({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("DefaultWalletBuilder tests", () => {
// Given
const builder = new DefaultWalletBuilder(mockMerkleTree);
const defaultWallet = new DefaultWallet(
"/48'/1'/0'/0'",
"48'/1'/0'/0'",
DefaultDescriptorTemplate.NATIVE_SEGWIT,
);
const masterFingerprint = hexaStringToBuffer("5c9e228d")!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class DefaultWalletBuilder implements WalletBuilder {
// For internal keys, the xpub should be put after key origin informations
// https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/wallet.md#keys-information-vector
const hexMasterFingerprint = bufferToHexaString(masterFingerprint).slice(2);
const keyOrigin = `[${hexMasterFingerprint}${wallet.derivationPath}]`;
const keyOrigin = `[${hexMasterFingerprint}/${wallet.derivationPath}]`;
const key = `${keyOrigin}${extendedPublicKey}`;
// Empty name for default wallets
const name = "";
Expand Down

0 comments on commit 62cd518

Please sign in to comment.