OP_RETURN <any opcode> is now standard #3313

issue SergioDemianLerner opened this issue on November 24, 2013
  1. SergioDemianLerner commented at 5:27 AM on November 24, 2013: contributor

    I think the idea was to make OP_RETURN only and OP_RETURN {pushdata} standard, but reading the code at script.cpp I think than any opcode after OP_RETURN would be accepted as standard.

    I don't think this has any security implication, nor if it's worth the trouble to change that. Maybe the solution is just to document it correctly.

  2. petertodd commented at 5:09 PM on November 26, 2013: contributor

    Could you explain in more detail?

    The IsStandard() test uses the usual template matching code - I don't see how that could accept anything but the template.

  3. sipa commented at 6:45 PM on November 26, 2013: member

    Note that there are two separate things here:

    • Provably prunable outputs (anything that starts with OP_RETURN is provably prunable)
    • A new standard output type that is OP_RETURN + some data
  4. SergioDemianLerner commented at 7:34 PM on November 26, 2013: contributor

    the code reads: else if (opcode2 == OP_SMALLDATA) { // small pushdata, <= 80 bytes if (vch1.size() > 80) break; }

    Where it should read something like :

    else if (opcode2 == OP_SMALLDATA) { if (opcode1 <= OP_16) { // small pushdata, <= 80 bytes if (vch1.size() > 80) break; } else break; }

  5. petertodd commented at 7:53 PM on November 26, 2013: contributor

    It'd probably make sense to just make the test be:

    if (vch1.size() > 80 || vch1.size() < 1)
        break;
    

    That's why OP_PUBKEY and OP_PUBKEYHASH can't match an arbitrary opcode, and there's no good reason to include an empty data string - use a plain OP_RETURN scriptPubKey instead.

  6. gavinandresen commented at 9:12 PM on November 26, 2013: contributor

    What is the problem with OP_RETURN OP_CHECKSIG (or OP_RETURN OP_ANYTHING) being standard?

    I vote we just document it as "that is the way it is."

  7. petertodd commented at 9:49 PM on November 26, 2013: contributor

    @gavinandresen I'm fine with that - might help discourage people from over-thinking what's supposed to be in there...

  8. gavinandresen commented at 6:46 PM on October 28, 2014: contributor

    Closing, consensus is "fine the way it is." If anybody feels strongly about more documentation, submit a pull request to https://bitcoin.org/en/developer-guide#standard-transactions (but I don't think it is worth mentioning, this is a weird nobody-is-going-to-do-it-that-way edge case).

  9. gavinandresen closed this on Oct 28, 2014

  10. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-24 18:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me