-
Notifications
You must be signed in to change notification settings - Fork 321
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
refactor(wallet): Use Psbt::sighash_ecdsa for computing sighashes #1424
refactor(wallet): Use Psbt::sighash_ecdsa for computing sighashes #1424
Conversation
0b7e13b
to
75e1f23
Compare
75e1f23
to
a4ed0e9
Compare
a4ed0e9
to
c71d30c
Compare
I'll make it a priority to review this next week. |
c71d30c
to
1f33c0b
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.
It's looking good! Thanks for addressing it.
Using the ctx
in a better way, and improving the errors definitely helps.
crates/wallet/src/wallet/signer.rs
Outdated
let (msg, hash_ty) = psbt | ||
.sighash_ecdsa(input_index, &mut sighasher) | ||
.map_err(SignerError::Psbt)?; |
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.
nit: I'm wondering if calling it msg instead of sighash
or hash
can lead to wrong interpretations of it.
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 dare say that msg
is the correct interpretation for the return type of sighash_ecdsa
1f33c0b
to
0a7ae6c
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 0a7ae6c
I like the cleanup, using functions instead of traits is a nice simplification.
We need a follow-up research issue to figure out how to remove signing from I suspect this will lead into the related refactoring using the new rust-miniscript |
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 0a7ae6c
@evanlinjin do you want to take a look at this one? Otherwise I'm inclined to merge it. |
- Change param `hash` to `&Message` in `sign_psbt_ecdsa` - Remove unused methods `compute_legacy_sighash`, and `compute_segwitv0_sighash`. - Match on `self.ctx` when signing for `SignerWrapper<PrivateKey>`
0a7ae6c
to
55a1729
Compare
I need to be honest, I don't have time to review this thoroughly. However, everything looks correct from a scan. |
This PR does some cleanup of the
bdk_wallet
signer module most notably by removing the internal traitComputeSighash
and replacing old code for computing the sighash (for legacy and segwit context) with a single methodPsbt::sighash_ecdsa
. The logic for computing the taproot sighash is unchanged and extracted to a new helper functioncompute_tap_sighash
.ComputeSighash
Psbt::sighash_ecdsa
. see Update rust bitcoin #1023 (comment)SignerError
variantsfixes #1038
Notes to the reviewers
Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committing