opcodeexplained.com icon indicating copy to clipboard operation
opcodeexplained.com copied to clipboard

doc: update OP_RETURN size notes

Open polespinasa opened this issue 3 months ago • 3 comments

The maximum size notes were a bit "wrong" or not well defined as it was limited by policy rules and op_return > 80bytes data were valid even with the standarness rule...

This PR updates the limits to consensus rules and defines the policy rules that affects OP_RETURN after core v30.

polespinasa avatar Sep 10 '25 20:09 polespinasa

Deploy Preview for timely-chimera-eba3bb ready!

Name Link
Latest commit 7e4f1d9e7f6e423fa740145f1e3191e82df449b1
Latest deploy log https://app.netlify.com/projects/timely-chimera-eba3bb/deploys/68c1daa91444e80008dc3256
Deploy Preview https://deploy-preview-23--timely-chimera-eba3bb.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Sep 10 '25 20:09 netlify[bot]

Hi, thanks for taking a look and contributing!

As written, I'm not sure I understand your sentence well. Moreover, when I look it up I find that the maximum size of the data is not (even by consensus rules as far as I can tell) upper-bounded by the block weight limit.

What do you think of the following:

- By default, relay policy limits OP_RETURN data to 80 bytes (this means that under standardness rules`OP_RETURN` can be at most 83 bytes: 1 byte for the opcode, 1-2 bytes for the data push, and 80 bytes of data).
- Ignoring policy (for example if a miner includes the transaction directly), consensus limits still apply: each pushed element must be ≤ 520 bytes, and the entire `OP_RETURN` script (scriptPubKey) must be ≤ 10,000 bytes.

I also propose we wait for v30 to come out and can adjust the docs with the correct verbiage then before merging.

thunderbiscuit avatar Sep 23 '25 17:09 thunderbiscuit

Maybe the sentence is not really well written :)

"By default" is a complicated affirmation because it's only the default on Bitcoin Core < v30.0. It's not the default for other implementations (Like Knots who has 43bytes limit, I think). I guess using the "default" word will depend if you want the page to be implementation agnostic.

On the other side, I'm not sure on how this 10k bytes limit on ScripPubKeys is applied. See this tx with an OP_RETURN with 79,870 bytes. (Will replay to sipa and ask clarification about that :) )

Update: I found an answer. The ScriptPubKey limit only affects to spendable outputs, so it doesn't to OP_RETURN. The max consensus limit is the block size. See

polespinasa avatar Sep 23 '25 17:09 polespinasa