-
Notifications
You must be signed in to change notification settings - Fork 831
PSBT serde implementation #497
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
src/blockdata/transaction.rs
Outdated
let s = match self { | ||
SigHashType::All => "SIGHASH_ALL", | ||
SigHashType::None => "SIGHASH_NONE", | ||
SigHashType::Single => "SIGHASH_SIGNLE", |
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.
typo :)
src/blockdata/transaction.rs
Outdated
SigHashType::All => "SIGHASH_ALL", | ||
SigHashType::None => "SIGHASH_NONE", | ||
SigHashType::Single => "SIGHASH_SIGNLE", | ||
SigHashType::AllPlusAnyoneCanPay => "SIGHASH_ALL | SIGHASH_ANYONECANPAY", |
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.
IMO we should drop the spaces here which might make parsing easier in some contexts (e.g. shell ... though of course shell will also barf on the |
;))
src/blockdata/transaction.rs
Outdated
SigHashType::Single => "SIGHASH_SIGNLE", | ||
SigHashType::AllPlusAnyoneCanPay => "SIGHASH_ALL | SIGHASH_ANYONECANPAY", | ||
SigHashType::NonePlusAnyoneCanPay => "SIGHASH_NONE | SIGHASH_ANYONECANPAY", | ||
SigHashType::SinglePlusAnyoneCanPay => "SIGHASH_SIGNLE | SIGHASH_ANYONECANPAY", |
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.
typo again
"SIGHASH_ALL|SIGHASH_ANYONECANPAY" => Ok(SigHashType::AllPlusAnyoneCanPay), | ||
"SIGHASH_NONE|SIGHASH_ANYONECANPAY" => Ok(SigHashType::NonePlusAnyoneCanPay), | ||
"SIGHASH_SIGNLE|SIGHASH_ANYONECANPAY" => Ok(SigHashType::SinglePlusAnyoneCanPay), | ||
_ => Err("can't recognize SIGHASH string".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.
can you add a unit test which tries to round-trip every variant as a string?
@apoelstra fixed typo + tests |
src/blockdata/transaction.rs
Outdated
type Err = String; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s.replace(' ', "").to_ascii_uppercase().as_ref() { |
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 really don't like this being case-insensitive or space-insensitive. It will break roundtripping tests for this type or anything that contains 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.
Fixed
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 8e0b992
I made this work with JSON and added a test here: #508. |
No description provided.