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
oleonardolima
left a comment
There was a problem hiding this comment.
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.
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.
I dare say that msg is the correct interpretation for the return type of sighash_ecdsa
1f33c0b to
0a7ae6c
Compare
|
notmandatory
left a comment
There was a problem hiding this comment.
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 |
|
@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_walletsigner module most notably by removing the internal traitComputeSighashand 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.ComputeSighashPsbt::sighash_ecdsa. see Update rust bitcoin #1023 (comment)SignerErrorvariantsfixes #1038
Notes to the reviewers
Changelog notice
Checklists
All Submissions:
cargo fmtandcargo clippybefore committing