-
Notifications
You must be signed in to change notification settings - Fork 831
Improve segwit signature hash API #1995
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
Conversation
concept ACK. Though I wonder if we want to split these into |
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 3a0579b78c705f5b25f61bb11cf88b3d333fcd93
9054594
to
00dec50
Compare
I have a question, in the BIP-143 test vectors for wrapped p2wsh the script code is the witness script with
I'd like to answer that because the script paramater to |
bitcoin/src/crypto/sighash.rs
Outdated
@@ -821,6 +843,7 @@ impl<R: Borrow<Transaction>> SighashCache<R> { | |||
} | |||
|
|||
/// Computes the BIP143 sighash for any flag type. | |||
#[deprecated(since = "0.30.0", note = "use segwit_v0_signature_hash instead")] |
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.
note needs to be updated?
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.
oh woops, thanks mate!
00dec50
to
2d08c9a
Compare
0xcf is 207, the number of bytes in the redeemScript. It is a VarInt with the encoded length. The script code needs to be the the "witnessScript serialized as scripts inside CTxOut". Which is VarInt size + script bytes. |
@tcharding |
1 similar comment
@tcharding |
ah BOOM! I've been bitten by that one before :) |
2d08c9a
to
fdbe9a0
Compare
Added some more docs. |
The word "segwit" refers to segwit v0 and taproot but currently we have `segwit_signature_hash` that is version specific (segwit v0). - Rename `segwit_encode_signing_data_to` to `segwit_v0_encode_signing_data_to` - Add `p2wpkh_signature_hash` and `p2wsh_signature_hash` functions We keep the single encode function because the error handling is better that way. While we are at it test the bip-143 test vectors against all the sighash types of wrapped p2wsh.
fdbe9a0
to
4300cf2
Compare
looks good. Shitty that we have so many |
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 4300cf2
I rekon the situation would be improved by an |
Agreed. Maybe we should do a followup PR for this. The we are already returning a |
I'm hesitant to dig too deeply into errors because of the secp error POC but I'll have a gentle poke (in a separate PR). |
My first reaction when reading the OP was "eh again a naming discussion around segwit <> segwitv0". But as someone who has been using sighashes a lot lately, I really like this change. The scriptCode is one of the most confusing things about the segwit BIPs (see what I did there?). So this change hides that confusion concept and the argument naming is pretty clear. ACK 4300cf2 |
BOOM! Reviews - I love it. Thanks bro. |
The word "segwit" refers to segwit v0 and taproot but these functions are version specific. Add
v0
into the function names.This is similar to #1994, both based on recent post of mine to bitcoin dev mailing list.