Strange behavior of small OP_RETURN outputs

I'm hoping someone familiar with the structure of an OP_RETURN output can help point me to a technical resource or help explain some strange behavior I've noticed in OP_RETURN outputs that are 4 bytes or smaller. It seems that data 4 bytes or less doesn't get pushed onto the stack in the same manner as outputs with 5-80 bytes.

For example, bitcoin txid 71a5e4e683b06b1b2accdab265abfad8335d75f3d5436e7435d0e48a33f283bb has an OP_RETURN output that looks like this:

 [vout] => Array ( [0] => Array ( [value] => 0 [n] => 0 [scriptPubKey] => Array ( [asm] => OP_RETURN 24897 [hex] => 6a024161 [type] => nulldata ) ) 

The OP_RETURN hex value of 6a024161 should have scripted with the OP_RETURN (6a) pushing 2 bytes of data (02) to the stack, with the data being 4161. Yet the data that was actually pushed is 24897. This doesn't appear consistent with the script specification (https://en.bitcoin.it/wiki/Script). I've been able to consistently reproduce these results by building transactions with bitcoin core, and once the data is 5 bytes or larger it behaves consistent with the specification. Does anyone know what's going on here or have any information they can share on this?

Thanks!

submitted by /u/sepharose
[link] [comments]

Comments