From 62cd51827e95c1dd2689a44e85469f7bff9d9c98 Mon Sep 17 00:00:00 2001 From: jdabbech-ledger Date: Mon, 6 Jan 2025 11:05:51 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(signer-btc):=20Fix=20wallet=20&?= =?UTF-8?q?=20pub=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app-binder/command/GetExtendedPublicKeyCommand.test.ts | 4 ++-- .../app-binder/command/GetExtendedPublicKeyCommand.ts | 4 +--- .../src/internal/wallet/service/DefaultWalletBuilder.test.ts | 2 +- .../src/internal/wallet/service/DefaultWalletBuilder.ts | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/signer/signer-btc/src/internal/app-binder/command/GetExtendedPublicKeyCommand.test.ts b/packages/signer/signer-btc/src/internal/app-binder/command/GetExtendedPublicKeyCommand.test.ts index 709073613..44bfda957 100644 --- a/packages/signer/signer-btc/src/internal/app-binder/command/GetExtendedPublicKeyCommand.test.ts +++ b/packages/signer/signer-btc/src/internal/app-binder/command/GetExtendedPublicKeyCommand.test.ts @@ -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", () => { @@ -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]), }); diff --git a/packages/signer/signer-btc/src/internal/app-binder/command/GetExtendedPublicKeyCommand.ts b/packages/signer/signer-btc/src/internal/app-binder/command/GetExtendedPublicKeyCommand.ts index b15f0461f..a1ac455bc 100644 --- a/packages/signer/signer-btc/src/internal/app-binder/command/GetExtendedPublicKeyCommand.ts +++ b/packages/signer/signer-btc/src/internal/app-binder/command/GetExtendedPublicKeyCommand.ts @@ -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; @@ -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({ diff --git a/packages/signer/signer-btc/src/internal/wallet/service/DefaultWalletBuilder.test.ts b/packages/signer/signer-btc/src/internal/wallet/service/DefaultWalletBuilder.test.ts index 67db87533..f3a9bf987 100644 --- a/packages/signer/signer-btc/src/internal/wallet/service/DefaultWalletBuilder.test.ts +++ b/packages/signer/signer-btc/src/internal/wallet/service/DefaultWalletBuilder.test.ts @@ -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")!; diff --git a/packages/signer/signer-btc/src/internal/wallet/service/DefaultWalletBuilder.ts b/packages/signer/signer-btc/src/internal/wallet/service/DefaultWalletBuilder.ts index 2c587c850..004c759d6 100644 --- a/packages/signer/signer-btc/src/internal/wallet/service/DefaultWalletBuilder.ts +++ b/packages/signer/signer-btc/src/internal/wallet/service/DefaultWalletBuilder.ts @@ -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 = "";