diff --git a/apps/sample/package.json b/apps/sample/package.json index bdd162fd5..d1e88dfd2 100644 --- a/apps/sample/package.json +++ b/apps/sample/package.json @@ -19,9 +19,9 @@ "@ledgerhq/device-management-kit": "workspace:*", "@ledgerhq/device-management-kit-flipper-plugin-client": "workspace:*", "@ledgerhq/device-mockserver-client": "workspace:*", + "@ledgerhq/device-signer-kit-bitcoin": "workspace:*", "@ledgerhq/device-signer-kit-ethereum": "workspace:*", "@ledgerhq/device-signer-kit-solana": "workspace:*", - "@ledgerhq/device-signer-kit-bitcoin": "workspace:*", "@ledgerhq/device-transport-kit-mockserver": "workspace:*", "@ledgerhq/device-transport-kit-web-ble": "workspace:*", "@ledgerhq/device-transport-kit-web-hid": "workspace:*", diff --git a/apps/sample/src/components/SignerBtcView/index.tsx b/apps/sample/src/components/SignerBtcView/index.tsx index 85227d8cb..1a2951e29 100644 --- a/apps/sample/src/components/SignerBtcView/index.tsx +++ b/apps/sample/src/components/SignerBtcView/index.tsx @@ -1,5 +1,7 @@ import React, { useMemo } from "react"; import { + DefaultDescriptorTemplate, + DefaultWallet, type GetExtendedDAIntermediateValue, type GetExtendedPublicKeyDAError, type GetExtendedPublicKeyDAOutput, @@ -7,12 +9,16 @@ import { type SignMessageDAError, type SignMessageDAIntermediateValue, type SignMessageDAOutput, + type SignPsbtDAError, + type SignPsbtDAIntermediateValue, + type SignPsbtDAOutput, } from "@ledgerhq/device-signer-kit-bitcoin"; import { DeviceActionsList } from "@/components/DeviceActionsView/DeviceActionsList"; import { type DeviceActionProps } from "@/components/DeviceActionsView/DeviceActionTester"; import { useDmk } from "@/providers/DeviceManagementKitProvider"; +// Native segwit const DEFAULT_DERIVATION_PATH = "84'/0'/0'"; export const SignerBtcView: React.FC<{ sessionId: string }> = ({ @@ -78,6 +84,37 @@ export const SignerBtcView: React.FC<{ sessionId: string }> = ({ SignMessageDAError, SignMessageDAIntermediateValue >, + { + title: "Sign psbt", + description: + "Perform all the actions necessary to sign a PSBT with the device", + executeDeviceAction: ({ derivationPath, psbt }) => { + if (!signer) { + throw new Error("Signer not initialized"); + } + + return signer.signPsbt( + new DefaultWallet( + derivationPath, + DefaultDescriptorTemplate.TAPROOT, + ), + psbt, + ); + }, + initialValues: { + derivationPath: DEFAULT_DERIVATION_PATH, + psbt: "cHNidP8BAFUCAAAAAVEiws3mgj5VdUF1uSycV6Co4ayDw44Xh/06H/M0jpUTAQAAAAD9////AXhBDwAAAAAAGXapFBPX1YFmlGw+wCKTQGbYwNER0btBiKwaBB0AAAEA+QIAAAAAAQHsIw5TCVJWBSokKCcO7ASYlEsQ9vHFePQxwj0AmLSuWgEAAAAXFgAUKBU5gg4t6XOuQbpgBLQxySHE2G3+////AnJydQAAAAAAF6kUyLkGrymMcOYDoow+/C+uGearKA+HQEIPAAAAAAAZdqkUy65bUM+Tnm9TG4prer14j+FLApeIrAJHMEQCIDfstCSDYar9T4wR5wXw+npfvc1ZUXL81WQ/OxG+/11AAiACDG0yb2w31jzsra9OszX67ffETgX17x0raBQLAjvRPQEhA9rIL8Cs/Pw2NI1KSKRvAc6nfyuezj+MO0yZ0LCy+ZXShPIcACIGAu6GCCB+IQKEJvaedkR9fj1eB3BJ9eaDwxNsIxR2KkcYGPWswv0sAACAAQAAgAAAAIAAAAAAAAAAAAAA", + }, + deviceModelId, + } satisfies DeviceActionProps< + SignPsbtDAOutput, + { + psbt: string; + derivationPath: string; + }, + SignPsbtDAError, + SignPsbtDAIntermediateValue + >, ], [deviceModelId, signer], ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a603c5960..eddcea5f3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7943,6 +7943,7 @@ packages: sudo-prompt@9.2.1: resolution: {integrity: sha512-Mu7R0g4ig9TUuGSxJavny5Rv0egCEtpZRNMrZaYS1vxkiIxGiGUwoezU3LazIQ+KE04hTrTfNPgxU5gzi7F5Pw==} + deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. superjson@1.13.3: resolution: {integrity: sha512-mJiVjfd2vokfDxsQPOwJ/PtanO87LhpYY88ubI5dUB1Ab58Txbyje3+jpm+/83R/fevaq/107NNhtYBLuoTrFg==}