Sunday, December 22, 2024

bitcoin core – Is the OP_PUSHBYTES_X opcode at all times required after OP_RETURN?

My current reply stands, however as I really feel we’re speaking previous one another attributable to totally different assumptions about what Script notations imply, let me add this to dig deeper into that.

I’ll change the literals in your query a bit for simplicity, and attempt to reply the query:

I see an output with scriptPubKey OP_RETURN OP_PUSHBYTES_3 686c77. Would an output with scriptPubKey OP_RETURN 686c77 even be legitimate and/or normal?

The primary level is that in your notation, the string OP_RETURN 686c77 merely has no which means. It doesn’t correspond to any script in any respect. I do not imply that such a script could be invalid; I imply that actually this can’t be translated to precise 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 imply by OP_RETURN 686c77 is the script whose hex bytes are 6a686c77, i.e., the identical bytes as earlier than, however with the OP_PUSHBYTES_3 byte dropped.

Nevertheless, these script bytes wouldn’t be denoted OP_RETURN 686c77. It might be denoted OP_RETURN OP_ENDIF OP_FROMALTSTACK OP_NIP (as a result of with out the 03 bytes, the three bytes that comply with are interpreted as opcodes, slightly than as a literal).

In case your query is concerning the script OP_RETURN OP_ENDIF OP_FROMALTSTACK OP_NIP (hex 6a686c77), the reply is that by consensus guidelines this output is legitimate (although it has an OP_ENDIF with out corresponding OP_IF!) as a result of Scripts should not executed or interpreted till they’re spent, and an OP_RETURN output like that is clearly unspendable. The one consensus guidelines governing scriptPubKeys is that they can not exceed 10000 bytes, however there are completely no guidelines limiting what these bytes could be. As for standardness, the reply as of Bitcoin Core 27.0 isn’t any; the requirement for OP_RETURN outputs to be normal is (amongst different issues) that the OP_RETURN is simply adopted by pushes, not by different opcodes.

So as to add to the confusion, there exist different human-readable notations for Script, together with a standard one which simply by no means makes use of OP_PUSHBYTES_xx. Within the Bitcoin Core notation, the script whose hex bytes are 6a03686c77 is just denoted OP_RETURN 686c77 (with the 03 byte, and the pushing, implicit within the hex fixed). So for those who ask about OP_RETURN 686c77, it actually issues what you imply by that. Both you have switched to a different encoding (for a similar script, and nothing modified), otherwise you’ve described one thing meaningless.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles