M8: Prepend version byte to V3+ OP_RETURN scripts#917
Open
DavidGershony wants to merge 1 commit into
Open
Conversation
V3+ projects prepend a 1-byte version marker (value >= 3) to the OP_RETURN data. The parser detects this by checking if the first data push is a single byte with value >= 3, then adjusts the data start index accordingly. V1/V2 projects continue using the existing layout without a version byte (backward compatible parsing preserved). This enables future protocol versions to evolve the OP_RETURN format while maintaining backward-compatible parsing of existing projects.
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.
Summary
Prepend a 1-byte version marker to OP_RETURN scripts for V3+ projects, enabling future protocol evolution while maintaining backward-compatible parsing.
Problem
The current OP_RETURN format has no version indicator. If the data layout needs to change in the future, there's no way to distinguish between old and new formats during parsing — leading to silent misinterpretation of data.
Solution
Builder (V3+)
Prepend a single byte with value equal to the project version (e.g.,
0x03) before the existing data pushes.Parser
Detect the version byte by checking:
If detected, adjust the data start index to skip the version byte. Otherwise, parse using the legacy V1/V2 layout.
Backward Compatibility
Testing
All 154 shared tests pass.