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.

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.

  • 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 sec – mulllhausen Nov 25 '13 at 5:40
  • @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 Nov 25 '13 at 6:28
  • 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 Nov 25 '13 at 6:31
  • @mulllhausen No, that's right. – theymos Nov 25 '13 at 6:31
  • 1
    @mulllhausen Yes, the coinbase tx is always the first tx in a block, and every block must have a coinbase tx. – theymos Nov 25 '13 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.