Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ (signer-btc) [DSDK-471]: SignPsbt task #581

Merged
merged 14 commits into from
Jan 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions apps/sample/src/components/SignerBtcView/index.tsx
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ import { DeviceActionsList } from "@/components/DeviceActionsView/DeviceActionsL
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 }> = ({
@@ -96,14 +95,14 @@ export const SignerBtcView: React.FC<{ sessionId: string }> = ({
return signer.signPsbt(
new DefaultWallet(
derivationPath,
DefaultDescriptorTemplate.TAPROOT,
DefaultDescriptorTemplate.NATIVE_SEGWIT,
),
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",
psbt: "70736274ff0104010101fb0402000000010204020000000105010100011004000000000103040100000001007102000000013daeeb9a92e7b5af90c787d53f0e60d2cf4cfd47bca9a0d8bc77a7464b024c0b00000000000000000002ff0300000000000016001402fe597c6ec0e2982712929bcf079a4e11d37e8d950b0000000000001600144dc432cb6a26c52a1e6ddd2bcf0ee49199fae0cc000000002206031869567d5e88d988ff7baf6827983f89530ddd79dbaeadaa6ec538a8f03dea8b18f5acc2fd540000800000008000000080000000000000000001011fff0300000000000016001402fe597c6ec0e2982712929bcf079a4e11d37e8d010e200cf08d04fa11ff024d5a50165ba65e495409b50ba6657788dfa15274adb682df010f0400000000000103086b01000000000000010416001429159115f12bb6a7e977439c83d3f8d555d72d5f00",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[COULD] Remove the default psbt here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, it's a heartache after so much difficulties to create it 😿

},
deviceModelId,
} satisfies DeviceActionProps<
Original file line number Diff line number Diff line change
@@ -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]),
});

Original file line number Diff line number Diff line change
@@ -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({
Original file line number Diff line number Diff line change
@@ -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")!;
Original file line number Diff line number Diff line change
@@ -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 = "";