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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

jdabbech-ledger
Copy link
Contributor

@jdabbech-ledger jdabbech-ledger commented Dec 27, 2024

πŸ“ Description

  • Create CommandErrorHelper to handle command error codes in parse response
  • Refactor SignMessage with ContinueTask
  • Create SignPsbt task & DA
  • Update sample app with Sign Psbt

❓ Context

  • Feature:

βœ… Checklist

Pull Requests must pass CI checks and undergo code review. Set the PR as Draft if it is not yet ready for review.

  • Covered by automatic tests
  • Changeset is provided
  • Impact of the changes:
    • list of the changes

🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.

@jdabbech-ledger jdabbech-ledger requested a review from a team as a code owner December 27, 2024 17:42
Copy link

vercel bot commented Dec 27, 2024

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
device-sdk-ts-sample βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jan 10, 2025 7:16pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
doc-device-management-kit ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2025 7:16pm

Copy link
Contributor

github-actions bot commented Dec 27, 2024

Messages
βœ… Danger: All checks passed successfully! πŸŽ‰

Generated by 🚫 dangerJS against 242b0c1

},
initialValues: {
derivationPath: DEFAULT_DERIVATION_PATH,
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 😿


export type SignPsbtDAInternalState = {
readonly error: SignPsbtDAError | null;
// [SHOULD] be psbt instead of signature
Copy link
Contributor

Choose a reason for hiding this comment

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

[ASK] What to do with this comment ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next task I'm working on, UpdatePsbtTask, will modify this device action to return a psbt instead of a Signature

Copy link
Contributor

Choose a reason for hiding this comment

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

actually as discussed, we won't return a PSBT but the list of signature, with according index/tag/pubkey_augm (typing to be refined)

{
constructor(private readonly args: GetWalletAddressCommandArgs) {}
constructor(
private readonly args: GetWalletAddressCommandArgs,
Copy link
Contributor

Choose a reason for hiding this comment

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

[COULD] rename args to _args

@@ -41,19 +37,26 @@ export type SignMessageCommandArgs = {
readonly messageMerkleRoot: Uint8Array;
};

export type SignMessageCommandResponse = Signature | ApduResponse;
export type SignMessageCommandResponse = ApduResponse;
Copy link
Contributor

Choose a reason for hiding this comment

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

[ASK] Why returning an ApduResponse instead of a Signature ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To handle the signature only in the task, with a client interpreter flow as the it should respond with those client commands.

psbt,
});
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[SHOULD] test file missing for this!

return signer.signPsbt(
new DefaultWallet(
derivationPath,
DefaultDescriptorTemplate.NATIVE_SEGWIT,
Copy link
Contributor

Choose a reason for hiding this comment

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

ideally we should be able to select the template we want to test. BOr another possibility would be to deduce it from the derivation path since we only support standard wallets for now, and derivation types also follow the standard as described here: https://learnmeabitcoin.com/technical/keys/hd-wallets/derivation-paths/

  • m/44'/... -> legacy
  • m/49'/... -> nested segwit
  • m/84'/... -> native segwit
  • m/86'/... -> taproot

(also note that if derivation path and descriptor template are not consistent, it will be rejected by the device anyway)

Copy link
Contributor Author

@jdabbech-ledger jdabbech-ledger Jan 10, 2025

Choose a reason for hiding this comment

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

ok I'll update the device action command form with a render prop to allow custom inputs

) {
const hasher = new Sha256HasherService();
this._walletSerializer =
walletSerializer || new DefaultWalletSerializer(hasher);
Copy link
Contributor

Choose a reason for hiding this comment

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

[COULD] we usually don't instantiate manually services like that. In ethereum signer, we use inversify to inject it in the app binder, and then give it as an input of the device action:
https://github.com/LedgerHQ/device-sdk-ts/blob/develop/packages/signer/signer-eth/src/internal/app-binder/EthAppBinder.ts#L35
That would make it easier to change the implementation later on if needed, and keep consistency to inject with inversify in di folder.
WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep it's definitely not the best way to inject the dependancy here but wasn't sure how to plug the task with inversify.
Will implement the same way as it's done in signer-eth then πŸ‘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants