LCOV - code coverage report
Current view: top level - src/script - script.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 241 241
Test Date: 2025-07-13 04:09:07 Functions: 100.0 % 17 17
Branches: 96.9 % 323 313

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2                 :             : // Copyright (c) 2009-present The Bitcoin Core developers
       3                 :             : // Distributed under the MIT software license, see the accompanying
       4                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5                 :             : 
       6                 :             : #include <script/script.h>
       7                 :             : 
       8                 :             : #include <crypto/common.h>
       9                 :             : #include <crypto/hex_base.h>
      10                 :             : #include <hash.h>
      11                 :             : #include <uint256.h>
      12                 :             : #include <util/hash_type.h>
      13                 :             : 
      14                 :             : #include <string>
      15                 :             : 
      16                 :      177400 : CScriptID::CScriptID(const CScript& in) : BaseHash(Hash160(in)) {}
      17                 :             : 
      18                 :    10361857 : std::string GetOpName(opcodetype opcode)
      19                 :             : {
      20   [ +  +  +  +  :    10361857 :     switch (opcode)
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
             +  +  +  +  
                      + ]
      21                 :             :     {
      22                 :             :     // push value
      23                 :        1352 :     case OP_0                      : return "0";
      24                 :           3 :     case OP_PUSHDATA1              : return "OP_PUSHDATA1";
      25                 :           2 :     case OP_PUSHDATA2              : return "OP_PUSHDATA2";
      26                 :           3 :     case OP_PUSHDATA4              : return "OP_PUSHDATA4";
      27                 :        7859 :     case OP_1NEGATE                : return "-1";
      28                 :       37507 :     case OP_RESERVED               : return "OP_RESERVED";
      29                 :      166643 :     case OP_1                      : return "1";
      30                 :       67282 :     case OP_2                      : return "2";
      31                 :       80344 :     case OP_3                      : return "3";
      32                 :       20935 :     case OP_4                      : return "4";
      33                 :       16730 :     case OP_5                      : return "5";
      34                 :        9128 :     case OP_6                      : return "6";
      35                 :        6525 :     case OP_7                      : return "7";
      36                 :      208571 :     case OP_8                      : return "8";
      37                 :       18505 :     case OP_9                      : return "9";
      38                 :       11331 :     case OP_10                     : return "10";
      39                 :       81408 :     case OP_11                     : return "11";
      40                 :       19824 :     case OP_12                     : return "12";
      41                 :       39085 :     case OP_13                     : return "13";
      42                 :       12716 :     case OP_14                     : return "14";
      43                 :       20887 :     case OP_15                     : return "15";
      44                 :       14654 :     case OP_16                     : return "16";
      45                 :             : 
      46                 :             :     // control
      47                 :     1171372 :     case OP_NOP                    : return "OP_NOP";
      48                 :       12881 :     case OP_VER                    : return "OP_VER";
      49                 :       20296 :     case OP_IF                     : return "OP_IF";
      50                 :       18058 :     case OP_NOTIF                  : return "OP_NOTIF";
      51                 :       17397 :     case OP_VERIF                  : return "OP_VERIF";
      52                 :       21965 :     case OP_VERNOTIF               : return "OP_VERNOTIF";
      53                 :      256352 :     case OP_ELSE                   : return "OP_ELSE";
      54                 :       29431 :     case OP_ENDIF                  : return "OP_ENDIF";
      55                 :       42299 :     case OP_VERIFY                 : return "OP_VERIFY";
      56                 :       76900 :     case OP_RETURN                 : return "OP_RETURN";
      57                 :             : 
      58                 :             :     // stack ops
      59                 :       26496 :     case OP_TOALTSTACK             : return "OP_TOALTSTACK";
      60                 :       24297 :     case OP_FROMALTSTACK           : return "OP_FROMALTSTACK";
      61                 :       15278 :     case OP_2DROP                  : return "OP_2DROP";
      62                 :       10807 :     case OP_2DUP                   : return "OP_2DUP";
      63                 :       36177 :     case OP_3DUP                   : return "OP_3DUP";
      64                 :       14401 :     case OP_2OVER                  : return "OP_2OVER";
      65                 :       12491 :     case OP_2ROT                   : return "OP_2ROT";
      66                 :       20035 :     case OP_2SWAP                  : return "OP_2SWAP";
      67                 :       24942 :     case OP_IFDUP                  : return "OP_IFDUP";
      68                 :       19712 :     case OP_DEPTH                  : return "OP_DEPTH";
      69                 :       16595 :     case OP_DROP                   : return "OP_DROP";
      70                 :       40869 :     case OP_DUP                    : return "OP_DUP";
      71                 :      119565 :     case OP_NIP                    : return "OP_NIP";
      72                 :       11696 :     case OP_OVER                   : return "OP_OVER";
      73                 :       13431 :     case OP_PICK                   : return "OP_PICK";
      74                 :       17795 :     case OP_ROLL                   : return "OP_ROLL";
      75                 :       38527 :     case OP_ROT                    : return "OP_ROT";
      76                 :      309839 :     case OP_SWAP                   : return "OP_SWAP";
      77                 :       14070 :     case OP_TUCK                   : return "OP_TUCK";
      78                 :             : 
      79                 :             :     // splice ops
      80                 :       12371 :     case OP_CAT                    : return "OP_CAT";
      81                 :      162762 :     case OP_SUBSTR                 : return "OP_SUBSTR";
      82                 :       47970 :     case OP_LEFT                   : return "OP_LEFT";
      83                 :       26989 :     case OP_RIGHT                  : return "OP_RIGHT";
      84                 :       10612 :     case OP_SIZE                   : return "OP_SIZE";
      85                 :             : 
      86                 :             :     // bit logic
      87                 :       19931 :     case OP_INVERT                 : return "OP_INVERT";
      88                 :       40675 :     case OP_AND                    : return "OP_AND";
      89                 :       15330 :     case OP_OR                     : return "OP_OR";
      90                 :       11277 :     case OP_XOR                    : return "OP_XOR";
      91                 :      175426 :     case OP_EQUAL                  : return "OP_EQUAL";
      92                 :       37716 :     case OP_EQUALVERIFY            : return "OP_EQUALVERIFY";
      93                 :       12110 :     case OP_RESERVED1              : return "OP_RESERVED1";
      94                 :       15302 :     case OP_RESERVED2              : return "OP_RESERVED2";
      95                 :             : 
      96                 :             :     // numeric
      97                 :       12270 :     case OP_1ADD                   : return "OP_1ADD";
      98                 :       10561 :     case OP_1SUB                   : return "OP_1SUB";
      99                 :       15759 :     case OP_2MUL                   : return "OP_2MUL";
     100                 :        8230 :     case OP_2DIV                   : return "OP_2DIV";
     101                 :       10216 :     case OP_NEGATE                 : return "OP_NEGATE";
     102                 :        9588 :     case OP_ABS                    : return "OP_ABS";
     103                 :       11258 :     case OP_NOT                    : return "OP_NOT";
     104                 :       96242 :     case OP_0NOTEQUAL              : return "OP_0NOTEQUAL";
     105                 :       14862 :     case OP_ADD                    : return "OP_ADD";
     106                 :       12264 :     case OP_SUB                    : return "OP_SUB";
     107                 :       15696 :     case OP_MUL                    : return "OP_MUL";
     108                 :       67536 :     case OP_DIV                    : return "OP_DIV";
     109                 :       16388 :     case OP_MOD                    : return "OP_MOD";
     110                 :       46777 :     case OP_LSHIFT                 : return "OP_LSHIFT";
     111                 :       19696 :     case OP_RSHIFT                 : return "OP_RSHIFT";
     112                 :       59910 :     case OP_BOOLAND                : return "OP_BOOLAND";
     113                 :       21020 :     case OP_BOOLOR                 : return "OP_BOOLOR";
     114                 :       22993 :     case OP_NUMEQUAL               : return "OP_NUMEQUAL";
     115                 :       11423 :     case OP_NUMEQUALVERIFY         : return "OP_NUMEQUALVERIFY";
     116                 :       21179 :     case OP_NUMNOTEQUAL            : return "OP_NUMNOTEQUAL";
     117                 :       22139 :     case OP_LESSTHAN               : return "OP_LESSTHAN";
     118                 :       10714 :     case OP_GREATERTHAN            : return "OP_GREATERTHAN";
     119                 :      501820 :     case OP_LESSTHANOREQUAL        : return "OP_LESSTHANOREQUAL";
     120                 :       11604 :     case OP_GREATERTHANOREQUAL     : return "OP_GREATERTHANOREQUAL";
     121                 :       34746 :     case OP_MIN                    : return "OP_MIN";
     122                 :       94025 :     case OP_MAX                    : return "OP_MAX";
     123                 :       29653 :     case OP_WITHIN                 : return "OP_WITHIN";
     124                 :             : 
     125                 :             :     // crypto
     126                 :       14263 :     case OP_RIPEMD160              : return "OP_RIPEMD160";
     127                 :       22672 :     case OP_SHA1                   : return "OP_SHA1";
     128                 :       10585 :     case OP_SHA256                 : return "OP_SHA256";
     129                 :      188144 :     case OP_HASH160                : return "OP_HASH160";
     130                 :       13765 :     case OP_HASH256                : return "OP_HASH256";
     131                 :       14085 :     case OP_CODESEPARATOR          : return "OP_CODESEPARATOR";
     132                 :      156520 :     case OP_CHECKSIG               : return "OP_CHECKSIG";
     133                 :       28648 :     case OP_CHECKSIGVERIFY         : return "OP_CHECKSIGVERIFY";
     134                 :      684593 :     case OP_CHECKMULTISIG          : return "OP_CHECKMULTISIG";
     135                 :      100992 :     case OP_CHECKMULTISIGVERIFY    : return "OP_CHECKMULTISIGVERIFY";
     136                 :             : 
     137                 :             :     // expansion
     138                 :       22936 :     case OP_NOP1                   : return "OP_NOP1";
     139                 :      313337 :     case OP_CHECKLOCKTIMEVERIFY    : return "OP_CHECKLOCKTIMEVERIFY";
     140                 :       18261 :     case OP_CHECKSEQUENCEVERIFY    : return "OP_CHECKSEQUENCEVERIFY";
     141                 :       14996 :     case OP_NOP4                   : return "OP_NOP4";
     142                 :       52280 :     case OP_NOP5                   : return "OP_NOP5";
     143                 :       12534 :     case OP_NOP6                   : return "OP_NOP6";
     144                 :       10663 :     case OP_NOP7                   : return "OP_NOP7";
     145                 :       17392 :     case OP_NOP8                   : return "OP_NOP8";
     146                 :       11169 :     case OP_NOP9                   : return "OP_NOP9";
     147                 :       23265 :     case OP_NOP10                  : return "OP_NOP10";
     148                 :             : 
     149                 :             :     // Opcode added by BIP 342 (Tapscript)
     150                 :       13854 :     case OP_CHECKSIGADD            : return "OP_CHECKSIGADD";
     151                 :             : 
     152                 :      117311 :     case OP_INVALIDOPCODE          : return "OP_INVALIDOPCODE";
     153                 :             : 
     154                 :     3407284 :     default:
     155                 :     3407284 :         return "OP_UNKNOWN";
     156                 :             :     }
     157                 :             : }
     158                 :             : 
     159                 :    20942538 : unsigned int CScript::GetSigOpCount(bool fAccurate) const
     160                 :             : {
     161                 :    20942538 :     unsigned int n = 0;
     162         [ +  + ]:    20942538 :     const_iterator pc = begin();
     163                 :    20942538 :     opcodetype lastOpcode = OP_INVALIDOPCODE;
     164         [ +  + ]:   153786473 :     while (pc < end())
     165                 :             :     {
     166                 :   133367098 :         opcodetype opcode;
     167         [ +  + ]:   133367098 :         if (!GetOp(pc, opcode))
     168                 :             :             break;
     169         [ +  + ]:   132843935 :         if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY)
     170                 :      598180 :             n++;
     171         [ +  + ]:   132245755 :         else if (opcode == OP_CHECKMULTISIG || opcode == OP_CHECKMULTISIGVERIFY)
     172                 :             :         {
     173   [ +  +  +  + ]:     1547850 :             if (fAccurate && lastOpcode >= OP_1 && lastOpcode <= OP_16)
     174                 :        4512 :                 n += DecodeOP_N(lastOpcode);
     175                 :             :             else
     176                 :     1543338 :                 n += MAX_PUBKEYS_PER_MULTISIG;
     177                 :             :         }
     178                 :             :         lastOpcode = opcode;
     179                 :             :     }
     180                 :    20942538 :     return n;
     181                 :             : }
     182                 :             : 
     183                 :        8152 : unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const
     184                 :             : {
     185         [ +  + ]:        8152 :     if (!IsPayToScriptHash())
     186                 :         310 :         return GetSigOpCount(true);
     187                 :             : 
     188                 :             :     // This is a pay-to-script-hash scriptPubKey;
     189                 :             :     // get the last item that the scriptSig
     190                 :             :     // pushes onto the stack:
     191         [ +  + ]:        7842 :     const_iterator pc = scriptSig.begin();
     192                 :        7842 :     std::vector<unsigned char> vData;
     193         [ +  + ]:       60308 :     while (pc < scriptSig.end())
     194                 :             :     {
     195                 :       58329 :         opcodetype opcode;
     196   [ +  -  +  + ]:       58329 :         if (!scriptSig.GetOp(pc, opcode, vData))
     197                 :             :             return 0;
     198         [ +  + ]:       53190 :         if (opcode > OP_16)
     199                 :             :             return 0;
     200                 :             :     }
     201                 :             : 
     202                 :             :     /// ... and return its opcount:
     203                 :        1979 :     CScript subscript(vData.begin(), vData.end());
     204         [ +  - ]:        1979 :     return subscript.GetSigOpCount(true);
     205                 :        9821 : }
     206                 :             : 
     207                 :     2320375 : bool CScript::IsPayToAnchor() const
     208                 :             : {
     209         [ +  + ]:     2320375 :     return (this->size() == 4 &&
     210   [ +  +  +  + ]:      143180 :         (*this)[0] == OP_1 &&
     211   [ +  +  +  + ]:       20408 :         (*this)[1] == 0x02 &&
     212   [ +  +  +  +  :     2340775 :         (*this)[2] == 0x4e &&
                   +  + ]
     213   [ +  +  +  + ]:        9564 :         (*this)[3] == 0x73);
     214                 :             : }
     215                 :             : 
     216                 :        9284 : bool CScript::IsPayToAnchor(int version, const std::vector<unsigned char>& program)
     217                 :             : {
     218                 :       16552 :     return version == 1 &&
     219         [ +  + ]:        7268 :         program.size() == 2 &&
     220   [ +  +  +  + ]:       14257 :         program[0] == 0x4e &&
     221         [ +  + ]:        3198 :         program[1] == 0x73;
     222                 :             : }
     223                 :             : 
     224                 :    22766137 : bool CScript::IsPayToScriptHash() const
     225                 :             : {
     226                 :             :     // Extra-fast test for pay-to-script-hash CScripts:
     227         [ +  + ]:    22766137 :     return (this->size() == 23 &&
     228   [ +  +  +  + ]:     1637978 :             (*this)[0] == OP_HASH160 &&
     229   [ +  +  +  +  :    24357025 :             (*this)[1] == 0x14 &&
                   +  + ]
     230   [ +  +  +  + ]:     1578864 :             (*this)[22] == OP_EQUAL);
     231                 :             : }
     232                 :             : 
     233                 :        5162 : bool CScript::IsPayToWitnessScriptHash() const
     234                 :             : {
     235                 :             :     // Extra-fast test for pay-to-witness-script-hash CScripts:
     236   [ +  +  +  + ]:        5205 :     return (this->size() == 34 &&
     237   [ +  +  +  +  :        4465 :             (*this)[0] == OP_0 &&
                   +  + ]
     238         [ +  + ]:          10 :             (*this)[1] == 0x20);
     239                 :             : }
     240                 :             : 
     241                 :       30356 : bool CScript::IsPayToTaproot() const
     242                 :             : {
     243   [ +  +  +  + ]:       34010 :     return (this->size() == 34 &&
     244   [ +  +  +  +  :        9652 :             (*this)[0] == OP_1 &&
                   +  + ]
     245         [ +  + ]:        2100 :             (*this)[1] == 0x20);
     246                 :             : }
     247                 :             : 
     248                 :             : // A witness program is any valid CScript that consists of a 1-byte push opcode
     249                 :             : // followed by a data push between 2 and 40 bytes.
     250                 :    57140711 : bool CScript::IsWitnessProgram(int& version, std::vector<unsigned char>& program) const
     251                 :             : {
     252   [ +  +  +  +  :   110114796 :     if (this->size() < 4 || this->size() > 42) {
             +  +  +  + ]
     253                 :             :         return false;
     254                 :             :     }
     255   [ +  +  +  +  :   106322524 :     if ((*this)[0] != OP_0 && ((*this)[0] < OP_1 || (*this)[0] > OP_16)) {
             +  +  +  + ]
     256                 :             :         return false;
     257                 :             :     }
     258   [ +  +  +  + ]:   104355634 :     if ((size_t)((*this)[1] + 2) == this->size()) {
     259                 :    52097184 :         version = DecodeOP_N((opcodetype)(*this)[0]);
     260         [ +  + ]:   156291552 :         program = std::vector<unsigned char>(this->begin() + 2, this->end());
     261                 :    52097184 :         return true;
     262                 :             :     }
     263                 :             :     return false;
     264                 :             : }
     265                 :             : 
     266                 :     5996661 : bool CScript::IsPushOnly(const_iterator pc) const
     267                 :             : {
     268         [ +  + ]:    62146118 :     while (pc < end())
     269                 :             :     {
     270                 :    56216818 :         opcodetype opcode;
     271         [ +  + ]:    56216818 :         if (!GetOp(pc, opcode))
     272                 :             :             return false;
     273                 :             :         // Note that IsPushOnly() *does* consider OP_RESERVED to be a
     274                 :             :         // push-type opcode, however execution of OP_RESERVED fails, so
     275                 :             :         // it's not relevant to P2SH/BIP62 as the scriptSig would fail prior to
     276                 :             :         // the P2SH special validation code being executed.
     277         [ +  + ]:    56178984 :         if (opcode > OP_16)
     278                 :             :             return false;
     279                 :             :     }
     280                 :             :     return true;
     281                 :             : }
     282                 :             : 
     283                 :     5930758 : bool CScript::IsPushOnly() const
     284                 :             : {
     285         [ +  + ]:    11861516 :     return this->IsPushOnly(begin());
     286                 :             : }
     287                 :             : 
     288                 :     1350947 : std::string CScriptWitness::ToString() const
     289                 :             : {
     290                 :     1350947 :     std::string ret = "CScriptWitness(";
     291         [ +  + ]:     8243652 :     for (unsigned int i = 0; i < stack.size(); i++) {
     292         [ +  + ]:     6892705 :         if (i) {
     293         [ +  - ]:     6860350 :             ret += ", ";
     294                 :             :         }
     295         [ +  - ]:    13785410 :         ret += HexStr(stack[i]);
     296                 :             :     }
     297         [ +  - ]:     1350947 :     return ret + ")";
     298                 :     1350947 : }
     299                 :             : 
     300                 :      662847 : bool CScript::HasValidOps() const
     301                 :             : {
     302         [ +  + ]:      662847 :     CScript::const_iterator it = begin();
     303         [ +  + ]:    28825447 :     while (it < end()) {
     304                 :    28168417 :         opcodetype opcode;
     305                 :    28168417 :         std::vector<unsigned char> item;
     306   [ +  -  +  +  :    28168417 :         if (!GetOp(it, opcode, item) || opcode > MAX_OPCODE || item.size() > MAX_SCRIPT_ELEMENT_SIZE) {
             +  +  +  + ]
     307                 :        5817 :             return false;
     308                 :             :         }
     309                 :    28168417 :     }
     310                 :             :     return true;
     311                 :             : }
     312                 :             : 
     313                 :   510362531 : bool GetScriptOp(CScriptBase::const_iterator& pc, CScriptBase::const_iterator end, opcodetype& opcodeRet, std::vector<unsigned char>* pvchRet)
     314                 :             : {
     315                 :   510362531 :     opcodeRet = OP_INVALIDOPCODE;
     316         [ +  + ]:   510362531 :     if (pvchRet)
     317         [ +  + ]:   107027955 :         pvchRet->clear();
     318         [ +  + ]:   510362531 :     if (pc >= end)
     319                 :             :         return false;
     320                 :             : 
     321                 :             :     // Read instruction
     322         [ +  - ]:   509933830 :     if (end - pc < 1)
     323                 :             :         return false;
     324         [ +  + ]:   509933830 :     unsigned int opcode = *pc++;
     325                 :             : 
     326                 :             :     // Immediate operand
     327         [ +  + ]:   509933830 :     if (opcode <= OP_PUSHDATA4)
     328                 :             :     {
     329                 :   204749813 :         unsigned int nSize = 0;
     330         [ +  + ]:   204749813 :         if (opcode < OP_PUSHDATA1)
     331                 :             :         {
     332                 :             :             nSize = opcode;
     333                 :             :         }
     334         [ +  + ]:    21936531 :         else if (opcode == OP_PUSHDATA1)
     335                 :             :         {
     336         [ +  + ]:    19616473 :             if (end - pc < 1)
     337                 :             :                 return false;
     338                 :    19604923 :             nSize = *pc++;
     339                 :             :         }
     340         [ +  + ]:     2320058 :         else if (opcode == OP_PUSHDATA2)
     341                 :             :         {
     342         [ +  + ]:     1256069 :             if (end - pc < 2)
     343                 :             :                 return false;
     344                 :     1238826 :             nSize = ReadLE16(&pc[0]);
     345                 :     1238826 :             pc += 2;
     346                 :             :         }
     347         [ +  - ]:     1063989 :         else if (opcode == OP_PUSHDATA4)
     348                 :             :         {
     349         [ +  + ]:     1063989 :             if (end - pc < 4)
     350                 :             :                 return false;
     351                 :     1053697 :             nSize = ReadLE32(&pc[0]);
     352                 :     1053697 :             pc += 4;
     353                 :             :         }
     354   [ +  -  +  + ]:   204710728 :         if (end - pc < 0 || (unsigned int)(end - pc) < nSize)
     355                 :     1582846 :             return false;
     356         [ +  + ]:   203127882 :         if (pvchRet)
     357                 :    46095513 :             pvchRet->assign(pc, pc + nSize);
     358                 :   203127882 :         pc += nSize;
     359                 :             :     }
     360                 :             : 
     361                 :   508311899 :     opcodeRet = static_cast<opcodetype>(opcode);
     362                 :   508311899 :     return true;
     363                 :             : }
     364                 :             : 
     365                 :      941845 : bool IsOpSuccess(const opcodetype& opcode)
     366                 :             : {
     367   [ +  +  +  +  :      941845 :     return opcode == 80 || opcode == 98 || (opcode >= 126 && opcode <= 129) ||
             +  +  +  +  
                      + ]
     368                 :             :            (opcode >= 131 && opcode <= 134) || (opcode >= 137 && opcode <= 138) ||
     369                 :             :            (opcode >= 141 && opcode <= 142) || (opcode >= 149 && opcode <= 153) ||
     370                 :      941845 :            (opcode >= 187 && opcode <= 254);
     371                 :             : }
     372                 :             : 
     373                 :    14486165 : bool CheckMinimalPush(const std::vector<unsigned char>& data, opcodetype opcode) {
     374                 :             :     // Excludes OP_1NEGATE, OP_1-16 since they are by definition minimal
     375         [ -  + ]:    14486165 :     assert(0 <= opcode && opcode <= OP_PUSHDATA4);
     376         [ +  + ]:    14486165 :     if (data.size() == 0) {
     377                 :             :         // Should have used OP_0.
     378                 :    11492888 :         return opcode == OP_0;
     379   [ +  +  +  +  :     2993277 :     } else if (data.size() == 1 && data[0] >= 1 && data[0] <= 16) {
                   +  + ]
     380                 :             :         // Should have used OP_1 .. OP_16.
     381                 :             :         return false;
     382   [ +  +  +  + ]:     2984489 :     } else if (data.size() == 1 && data[0] == 0x81) {
     383                 :             :         // Should have used OP_1NEGATE.
     384                 :             :         return false;
     385         [ +  + ]:     2982223 :     } else if (data.size() <= 75) {
     386                 :             :         // Must have used a direct push (opcode indicating number of bytes pushed + those bytes).
     387                 :     2902805 :         return opcode == data.size();
     388         [ +  + ]:       79418 :     } else if (data.size() <= 255) {
     389                 :             :         // Must have used OP_PUSHDATA.
     390                 :       60926 :         return opcode == OP_PUSHDATA1;
     391         [ +  + ]:       18492 :     } else if (data.size() <= 65535) {
     392                 :             :         // Must have used OP_PUSHDATA2.
     393                 :       18453 :         return opcode == OP_PUSHDATA2;
     394                 :             :     }
     395                 :             :     return true;
     396                 :             : }
        

Generated by: LCOV version 2.0-1