Skip to content

channels_sv2: document why coinbase scriptSig length prefix is always 1 byte - #2244

Merged
plebhash merged 1 commit into
stratum-mining:mainfrom
plebhash:2026-08-01-doc-scriptsig-100-bytes
Aug 5, 2026
Merged

channels_sv2: document why coinbase scriptSig length prefix is always 1 byte#2244
plebhash merged 1 commit into
stratum-mining:mainfrom
plebhash:2026-08-01-doc-scriptsig-100-bytes

Conversation

@plebhash

@plebhash plebhash commented Aug 2, 2026

Copy link
Copy Markdown
Member

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 tx 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.

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

@plebhash
plebhash force-pushed the 2026-08-01-doc-scriptsig-100-bytes branch from 9d48e7b to 5b827d4 Compare August 3, 2026 17:47
@plebhash plebhash changed the title document why coinbase scriptSig length prefix is always 1 byte channels_sv2: document why coinbase scriptSig length prefix is always 1 byte Aug 3, 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
plebhash force-pushed the 2026-08-01-doc-scriptsig-100-bytes branch from 5b827d4 to 71f0d38 Compare August 5, 2026 17:10
@plebhash
plebhash merged commit 1e947c8 into stratum-mining:main Aug 5, 2026
14 checks passed
@plebhash
plebhash deleted the 2026-08-01-doc-scriptsig-100-bytes branch August 5, 2026 17:42
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.

2 participants