Our miner code adds OP_0
to the coinbase scriptSig
in order to avoid triggering the bad-cb-length
consensus error on test networks.
This commit, like blocktools.py, limits that workaround to blocks 1 through 16 where it’s actually needed (OP1
through OP_16
).
Previously the coinbase transaction generated by our miner code was not used downstream, because the getblocktemplate
RPC excludes it.
Since the Mining IPC interface was introduced in #30200 we do expose this dummy coinbase transaction. In Stratum v2 several parts of it are communicated downstream, including the scriptSig
.
To avoid churning various hardcoded hashes in test files, this PR continues to add OP_0
for regtest. This can be changed if we ever need to change them anyway, such as in #32155.
There’s a few places where the tests generate their own coinbase transactions. Those are modified to either match the new behavior, or a code comment is added.