Author

Topic: How to handle OP_INVALIDOPCODE and other undefined OP bytes? (Read 174 times)

legendary
Activity: 1456
Merit: 1175
Always remember the cause!
OP,
By definition, output scripts are processed when they are being spent and treated as input scripts. If an invalid opcode happens to reside in a branch that is never executed, it is ok, otherwise, it fails.

So, if you are embedding an invalid opcode in an output script that transaction could go to the blockchain without any objection but when you are trying to spend the relative UTXO you may found yourself in big trouble as the spending txn is the one that is suspected to fail.

By the way, once the long-awaited MAST proposal becomes operational, hopefully, the very little chance for a hypothetical stupid script processing engine to fail because of the mere existence of an invalid opcode in an unvisited branch of the (now) input transaction will vanish forever. MAST won't disclose unvisited execution branches at all, as you already know.
legendary
Activity: 1042
Merit: 2805
Bitcoin and C♯ Enthusiast
What happens if a script contains OP codes that are not among the defined bytes from 0x00 to 0xb9? For example if it contained 0xcc.
Is it one of those "special" cases where we let it slide if for example it is not executed (eg. not-executed conditional branch or in PubkeyScripts)? Or are the rules more strict here?

More specifically what happens if a script contains the only named OP code that is 0xff (or OP_INVALIDOPCODE) which seems to be the only defined OP code without any case in interpreter
https://github.com/bitcoin/bitcoin/blob/5e12a61044b15e4e29ac786135a9ebb72d1bfc61/src/script/script.h#L190
This one seems to be slipping through as valid using conditional OPs!
Jump to: