8000 PSBT serde implementation by dr-orlovsky · Pull Request #497 · rust-bitcoin/rust-bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Oct 14, 2020
Merged

PSBT serde implementation #497

merged 3 commits into from
Oct 14, 2020

Conversation

dr-orlovsky
Copy link
Collaborator

No description provided.

let s = match self {
SigHashType::All => "SIGHASH_ALL",
SigHashType::None => "SIGHASH_NONE",
SigHashType::Single => "SIGHASH_SIGNLE",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo :)

SigHashType::All => "SIGHASH_ALL",
SigHashType::None => "SIGHASH_NONE",
SigHashType::Single => "SIGHASH_SIGNLE",
SigHashType::AllPlusAnyoneCanPay => "SIGHASH_ALL | SIGHASH_ANYONECANPAY",
Copy link
Member

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 | ;))

SigHashType::Single => "SIGHASH_SIGNLE",
SigHashType::AllPlusAnyoneCanPay => "SIGHASH_ALL | SIGHASH_ANYONECANPAY",
SigHashType::NonePlusAnyoneCanPay => "SIGHASH_NONE | SIGHASH_ANYONECANPAY",
SigHashType::SinglePlusAnyoneCanPay => "SIGHASH_SIGNLE | SIGHASH_ANYONECANPAY",
Copy link
Member

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())
Copy link
Member

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?

@dr-orlovsky
Copy link
Collaborator Author

@apoelstra fixed typo + tests

type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.replace(' ', "").to_ascii_uppercase().as_ref() {
Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member
@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack 8e0b992

@apoelstra apoelstra merged commit 65b52cf into rust-bitcoin:master Oct 14, 2020
@stevenroose
Copy link
Collaborator

I made this work with JSON and added a test here: #508.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0