Skip to content

feat: example using hwi signing with #206

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sdmg15
Copy link

@sdmg15 sdmg15 commented Apr 10, 2025

Description

Integrates a new BDK signer using async-hwi.
The included example uses Bitbox02 but can be easily extended to use any other supported device.

Notes for reviewer

It's related to issue #20

Changelog notice

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

@notmandatory notmandatory added the documentation Improvements or additions to documentation label Apr 21, 2025
@notmandatory notmandatory moved this to In Progress in BDK Wallet Apr 21, 2025
@notmandatory
Copy link
Member

Thanks for this! looks like a good simple example for using hwi-async with bdk_wallet. One FYI we are talking about removing signing from bdk_wallet and delegating it to the rust-bitcoin Psbt::sign function. How hard would it be to use hwi-async to just sign a Psbt ?

@sdmg15
Copy link
Author

sdmg15 commented Apr 23, 2025

async-hwi provides a function with the following signature

    async fn sign_tx(&self, tx: &mut Psbt) -> Result<(), Error>;

So I think after constructing the psbt we can just call that function and voila.


let _ = bb.register_wallet("test-wallet", descriptor).await.unwrap();

let bitbox_signer = HwiSigner::new(bb);
Copy link
Author

Choose a reason for hiding this comment

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

So at this level we can just call bibox_signer.sign(psbt) given that the psbt has been constructed with bdk_wallet or something else

Copy link
Member

@notmandatory notmandatory Apr 26, 2025

Choose a reason for hiding this comment

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

Yes I think this is the right approach. Even though it makes the example much simpler it's still useful to show the end-to-end flow of using async-hwi to sign a psbt created with bdk_wallet::TxBuilder (and eventually the bdk_tx::TxBuilder).

Copy link
Author

Choose a reason for hiding this comment

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

Is it a good idea to add syncing wallet code in the example?
If not what's a good way of mocking the wallet with some utxos to sign?

@sdmg15
Copy link
Author

sdmg15 commented May 5, 2025

@notmandatory
Instead of syncing I "mocked" the wallet with some UTXOs since syncing isn't the goal of this example.

I also added a feature simulator when enabled for people that don't have a physical device connected but still want to run the example (Still need to add instructions on the readme on how to run)

Please let me know what you think

@sdmg15 sdmg15 marked this pull request as ready for review May 9, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants