channels_sv2: document why coinbase scriptSig length prefix is always 1 byte - #2244
Merged
plebhash merged 1 commit intoAug 5, 2026
Merged
Conversation
plebhash
force-pushed
the
2026-08-01-doc-scriptsig-100-bytes
branch
from
August 3, 2026 17:47
9d48e7b to
5b827d4
Compare
scriptSig length prefix is always 1 bytechannels_sv2: document why coinbase scriptSig length prefix is always 1 byte
GitGab19
approved these changes
Aug 5, 2026
The prefix/suffix split indexes in JobFactory hardcode a `1 // bytes in script` term for the scriptSig CompactSize length prefix. CompactSize switches to a 3-byte encoding at 253 bytes, so the hardcoded 1 looks like an off-by-2 hazard on inspection. It is not: Bitcoin consensus limits the coinbase scriptSig to 100 bytes, unconditionally below the 253-byte threshold. Any input that would push the scriptSig past 252 bytes is already consensus-invalid for reasons that have nothing to do with the split. Add a comment stating that rationale at each of the four sites so the assumption doesn't have to be re-derived. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
plebhash
force-pushed
the
2026-08-01-doc-scriptsig-100-bytes
branch
from
August 5, 2026 17:10
5b827d4 to
71f0d38
Compare
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.
The prefix/suffix split indexes in
JobFactoryhardcode a1 // bytes in scriptterm for thescriptSigCompactSizelength prefix.CompactSizeswitches to a 3-byte encoding at 253 bytes, so the hardcoded 1 looks like an off-by-2 hazard on inspection.It is not: Bitcoin consensus limits the coinbase tx
scriptSigto 100 bytes, unconditionally below the 253-byte threshold.Any input that would push the scriptSig past 252 bytes is already consensus-invalid for reasons that have nothing to do with the split.
This PR adds a comment stating that rationale at each of the four sites so the assumption doesn't have to be re-derived.
close https://github.com/project-loupe/audit-stratum/issues/19