Improve SchnorrSigHashType#903
Merged
dr-orlovsky merged 3 commits intorust-bitcoin:masterfrom Mar 24, 2022
Merged
Conversation
As is done in the rest of the `internal_macros` module use the fully qualified path for the `String` type. Done in preparation for using `serde_string_impl` in the `sighash` module.
This was referenced Mar 24, 2022
86e0cb9 to
1f70983
Compare
In preparation for constructing an error outside of this module improve the `SigHashTypeParseError` by doing: - Make the field public - Rename the field to `unrecognized` to better describe its usage
1f70983 to
e04eb11
Compare
We currently implement `Display` and `FromStr` on `EcdsaSigHashType` and use them in the `serde_string_impl` macro to implement ser/de. Mirror this logic in `SchnorrSigHashType`.
e04eb11 to
35b682d
Compare
Member
Author
|
All the force pushes are me finally working out that |
sanket1729
approved these changes
Mar 24, 2022
Member
sanket1729
left a comment
There was a problem hiding this comment.
ACK 35b682d. Thanks, much easier to review now that the diff is small
dr-orlovsky
approved these changes
Mar 24, 2022
| impl fmt::Display for SigHashTypeParseError { | ||
| fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
| write!(f, "can't recognize SIGHASH string '{}'", self.string) | ||
| write!(f, "Unrecognized SIGHASH string '{}'", self.unrecognized) |
Collaborator
There was a problem hiding this comment.
nit: error strings usually starts with small letter, since they are appended after Error: when printed out by default printer
Member
Author
There was a problem hiding this comment.
Sweet, I was wondering this. I'll rectify this as I do other clean ups.
| ]; | ||
| for s in sht_mistakes { | ||
| assert_eq!(EcdsaSigHashType::from_str(s).unwrap_err().to_string(), format!("can't recognize SIGHASH string '{}'", s)); | ||
| assert_eq!(EcdsaSigHashType::from_str(s).unwrap_err().to_string(), format!("Unrecognized SIGHASH string '{}'", s)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement Display/FromStr for SchnorrSigHashType
We currently implement
DisplayandFromStronEcdsaSigHashTypeand use them in theserde_string_implmacro to implement ser/de.Mirror this logic in
SchnorrSigHashType.Patch 1 and 2 are preparatory patches for patch 3.
Notes to reviewers
This PR has some conflicts with #898 but is pushing in the same direction, I'm happy to let 898 go in first and rebase on top.