My existing answer stands, but as I feel we're talking past each other due to different assumptions about what Script notations mean, let me add this to dig deeper into that.
I'm going to change the literals in your question a bit for simplicity, and try to answer the question:
I see an output with scriptPubKey OP_RETURN OP_PUSHBYTES_3 686c77
. Would an output with scriptPubKey OP_RETURN 686c77
also be valid and/or standard?
The first point is that in your notation, the string OP_RETURN 686c77
simply has no meaning. It does not correspond to any script at all. I don't mean that such a script would be invalid; I mean that literally this cannot be translated to actual script bytes.
For background, the script OP_RETURN OP_PUSHBYTES_3 686c77
corresponds the script bytes whose hex encoding is 6a03686c77
(6a
being OP_RETURN
, and 03
being OP_PUSHBYTES_3
). My assumption is that what you mean by OP_RETURN 686c77
is the script whose hex bytes are 6a686c77
, i.e., the same bytes as before, but with the OP_PUSHBYTES_3
byte dropped.
However, those script bytes would not be denoted OP_RETURN 686c77
. It would be denoted OP_RETURN OP_ENDIF OP_FROMALTSTACK OP_NIP
(because without the 03
bytes, the 3 bytes that follow are interpreted as opcodes, rather than as a literal).
If your question is about the script OP_RETURN OP_ENDIF OP_FROMALTSTACK OP_NIP
(hex 6a686c77
), the answer is that by consensus rules this output is valid (even though it has an OP_ENDIF
without corresponding OP_IF
!) because Scripts are not executed or interpreted until they are spent, and an OP_RETURN output like this is obviously unspendable. The only consensus rules governing scriptPubKeys is that they cannot exceed 10000 bytes, but there are absolutely no rules restricting what those bytes can be. As for standardness, the answer as of Bitcoin Core 27.0 is no; the requirement for OP_RETURN outputs to be standard is (among other things) that the OP_RETURN
is only followed by pushes, not by other opcodes.
To add to the confusion, there exist other human-readable notations for Script, including a common one which just never uses OP_PUSHBYTES_xx
. In the Bitcoin Core notation, the script whose hex bytes are 6a03686c77
is simply denoted OP_RETURN 686c77
(with the 03
byte, and the pushing, implicit in the hex constant). So if you ask about OP_RETURN 686c77
, it really matters what you mean by that. Either you've switched to another encoding (for the same script, and nothing changed), or you've described something meaningless.