Skip to content

Add special human-readable serde for OutPoint and most bip32 types#271

Merged
apoelstra merged 5 commits intorust-bitcoin:masterfrom
stevenroose:serde-outpoint
Aug 2, 2019
Merged

Add special human-readable serde for OutPoint and most bip32 types#271
apoelstra merged 5 commits intorust-bitcoin:masterfrom
stevenroose:serde-outpoint

Conversation

@stevenroose
Copy link
Copy Markdown
Collaborator

@stevenroose stevenroose commented May 29, 2019

Serialized OutPoint as "<txid>:<vout>" instead of a struct when a human-readable (de)serializer is used, f.e. JSON.

It should be noted that this is a breaking change for people relying on the current JSON serialization of OutPoint as a struct.

This PR is on top of #269, but doesn't have to be.

Closes #202.

@apoelstra
Copy link
Copy Markdown
Member

This is great. Can you make an analogous PR to rust-elements?

@apoelstra
Copy link
Copy Markdown
Member

I think we should first get rid of the serde macros. They aren't needed since rustc 0.15.

@apoelstra
Copy link
Copy Markdown
Member

Eh, actually there's no reason to get rid of the serde macros yet. ACK mod nit.

@stevenroose stevenroose added API break This PR requires a version bump for the next release enhancement labels Jun 6, 2019
@stevenroose
Copy link
Copy Markdown
Collaborator Author

Eh, actually there's no reason to get rid of the serde macros yet. ACK mod nit.

Were you talking about using derive for the struct macro?

@stevenroose
Copy link
Copy Markdown
Collaborator Author

I addressed the collect_str comments. This PR merges #269 as well though. If you want to merge this one before that, I guess I could re-push it standalone.

@stevenroose
Copy link
Copy Markdown
Collaborator Author

Btw, any idea if it's possible to condense that macro in the two other macros? It's kind of a total code duplicate of serde_struct_impl and serde_string_impl with an if-statement to choose which.

@apoelstra
Copy link
Copy Markdown
Member

Yeah, serde_struct_impl could be replaced with #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]. But that's somewhat independent of these changes.

No, I don't have any good ideas about how to reduce code duplication :(

@stevenroose stevenroose changed the title Add special human-readable serde for OutPoint Add special human-readable serde for OutPoint and bip32::Extended*Key Jun 8, 2019
apoelstra
apoelstra previously approved these changes Jun 12, 2019
Copy link
Copy Markdown
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.

utACK

@dongcarl
Copy link
Copy Markdown
Member

I'm not too familiar with serde, but I can attest that:

  • The changes in 8d7a1ff isn't more wrong than before
  • The changes in ebe6ace9cee3acf9f482f5921f3e4538e80d0bae make sense conceptually
  • The changes in 42d3a30dd488e4cddd1aa0fd52c613c4ca78bf4d is correct and doesn't change behavior (or binary output if Rust's "free-abstraction" works)

If anyone can attest to the serde code in ebe6ace9cee3acf9f482f5921f3e4538e80d0bae that'd be great.

@stevenroose stevenroose force-pushed the serde-outpoint branch 3 times, most recently from 1ecc696 to b59aedf Compare July 15, 2019 18:04
@stevenroose stevenroose changed the title Add special human-readable serde for OutPoint and bip32::Extended*Key Add special human-readable serde for OutPoint and most bip32 types Jul 15, 2019
@stevenroose
Copy link
Copy Markdown
Collaborator Author

If anyone can attest to the serde code in ebe6ace that'd be great.

You should be able to see that it's nothing more than the other two serde impl macros combined with an if serializer.human_readable() condition.

@stevenroose
Copy link
Copy Markdown
Collaborator Author

Fixed Rust v1.22 compilation.

apoelstra
apoelstra previously approved these changes Jul 22, 2019
Copy link
Copy Markdown
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.

re-utACK

@apoelstra apoelstra added this to the 0.19 milestone Jul 27, 2019
@stevenroose
Copy link
Copy Markdown
Collaborator Author

Added small commit to address @dongcarl 's nit.

Copy link
Copy Markdown
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.

changes look fine

Copy link
Copy Markdown
Member

@dongcarl dongcarl left a comment

Choose a reason for hiding this comment

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

LGTM

@apoelstra apoelstra merged commit 2e915bf into rust-bitcoin:master Aug 2, 2019
shesek added a commit to Blockstream/electrs that referenced this pull request Oct 1, 2021
SatoKentaNayoro pushed a commit to boolnetwork/mempool-electrs that referenced this pull request Nov 29, 2024
PastaPastaPasta pushed a commit to PastaPastaPasta/rust-dashcore that referenced this pull request Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API break This PR requires a version bump for the next release enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bip32 serialization/deserialization of ExtendedPrivKey

3 participants