What is opcode 252?

4

Writing my own blockchain parser, I have come across an unrecognized opcode in block number 142312. The relevant section of the transaction input is this:

"in":[
         {
             "prev_out":{
                 "hash": "0000000000000000000000000000000000000000000000000000000000000000",
                 "n": 4294967295
             },
             "coinbase": "fc70035c7a81bc6f4876c6036e4bc4080eaf81377bc9672828061491e79df5d4ddf1d65b058ccb30563f1f1c14f658607bd2c7138e87e480bcec3f5b91d041d041"
         }
     ],

fc corresponds to opcode 252, which is not listed in the Bitcoin wiki. How should I interpret this script value?

My block parsing program gives me the following raw coinbase script value:

fc70035c7a81bc6f4876c6036e4bc4080eaf81377bc9672828061491e79df5d4ddf1d65b058ccb30563f1f1c14f658607bd2c7138e87e480bcec3f5b91d041d041

That is, there isn't any opcode before the above hexadecimal string.

mulllhausen

Posted 2013-11-25T02:57:41.133

Reputation: 1 533

Answers

3

It's possible for invalid scripts to exist in the chain. Scripts are only checked for validity when spent, and coinbase scriptsigs are never checked. You should just interpret coinbase scriptsigs as a chunk of arbitrary data that's usually (not always) a valid script. ScriptPubKeys can also be invalid: blockexplorer.com will print the script as "[error]" in such cases.

theymos

Posted 2013-11-25T02:57:41.133

Reputation: 8 228

i know they aren't but i have parsed the block myself and this is how the coinbase script starts - there is no op_pushdata before 'fc'. i will update the question with the full coinbase script value in a secmulllhausen 2013-11-25T05:40:58.557

@mulllhausen Actually, I forgot that blockexplorer.com prints coinbase scriptsigs differently than other scripts. It does start with 0xFC. This is legal: coinbase scriptsigs can be invalid scripts, even if they usually are valid. You can't interpret it as a script because it isn't one.theymos 2013-11-25T06:28:59.007

ah right. how can i identify whether the script element is a coinbase scriptsig? i'm guessing it would be wrong to assume that the first transaction in the block is always the coinbase transaction?mulllhausen 2013-11-25T06:31:05.637

@mulllhausen No, that's right.theymos 2013-11-25T06:31:37.223

you mean it is identified as being the first transaction in the block?mulllhausen 2013-11-25T06:44:35.217

1@mulllhausen Yes, the coinbase tx is always the first tx in a block, and every block must have a coinbase tx.theymos 2013-11-25T07:30:36.720