Bitcoin Forum
October 28, 2020, 05:43:01 AM *
News: Latest Bitcoin Core release: 0.20.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to handle OP_INVALIDOPCODE and other undefined OP bytes?  (Read 94 times)
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 839
Merit: 1669


Bitcoin and C♯ Enthusiast


View Profile WWW
March 08, 2020, 07:10:00 AM
Merited by hugeblack (2), ETFbitcoin (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.5.0)Ann-git
Denovo(0.1.0)Ann-git
Bitcoin.Net(0.6.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.10.0)Ann-git
1603863781
Hero Member
*
Offline Offline

Posts: 1603863781

View Profile Personal Message (Offline)

Ignore
1603863781
Reply with quote  #2

1603863781
Report to moderator
1603863781
Hero Member
*
Offline Offline

Posts: 1603863781

View Profile Personal Message (Offline)

Ignore
1603863781
Reply with quote  #2

1603863781
Report to moderator
1603863781
Hero Member
*
Offline Offline

Posts: 1603863781

View Profile Personal Message (Offline)

Ignore
1603863781
Reply with quote  #2

1603863781
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1603863781
Hero Member
*
Offline Offline

Posts: 1603863781

View Profile Personal Message (Offline)

Ignore
1603863781
Reply with quote  #2

1603863781
Report to moderator
1603863781
Hero Member
*
Offline Offline

Posts: 1603863781

View Profile Personal Message (Offline)

Ignore
1603863781
Reply with quote  #2

1603863781
Report to moderator
aliashraf
Hero Member
*****
Offline Offline

Activity: 1148
Merit: 898

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), ETFbitcoin (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!