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

adding hardware signers #135

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

ulrichard
Copy link
Contributor

@ulrichard ulrichard commented Jan 6, 2023

Description

Adding hardware signers, so that hardware wallets can be used to sign transactions.

Notes to the reviewers

It doesn't work 100% yet for me.
I am using the following wallet:
https://github.com/RCasatta/electrum2descriptors/blob/main/tests/wallets2descriptors.rs#L89
https://github.com/RCasatta/electrum2descriptors/blob/main/tests/wallets/multisig_hw_segwit
I can create and sign a transaction with this version of bdk-cli. It displays the details on the Trezor and everything looks good so far. But in the CLI output of bdk-cli it says "is_finalized= false" and when I open the supposedly signed tx in Electrum, it aslo says "Status: Unsigned".
So, something must still be missing.

Initially I had some dependency problems, so I deleted Cargo.lock. That solved the dependency problems, but that's the reason for the large diff on that file.

Changelog notice

Added hardware signers through the use of HWI

Checklists

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

@rajarshimaitra
Copy link
Contributor

Concept ACK.. Thanks for adding this.. I was just thinking about this the other day.. Could be useful if anyone wanna use bdk-cli with mainnet (still not recommended)..

I can create and sign a transaction with this version of bdk-cli. It displays the details on the Trezor and everything looks good so far. But in the CLI output of bdk-cli it says "is_finalized= false" and when I open the supposedly signed tx in Electrum, it aslo says "Status: Unsigned".

From an initial glance, it looks like all the wallets you are using are watch-only? It has Xpubs and addresses only.. Such wallets in bdk can't sign for transactions as they don't have the private key.. and is_finalised=false means the resulting psbt doesn't have signatures.

PS: We should throw an error in those cases if use asks to sign a bdk-cli with watch only descriptors.

Can you try testing with a single sig wallet, with keys generated from bdk-cli itself?? If the HWI part is working properly that should work..

I will also try to test this out in an emulator..

@rajarshimaitra
Copy link
Contributor

rajarshimaitra commented Jan 9, 2023

I think the elctrum error you are seeing is also part of our lack of error handling in unsigned psbts and should be fixed with #128.

But it only handles it while broadcast.. I will try to see how the watch-only case can be captured in signing also..

@ulrichard
Copy link
Contributor Author

I tested with single sig hw wallets now.
With the Trezor everything works nicely.
With the Ledger, I got the descriptors, but when I tried to sign, I got an IO error "failed to open device". Anyway, since it works with the Trezor, I'm sure it has nothing to do with the bdk-cli integration.

@ulrichard ulrichard marked this pull request as ready for review January 10, 2023 14:32
@ulrichard ulrichard force-pushed the feature/hwi branch 2 times, most recently from 816b8cc to bd2b66e Compare January 10, 2023 14:45
@notmandatory notmandatory added the enhancement New feature or request label Jan 10, 2023
Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

Code Review ACK bd2b66e

Few more changes and it would be good to go..

Also seems to have conflict with master..

I have successfully tried it out with a single sig coldcard..

CHANGELOG.md Outdated
Comment on lines 9 to 10
- Added hardware signers through the use of HWI

Copy link
Contributor

Choose a reason for hiding this comment

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

We recently changed our changelog system from this file to just include it in the PR description.

The new PR template is here.. https://github.com/bitcoindevkit/bdk-cli/blob/master/.github/pull_request_template.md

Can you just add a Change Log section with this line in the description instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify after adding the log in the description, its actually not needed anymore in this file..

src/handlers.rs Show resolved Hide resolved
src/utils.rs Outdated Show resolved Hide resolved
src/utils.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

Re Ack 927b066 modulo one comment..

CHANGELOG.md Outdated
Comment on lines 9 to 10
- Added hardware signers through the use of HWI

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify after adding the log in the description, its actually not needed anymore in this file..

@notmandatory
Copy link
Member

notmandatory commented Feb 14, 2023

@ulrichard we made some CI changes and bumped the bdk and bdk-reserves versions, please rebase after #143 is merged and then this should be ready to go. Thanks!

Copy link
Member

@notmandatory notmandatory left a comment

Choose a reason for hiding this comment

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

utACK 100ea8d

Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

ACK 100ea8d

@rajarshimaitra rajarshimaitra merged commit e3d09a6 into bitcoindevkit:master Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants