Skip to content

feat(hwi): add hardware wallet support - #207

Closed
tvpeter wants to merge 8 commits into
bitcoindevkit:masterfrom
tvpeter:feat/hwi
Closed

tvpeter wants to merge 8 commits into
bitcoindevkit:masterfrom
tvpeter:feat/hwi

Conversation

@tvpeter

@tvpeter tvpeter commented Jul 21, 2025 •

Copy link
Copy Markdown
Collaborator

Description

fixes #194

Notes to the reviewers

  • enable offline signer for creating tx whenever hwi feature is enabled
  • make handle_offline_wallet_subcommand fn async to handle hwi operations
  • The display_address method in the provided trait in async-hwi library is meant to trigger address generation by the connected device and display it on the device screen. Generated addresses are the same for both the app and device, so app addresses are returned for the hwi address subcommand.

This feature was tested with SpecterSimulator and Coldcard, although not all hwi features were successfully tested on coldcard.

For signing with hwi, it does sign but do not finalized the PSBT, so it has to be finalized before broadcasting.

Changelog notice

Checklists

HWI Wallet Subcommands implementation

  • hwi devices
  • hwi register
  • hwi address
  • hwi sign tx

All Submissions:

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

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature
  • I've updated CHANGELOG.md

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@tvpeter
tvpeter marked this pull request as ready for review July 23, 2025 04:34
@tvpeter tvpeter changed the title feat(hwi): add hwi device list wallet subcommand feat(hwi): add hardware wallet support Jul 23, 2025
@tvpeter
tvpeter force-pushed the feat/hwi branch 2 times, most recently from 2c28a68 to 067f8eb Compare October 13, 2025 11:10
@coveralls

coveralls commented Oct 13, 2025 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 19265985308

Details

  • 0 of 182 (0.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-1.4%) to 10.777%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/utils.rs 0 89 0.0%
src/handlers.rs 0 93 0.0%
Files with Coverage Reduction New Missed Lines %
src/handlers.rs 1 14.22%
Totals Coverage Status
Change from base Build 19253249526: -1.4%
Covered Lines: 172
Relevant Lines: 1596

💛 - Coveralls

@tvpeter
tvpeter requested a review from notmandatory October 13, 2025 11:53
@tvpeter
tvpeter force-pushed the feat/hwi branch 3 times, most recently from d3cfe8b to 60628b8 Compare October 15, 2025 08:52
Comment thread src/utils.rs Outdated
Comment thread src/commands.rs
@sdmg15

sdmg15 commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

I have tested with most of the devices, expect BitBox since you're not providing the emulator feature, this makes the is_bitbox02 always returning false even when the simulator is running.

@tvpeter
tvpeter force-pushed the feat/hwi branch 3 times, most recently from 7681e80 to 4a71d1d Compare February 20, 2026 03:58
@tvpeter tvpeter moved this to In Progress in BDK-CLI Feb 23, 2026
@tvpeter tvpeter self-assigned this Feb 23, 2026
- enable offline signer for creating tx whenever
hwi feature is enabled
- make handle_offline_wallet_subcommand fn async
to handle hwi operations
- add connecting to hwi fn in utils
- add `register` wallet hwi subcommand
- add signing psbt with hardware wallet
- add ledger and coldcard integration
- update hwi as top level command
- update CHANGELOG

rebase and fix clippy issues
- async-hwi requires libudev-sys for linux systems
- remove skip_blocks param as it is no longer
needed for cbf
- update code_coverage workflow to use the latest
actions
- add hidapi dependencies to workflows to fix
failing compilation

@notmandatory notmandatory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK 8a6012d

Looks like last commit failed due to some unrelated CI/codecov error.

@notmandatory

Copy link
Copy Markdown
Member

Thanks for getting this one done, it's a really important feature! We should talk this one up when the next release is published.

@tvpeter

tvpeter commented Feb 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

Looks like last commit failed due to some unrelated CI/codecov error.

Yes, coveralls.io is having a DNS error
Screenshot 2026-02-26 at 12 07 17 AM

@tvpeter tvpeter added this to the CLI 4.0.0 milestone May 6, 2026
@tvpeter tvpeter modified the milestones: CLI 4.0.0, CLI 4.1.0 Jun 30, 2026
@tvpeter tvpeter mentioned this pull request Aug 6, 2026
5 of 6 tasks
@tvpeter

tvpeter commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

Closing this PR in favour of #311

@tvpeter tvpeter closed this Aug 6, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in BDK-CLI Aug 6, 2026
tvpeter added a commit that referenced this pull request Oct 21, 2026
d34e6bf test(hwi): add more tests to helper fns (Vihiga Tyonum)
c2466e9 ref(hwi): move descriptor utils into descriptor utils (Vihiga Tyonum)
4131510 feat(hwi): Add fingerprint to "hwi xpub" (Vihiga Tyonum)
3e3c0be feat(hwi): Add merging ext and int desc into policy (Vihiga Tyonum)
e59a64d feat(hwi): Move register, address & sign to wallet (Vihiga Tyonum)
a121866 feat(hwi): Reuse saved wallet config for hwi (Vihiga Tyonum)
abea789 feat(hwi): Add hwi documentation (Vihiga Tyonum)
25b60b6 feat(hwi): Add hidapi to workflows (Vihiga Tyonum)
ea7043e feat(hwi): Add hwi feature to dispatch and routing (Vihiga Tyonum)
7eab246 feat(hwi): Add hwi subcommand handler (Vihiga Tyonum)
0c9e1c3 feat(hwi): Add utility fns to detect & list device (Vihiga Tyonum)

Pull request description:

  <!-- You can erase any parts of this template not applicable to your Pull Request. -->

  ### Description

  Adds hardware wallet support to the project using `async-hwi` library. Supported hardware devices include Specter, Jade, Ledger, Coldcard, and BitBox02 together with their simulators.

  This supersedes #207, which was approved but went stale after the project restructure. The feature has been reimplemented from scratch on the current modular structure, and the design is reworked around the saved wallet config.

  Commands:

  The feature introduced two top-level commands  (`hwi devices` and `hwi xpub`) and wallet subcommands (`register`, `address`, and `sign`).
  - `hwi xpub [<path>] [--type <wpkh|tr|sh-wpkh|pkh>]`:  reads a device extended public key. Outputs a ready-to-use key expression and external/internal descriptors.
  - `hwi devices`:  list every connected device (fingerprint + model).
  -  `register`: Wallet scoped operation (`wallet -w <walletname> hwi register`). It registers the wallet policy on the device (returns the HMAC where the device supports it). The policy comes from the saved wallet config.
  - address:  Also a wallet-scoped operation. It displays the address on-device where supported, and derive it locally.
  - `sign <psbt>`: sign a PSBT with the device.

  fixes #194

  <!-- Describe the purpose of this PR, what's being adding and/or fixed -->

  ### Notes to the reviewers

  - `xpub` and `devices` are top-level because you need xpub to build a wallet.
  - `register`, `address`, `sign` live under wallet and read descriptors from the saved config.
  - Policy handling. async-hwi expects a single multipath (…/<0;1>/*) public wallet policy. BDK stores the external/internal chains as two single-path descriptors, so the code combines them (from the wallet's public_descriptor, guaranteeing xpub-only) into the multipath form.
  - `create_tx` defaults --offline_signer to true when built with hwi, so PSBTs carry the xpub data the hardware wallets need.

  Known limitations:
  - Only the first connected device is used
  - `sign` produces partial signatures only; finalize separately with `finalize_psbt`
  - On-device address display for single-sig is limited to taproot (async-hwi has no simple wpkh display path); other single-sig returns the locally derived address.

  HWI subcommand implementation
  - `hwi xpub`
  - `hwi devices`
  - `wallet … hwi register`
  - `wallet … hwi address`
  - `wallet … hwi sign`

  <!-- In this section you can include notes directed to the reviewers, like explaining why some parts
  of the PR were done in a specific way -->

  Devices tested:
  - specter simulator: devices, xpub, register, sign
  - bitbox simulator: devices, xpub, register, sign
  - coldcard device: devices, xpub, address, sign

  ## Changelog notice

  - Added hwi feature with hardware wallet support (Specter, Jade, Ledger, Coldcard, BitBox02) to read device xpubs, list devices, register a wallet policy, display/verify addresses, and sign PSBTs.

  <!-- Notice the release manager should include in the release tag message changelog -->
  <!-- See https://keepachangelog.com/en/1.0.0/ for examples -->

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [ ] I've added tests for the new feature
  * [x] I've added docs for the new feature
  * [x] I've updated `CHANGELOG.md`

ACKs for top commit:
  Musab1258:
    tACK d34e6bf

Tree-SHA512: 4756dc1ecbb541f478f183ac8d625fe5ed1978a201cfe869b71eaa40532400b840dcc0fd91545e94ba0eff9e90190c8440ae47f7ebb44914a0de67dec92ac474
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add back HWI signing support

4 participants