-
Notifications
You must be signed in to change notification settings - Fork 324
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
ref(hwi): Move hwi out of bdk #1161
Conversation
8cfee3e
to
6d9920d
Compare
As per today's discussion in the Lib Team Call, this PR probably needs to be rebased after the ci fix of #1182 |
6d9920d
to
4049c70
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
I also agree it would be nice to move some common bdk test utils to a shared crate - similar to #1171
crates/hwi/src/signer.rs
Outdated
self.client | ||
.sign_tx(psbt) | ||
.map_err(|e| { | ||
SignerError::Generic(format!("While signing with hardware wallet: {}", e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this work?
SignerError::Generic(format!("While signing with hardware wallet: {}", e)) | |
SignerError::HWIError(e.to_string()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order for this to work, we would need to add the HWIError
variant inside of bdk, which is not really desirable since it wouldn't be used inside bdk but in an outside crate.
This PR moves I would really love to have hwi as a separate crate. However, I don't think it makes sense to do it with the current state of Introducing In conclusion, I think we should try this again later down the line. |
Why? We already have
True, but at the moment everyone trying to implement the Signer trait in a crate outside of bdk encounters the same problem, so I think we should find a way to fix this anyways (without having to wait for a complete refactoring on the signer/wallet, since that will take a while). We could add either good docs to I agree that this code is very suboptimal given the state of the Wallet, but we won't refactor the Wallet until bdk 2.0; do we want to leave hwi inside bdk, untested, until then? |
4049c70
to
e291408
Compare
@evanlinjin do you have any feedback on Daniela's last comment? |
Please rebase now that #1183 has been merged. |
e291408
to
f1124d4
Compare
Done, thanks! |
crates/bdk/src/wallet/signer.rs
Outdated
SignerError::HWIError(e) | ||
} | ||
/// A generic error | ||
Generic(String), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of the SignerError::Generic
since I just removed bdk::Error::Generic
in #1028. But in this case I don't see an simple way around it. If it becomes annoying we can fix it in 2.0 release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK f1124d4
Can merge this one after the new CI issues are fixed with #1247 (after it's ACKd and merged). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK f1124d4
I don't like SignerError::Generic
, however I don't see a better option without taking too much time. We will change the API greatly for 2.0 anyway (as @danielabrozzoni mentioned: #1161 (comment)).
Do you think it would be better to rename |
How about |
f1124d4
to
105d70e
Compare
Thanks, I rebased and changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK 105d70e
Fixes #872
Description
This commit moves the
hardwaresigner
outside of bdk and insidebdk_hwi
Notes to the reviewers
There are currently two issues with the code:
TransactionSigner
dictates thatsign_transaction
must return aSignerError
- but beingSignerError
defined inside of bdk, we can't modify it to include an hwi specific error! I don't know how we could fix this (other than getting rid of the trait altogether :)); for now I just added aSignerError::Generic
variant, lmk if you have better ideas!bdk_hwi
, which made me realize - maybe we should expose them so that we can use them across our crates, and also our users can use them to test their code?For now, I just left the test commented.
Changelog notice
hardwaresigner
module has been moved out ofbdk
and insidebdk_hwi
.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
* [ ] I've added tests for the new feature