Bitcoin Forum
May 25, 2024, 05:05:12 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to handle OP_INVALIDOPCODE and other undefined OP bytes?  (Read 152 times)
Coding Enthusiast (OP)
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
March 08, 2020, 07:10:00 AM
Merited by hugeblack (2), ABCbits (1), Heisenberg_Hunter (1)
 #1

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!

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
aliashraf
Legendary
*
Offline Offline

Activity: 1456
Merit: 1174

Always remember the cause!


View Profile WWW
March 08, 2020, 08:21:53 AM
Last edit: March 08, 2020, 08:33:36 AM by aliashraf
Merited by Welsh (4), hugeblack (3), ABCbits (1), Heisenberg_Hunter (1), Coding Enthusiast (1)
 #2

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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!