PSET: Various fixes#1121
Merged
Merged
Conversation
sanket1729
approved these changes
Jul 1, 2022
Contributor
sanket1729
left a comment
There was a problem hiding this comment.
code review ACK 32c3a98. Double checked that rust-elements parser and parser that allen implemnted https://tools.blockstream.com/psbt parses the new serialization correctly.
apoelstra
reviewed
Jul 1, 2022
apoelstra
reviewed
Jul 1, 2022
apoelstra
approved these changes
Jul 1, 2022
apoelstra
approved these changes
Jul 5, 2022
2 tasks
apoelstra
approved these changes
Jul 20, 2022
A single 0x00 byte indicates a zero length field; we must skip parsing that field otherwise the length will be expected to be read again for the vector that is passed in to revieve the value. This allows PSBT_ELEMENTS_GLOBAL_SCALAR to be parsed when it is serialized according to the spec, i.e. both of the following cases will correctly parse to the same representation: $cli decodepsbt 'cHNldP8B+wQCAAAAAQIEAgAAAAEEAQABBQEAJ/wEcHNldAABAgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGhscHR4fIAEAAA==' and $cli decodepsbt 'cHNldP8B+wQCAAAAAQIEAgAAAAEEAQABBQEAJ/wEcHNldAABAgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGhscHR4fIAAA' PSBT_ELEMENTS_GLOBAL_SCALAR is the only PSBT/PSET field that contains key data but no value data and so is the only field that currently hits this special case.
Note the re-parsing of the correct serialization is covered by the existing PSBT tests which process PSBTs containing scalars.
While the order of fields is not explicit in the PSBT/PSET specifications, third parties need to be able to support both with a single implementation. Keeping the PSBT fields in the same order makes this significantly easier.
ASSET_COMMITMENT and ASSET were in the wrong order, which prevents simply iterating the constants in simple parsers/writers.
As for outputs. ISSUANCE_VALUE_COMMITMENT and ISSUANCE_VALUE were misordered.
This makes global handling forwards-compatible when new fields are added, and un-breaks any PSET implementations that serialize PSBT_ELEMENTS_GLOBAL_TX_MODIFIABLE (which Elements does not yet implement).
This allows these test cases to be re-used by alternate implementations for round-trip serialization testing.
I found this useful for for creating test cases and checking validity. In the event that alternative implementations do not aim for exact serilization compatibility, this RPC can be used to validate and re-serialize their output for testing.
32ac36a to
3be6e80
Compare
apoelstra
approved these changes
Aug 9, 2022
gwillen
added a commit
to gwillen/elements
that referenced
this pull request
Aug 9, 2022
…lements 22rc3.
gwillen
added a commit
to gwillen/elements
that referenced
this pull request
Mar 2, 2023
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.
parsepsbtrpc for testingFixes #1065