Coverage Report

Created: 2026-06-01 18:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/bitcoin/src/script/script_error.cpp
Line
Count
Source
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_error.h>
7
8
#include <string>
9
10
std::string ScriptErrorString(const ScriptError serror)
11
0
{
12
0
    switch (serror)
  Branch (12:13): [True: 0, False: 0]
13
0
    {
14
0
        case SCRIPT_ERR_OK:
  Branch (14:9): [True: 0, False: 0]
15
0
            return "No error";
16
0
        case SCRIPT_ERR_EVAL_FALSE:
  Branch (16:9): [True: 0, False: 0]
17
0
            return "Script evaluated without error but finished with a false/empty top stack element";
18
0
        case SCRIPT_ERR_VERIFY:
  Branch (18:9): [True: 0, False: 0]
19
0
            return "Script failed an OP_VERIFY operation";
20
0
        case SCRIPT_ERR_EQUALVERIFY:
  Branch (20:9): [True: 0, False: 0]
21
0
            return "Script failed an OP_EQUALVERIFY operation";
22
0
        case SCRIPT_ERR_CHECKMULTISIGVERIFY:
  Branch (22:9): [True: 0, False: 0]
23
0
            return "Script failed an OP_CHECKMULTISIGVERIFY operation";
24
0
        case SCRIPT_ERR_CHECKSIGVERIFY:
  Branch (24:9): [True: 0, False: 0]
25
0
            return "Script failed an OP_CHECKSIGVERIFY operation";
26
0
        case SCRIPT_ERR_NUMEQUALVERIFY:
  Branch (26:9): [True: 0, False: 0]
27
0
            return "Script failed an OP_NUMEQUALVERIFY operation";
28
0
        case SCRIPT_ERR_SCRIPT_SIZE:
  Branch (28:9): [True: 0, False: 0]
29
0
            return "Script is too big";
30
0
        case SCRIPT_ERR_PUSH_SIZE:
  Branch (30:9): [True: 0, False: 0]
31
0
            return "Push value size limit exceeded";
32
0
        case SCRIPT_ERR_OP_COUNT:
  Branch (32:9): [True: 0, False: 0]
33
0
            return "Operation limit exceeded";
34
0
        case SCRIPT_ERR_STACK_SIZE:
  Branch (34:9): [True: 0, False: 0]
35
0
            return "Stack size limit exceeded";
36
0
        case SCRIPT_ERR_SIG_COUNT:
  Branch (36:9): [True: 0, False: 0]
37
0
            return "Signature count negative or greater than pubkey count";
38
0
        case SCRIPT_ERR_PUBKEY_COUNT:
  Branch (38:9): [True: 0, False: 0]
39
0
            return "Pubkey count negative or limit exceeded";
40
0
        case SCRIPT_ERR_BAD_OPCODE:
  Branch (40:9): [True: 0, False: 0]
41
0
            return "Opcode missing or not understood";
42
0
        case SCRIPT_ERR_DISABLED_OPCODE:
  Branch (42:9): [True: 0, False: 0]
43
0
            return "Attempted to use a disabled opcode";
44
0
        case SCRIPT_ERR_INVALID_STACK_OPERATION:
  Branch (44:9): [True: 0, False: 0]
45
0
            return "Operation not valid with the current stack size";
46
0
        case SCRIPT_ERR_INVALID_ALTSTACK_OPERATION:
  Branch (46:9): [True: 0, False: 0]
47
0
            return "Operation not valid with the current altstack size";
48
0
        case SCRIPT_ERR_OP_RETURN:
  Branch (48:9): [True: 0, False: 0]
49
0
            return "OP_RETURN was encountered";
50
0
        case SCRIPT_ERR_UNBALANCED_CONDITIONAL:
  Branch (50:9): [True: 0, False: 0]
51
0
            return "Invalid OP_IF construction";
52
0
        case SCRIPT_ERR_NEGATIVE_LOCKTIME:
  Branch (52:9): [True: 0, False: 0]
53
0
            return "Negative locktime";
54
0
        case SCRIPT_ERR_UNSATISFIED_LOCKTIME:
  Branch (54:9): [True: 0, False: 0]
55
0
            return "Locktime requirement not satisfied";
56
0
        case SCRIPT_ERR_SIG_HASHTYPE:
  Branch (56:9): [True: 0, False: 0]
57
0
            return "Signature hash type missing or not understood";
58
0
        case SCRIPT_ERR_SIG_DER:
  Branch (58:9): [True: 0, False: 0]
59
0
            return "Non-canonical DER signature";
60
0
        case SCRIPT_ERR_MINIMALDATA:
  Branch (60:9): [True: 0, False: 0]
61
0
            return "Data push larger than necessary";
62
0
        case SCRIPT_ERR_SIG_PUSHONLY:
  Branch (62:9): [True: 0, False: 0]
63
0
            return "Only push operators allowed in signatures";
64
0
        case SCRIPT_ERR_SIG_HIGH_S:
  Branch (64:9): [True: 0, False: 0]
65
0
            return "Non-canonical signature: S value is unnecessarily high";
66
0
        case SCRIPT_ERR_SIG_NULLDUMMY:
  Branch (66:9): [True: 0, False: 0]
67
0
            return "Dummy CHECKMULTISIG argument must be zero";
68
0
        case SCRIPT_ERR_MINIMALIF:
  Branch (68:9): [True: 0, False: 0]
69
0
            return "OP_IF/NOTIF argument must be minimal";
70
0
        case SCRIPT_ERR_SIG_NULLFAIL:
  Branch (70:9): [True: 0, False: 0]
71
0
            return "Signature must be zero for failed CHECK(MULTI)SIG operation";
72
0
        case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS:
  Branch (72:9): [True: 0, False: 0]
73
0
            return "NOPx reserved for soft-fork upgrades";
74
0
        case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM:
  Branch (74:9): [True: 0, False: 0]
75
0
            return "Witness version reserved for soft-fork upgrades";
76
0
        case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION:
  Branch (76:9): [True: 0, False: 0]
77
0
            return "Taproot version reserved for soft-fork upgrades";
78
0
        case SCRIPT_ERR_DISCOURAGE_OP_SUCCESS:
  Branch (78:9): [True: 0, False: 0]
79
0
            return "OP_SUCCESSx reserved for soft-fork upgrades";
80
0
        case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_PUBKEYTYPE:
  Branch (80:9): [True: 0, False: 0]
81
0
            return "Public key version reserved for soft-fork upgrades";
82
0
        case SCRIPT_ERR_PUBKEYTYPE:
  Branch (82:9): [True: 0, False: 0]
83
0
            return "Public key is neither compressed or uncompressed";
84
0
        case SCRIPT_ERR_CLEANSTACK:
  Branch (84:9): [True: 0, False: 0]
85
0
            return "Stack size must be exactly one after execution";
86
0
        case SCRIPT_ERR_WITNESS_PROGRAM_WRONG_LENGTH:
  Branch (86:9): [True: 0, False: 0]
87
0
            return "Witness program has incorrect length";
88
0
        case SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY:
  Branch (88:9): [True: 0, False: 0]
89
0
            return "Witness program was passed an empty witness";
90
0
        case SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH:
  Branch (90:9): [True: 0, False: 0]
91
0
            return "Witness program hash mismatch";
92
0
        case SCRIPT_ERR_WITNESS_MALLEATED:
  Branch (92:9): [True: 0, False: 0]
93
0
            return "Witness requires empty scriptSig";
94
0
        case SCRIPT_ERR_WITNESS_MALLEATED_P2SH:
  Branch (94:9): [True: 0, False: 0]
95
0
            return "Witness requires only-redeemscript scriptSig";
96
0
        case SCRIPT_ERR_WITNESS_UNEXPECTED:
  Branch (96:9): [True: 0, False: 0]
97
0
            return "Witness provided for non-witness script";
98
0
        case SCRIPT_ERR_WITNESS_PUBKEYTYPE:
  Branch (98:9): [True: 0, False: 0]
99
0
            return "Using non-compressed keys in segwit";
100
0
        case SCRIPT_ERR_SCHNORR_SIG_SIZE:
  Branch (100:9): [True: 0, False: 0]
101
0
            return "Invalid Schnorr signature size";
102
0
        case SCRIPT_ERR_SCHNORR_SIG_HASHTYPE:
  Branch (102:9): [True: 0, False: 0]
103
0
            return "Invalid Schnorr signature hash type";
104
0
        case SCRIPT_ERR_SCHNORR_SIG:
  Branch (104:9): [True: 0, False: 0]
105
0
            return "Invalid Schnorr signature";
106
0
        case SCRIPT_ERR_TAPROOT_WRONG_CONTROL_SIZE:
  Branch (106:9): [True: 0, False: 0]
107
0
            return "Invalid Taproot control block size";
108
0
        case SCRIPT_ERR_TAPSCRIPT_VALIDATION_WEIGHT:
  Branch (108:9): [True: 0, False: 0]
109
0
            return "Too much signature validation relative to witness weight";
110
0
        case SCRIPT_ERR_TAPSCRIPT_CHECKMULTISIG:
  Branch (110:9): [True: 0, False: 0]
111
0
            return "OP_CHECKMULTISIG(VERIFY) is not available in tapscript";
112
0
        case SCRIPT_ERR_TAPSCRIPT_MINIMALIF:
  Branch (112:9): [True: 0, False: 0]
113
0
            return "OP_IF/NOTIF argument must be minimal in tapscript";
114
0
        case SCRIPT_ERR_TAPSCRIPT_EMPTY_PUBKEY:
  Branch (114:9): [True: 0, False: 0]
115
0
            return "Empty public key in tapscript";
116
0
        case SCRIPT_ERR_OP_CODESEPARATOR:
  Branch (116:9): [True: 0, False: 0]
117
0
            return "Using OP_CODESEPARATOR in non-witness script";
118
0
        case SCRIPT_ERR_SIG_FINDANDDELETE:
  Branch (118:9): [True: 0, False: 0]
119
0
            return "Signature is found in scriptCode";
120
0
        case SCRIPT_ERR_SCRIPTNUM:
  Branch (120:9): [True: 0, False: 0]
121
0
            return "Script number overflowed or is non-minimally encoded";
122
0
        case SCRIPT_ERR_UNKNOWN_ERROR:
  Branch (122:9): [True: 0, False: 0]
123
0
        case SCRIPT_ERR_ERROR_COUNT:
  Branch (123:9): [True: 0, False: 0]
124
0
            break;
125
0
    } // no default case, so the compiler can warn about missing cases
126
0
    return "unknown error";
127
0
}