Branch data Line data Source code
# 1 : : // Copyright (c) 2009-2010 Satoshi Nakamoto # 2 : : // Copyright (c) 2009-2020 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 : 246692 : { # 12 : 246692 : switch (serror) # 13 : 246692 : { # 14 [ + + ]: 150270 : case SCRIPT_ERR_OK: # 15 : 150270 : return "No error"; # 16 [ + + ]: 819 : case SCRIPT_ERR_EVAL_FALSE: # 17 : 819 : return "Script evaluated without error but finished with a false/empty top stack element"; # 18 [ + + ]: 44 : case SCRIPT_ERR_VERIFY: # 19 : 44 : return "Script failed an OP_VERIFY operation"; # 20 [ + + ]: 2 : case SCRIPT_ERR_EQUALVERIFY: # 21 : 2 : return "Script failed an OP_EQUALVERIFY operation"; # 22 [ + + ]: 92 : case SCRIPT_ERR_CHECKMULTISIGVERIFY: # 23 : 92 : return "Script failed an OP_CHECKMULTISIGVERIFY operation"; # 24 [ + + ]: 355 : case SCRIPT_ERR_CHECKSIGVERIFY: # 25 : 355 : return "Script failed an OP_CHECKSIGVERIFY operation"; # 26 [ - + ]: 0 : case SCRIPT_ERR_NUMEQUALVERIFY: # 27 : 0 : return "Script failed an OP_NUMEQUALVERIFY operation"; # 28 [ + + ]: 1 : case SCRIPT_ERR_SCRIPT_SIZE: # 29 : 1 : return "Script is too big"; # 30 [ + + ]: 500 : case SCRIPT_ERR_PUSH_SIZE: # 31 : 500 : return "Push value size limit exceeded"; # 32 [ - + ]: 0 : case SCRIPT_ERR_OP_COUNT: # 33 : 0 : return "Operation limit exceeded"; # 34 [ + + ]: 849 : case SCRIPT_ERR_STACK_SIZE: # 35 : 849 : return "Stack size limit exceeded"; # 36 [ - + ]: 0 : case SCRIPT_ERR_SIG_COUNT: # 37 : 0 : return "Signature count negative or greater than pubkey count"; # 38 [ - + ]: 0 : case SCRIPT_ERR_PUBKEY_COUNT: # 39 : 0 : return "Pubkey count negative or limit exceeded"; # 40 [ + + ]: 633 : case SCRIPT_ERR_BAD_OPCODE: # 41 : 633 : return "Opcode missing or not understood"; # 42 [ + + ]: 30 : case SCRIPT_ERR_DISABLED_OPCODE: # 43 : 30 : return "Attempted to use a disabled opcode"; # 44 [ + + ]: 18085 : case SCRIPT_ERR_INVALID_STACK_OPERATION: # 45 : 18085 : return "Operation not valid with the current stack size"; # 46 [ - + ]: 0 : case SCRIPT_ERR_INVALID_ALTSTACK_OPERATION: # 47 : 0 : return "Operation not valid with the current altstack size"; # 48 [ + + ]: 731 : case SCRIPT_ERR_OP_RETURN: # 49 : 731 : return "OP_RETURN was encountered"; # 50 [ + + ]: 88 : case SCRIPT_ERR_UNBALANCED_CONDITIONAL: # 51 : 88 : return "Invalid OP_IF construction"; # 52 [ + + ]: 411 : case SCRIPT_ERR_NEGATIVE_LOCKTIME: # 53 : 411 : return "Negative locktime"; # 54 [ + + ]: 22215 : case SCRIPT_ERR_UNSATISFIED_LOCKTIME: # 55 : 22215 : return "Locktime requirement not satisfied"; # 56 [ + + ]: 42 : case SCRIPT_ERR_SIG_HASHTYPE: # 57 : 42 : return "Signature hash type missing or not understood"; # 58 [ + + ]: 17805 : case SCRIPT_ERR_SIG_DER: # 59 : 17805 : return "Non-canonical DER signature"; # 60 [ + + ]: 31 : case SCRIPT_ERR_MINIMALDATA: # 61 : 31 : return "Data push larger than necessary"; # 62 [ + + ]: 236 : case SCRIPT_ERR_SIG_PUSHONLY: # 63 : 236 : return "Only push operators allowed in signatures"; # 64 [ + + ]: 208 : case SCRIPT_ERR_SIG_HIGH_S: # 65 : 208 : return "Non-canonical signature: S value is unnecessarily high"; # 66 [ + + ]: 148 : case SCRIPT_ERR_SIG_NULLDUMMY: # 67 : 148 : return "Dummy CHECKMULTISIG argument must be zero"; # 68 [ - + ]: 0 : case SCRIPT_ERR_MINIMALIF: # 69 : 0 : return "OP_IF/NOTIF argument must be minimal"; # 70 [ + + ]: 282 : case SCRIPT_ERR_SIG_NULLFAIL: # 71 : 282 : return "Signature must be zero for failed CHECK(MULTI)SIG operation"; # 72 [ - + ]: 0 : case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS: # 73 : 0 : return "NOPx reserved for soft-fork upgrades"; # 74 [ + + ]: 240 : case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM: # 75 : 240 : return "Witness version reserved for soft-fork upgrades"; # 76 [ + + ]: 514 : case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION: # 77 : 514 : return "Taproot version reserved for soft-fork upgrades"; # 78 [ + + ]: 632 : case SCRIPT_ERR_DISCOURAGE_OP_SUCCESS: # 79 : 632 : return "OP_SUCCESSx reserved for soft-fork upgrades"; # 80 [ + + ]: 17 : case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_PUBKEYTYPE: # 81 : 17 : return "Public key version reserved for soft-fork upgrades"; # 82 [ + + ]: 22 : case SCRIPT_ERR_PUBKEYTYPE: # 83 : 22 : return "Public key is neither compressed or uncompressed"; # 84 [ + + ]: 867 : case SCRIPT_ERR_CLEANSTACK: # 85 : 867 : return "Stack size must be exactly one after execution"; # 86 [ + + ]: 172 : case SCRIPT_ERR_WITNESS_PROGRAM_WRONG_LENGTH: # 87 : 172 : return "Witness program has incorrect length"; # 88 [ + + ]: 2899 : case SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY: # 89 : 2899 : return "Witness program was passed an empty witness"; # 90 [ + + ]: 24815 : case SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH: # 91 : 24815 : return "Witness program hash mismatch"; # 92 [ + + ]: 88 : case SCRIPT_ERR_WITNESS_MALLEATED: # 93 : 88 : return "Witness requires empty scriptSig"; # 94 [ - + ]: 0 : case SCRIPT_ERR_WITNESS_MALLEATED_P2SH: # 95 : 0 : return "Witness requires only-redeemscript scriptSig"; # 96 [ + + ]: 3 : case SCRIPT_ERR_WITNESS_UNEXPECTED: # 97 : 3 : return "Witness provided for non-witness script"; # 98 [ + + ]: 27 : case SCRIPT_ERR_WITNESS_PUBKEYTYPE: # 99 : 27 : return "Using non-compressed keys in segwit"; # 100 [ + + ]: 33 : case SCRIPT_ERR_SCHNORR_SIG_SIZE: # 101 : 33 : return "Invalid Schnorr signature size"; # 102 [ + + ]: 1010 : case SCRIPT_ERR_SCHNORR_SIG_HASHTYPE: # 103 : 1010 : return "Invalid Schnorr signature hash type"; # 104 [ + + ]: 139 : case SCRIPT_ERR_SCHNORR_SIG: # 105 : 139 : return "Invalid Schnorr signature"; # 106 [ + + ]: 11 : case SCRIPT_ERR_TAPROOT_WRONG_CONTROL_SIZE: # 107 : 11 : return "Invalid Taproot control block size"; # 108 [ + + ]: 79 : case SCRIPT_ERR_TAPSCRIPT_VALIDATION_WEIGHT: # 109 : 79 : return "Too much signature validation relative to witness weight"; # 110 [ + + ]: 6 : case SCRIPT_ERR_TAPSCRIPT_CHECKMULTISIG: # 111 : 6 : return "OP_CHECKMULTISIG(VERIFY) is not available in tapscript"; # 112 [ + + ]: 6 : case SCRIPT_ERR_TAPSCRIPT_MINIMALIF: # 113 : 6 : return "OP_IF/NOTIF argument must be minimal in tapscript"; # 114 [ + + ]: 618 : case SCRIPT_ERR_OP_CODESEPARATOR: # 115 : 618 : return "Using OP_CODESEPARATOR in non-witness script"; # 116 [ + + ]: 438 : case SCRIPT_ERR_SIG_FINDANDDELETE: # 117 : 438 : return "Signature is found in scriptCode"; # 118 [ + + ]: 179 : case SCRIPT_ERR_UNKNOWN_ERROR: # 119 [ - + ]: 179 : case SCRIPT_ERR_ERROR_COUNT: # 120 [ - + ]: 179 : default: break; # 121 : 246692 : } # 122 : 179 : return "unknown error"; # 123 : 246692 : }