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 132223 : std::string ScriptErrorString(const ScriptError serror) 11 : { 12 132223 : switch (serror) 13 : { 14 : case SCRIPT_ERR_OK: 15 67713 : return "No error"; 16 : case SCRIPT_ERR_EVAL_FALSE: 17 37 : return "Script evaluated without error but finished with a false/empty top stack element"; 18 : case SCRIPT_ERR_VERIFY: 19 1 : return "Script failed an OP_VERIFY operation"; 20 : case SCRIPT_ERR_EQUALVERIFY: 21 1 : return "Script failed an OP_EQUALVERIFY operation"; 22 : case SCRIPT_ERR_CHECKMULTISIGVERIFY: 23 2 : return "Script failed an OP_CHECKMULTISIGVERIFY operation"; 24 : case SCRIPT_ERR_CHECKSIGVERIFY: 25 7 : return "Script failed an OP_CHECKSIGVERIFY operation"; 26 : case SCRIPT_ERR_NUMEQUALVERIFY: 27 0 : return "Script failed an OP_NUMEQUALVERIFY operation"; 28 : case SCRIPT_ERR_SCRIPT_SIZE: 29 0 : return "Script is too big"; 30 : case SCRIPT_ERR_PUSH_SIZE: 31 1 : return "Push value size limit exceeded"; 32 : case SCRIPT_ERR_OP_COUNT: 33 0 : return "Operation limit exceeded"; 34 : case SCRIPT_ERR_STACK_SIZE: 35 0 : return "Stack size limit exceeded"; 36 : case SCRIPT_ERR_SIG_COUNT: 37 0 : return "Signature count negative or greater than pubkey count"; 38 : case SCRIPT_ERR_PUBKEY_COUNT: 39 0 : return "Pubkey count negative or limit exceeded"; 40 : case SCRIPT_ERR_BAD_OPCODE: 41 2 : return "Opcode missing or not understood"; 42 : case SCRIPT_ERR_DISABLED_OPCODE: 43 30 : return "Attempted to use a disabled opcode"; 44 : case SCRIPT_ERR_INVALID_STACK_OPERATION: 45 16405 : return "Operation not valid with the current stack size"; 46 : case SCRIPT_ERR_INVALID_ALTSTACK_OPERATION: 47 0 : return "Operation not valid with the current altstack size"; 48 : case SCRIPT_ERR_OP_RETURN: 49 0 : return "OP_RETURN was encountered"; 50 : case SCRIPT_ERR_UNBALANCED_CONDITIONAL: 51 12 : return "Invalid OP_IF construction"; 52 : case SCRIPT_ERR_NEGATIVE_LOCKTIME: 53 10 : return "Negative locktime"; 54 : case SCRIPT_ERR_UNSATISFIED_LOCKTIME: 55 16500 : return "Locktime requirement not satisfied"; 56 : case SCRIPT_ERR_SIG_HASHTYPE: 57 0 : return "Signature hash type missing or not understood"; 58 : case SCRIPT_ERR_SIG_DER: 59 16134 : return "Non-canonical DER signature"; 60 : case SCRIPT_ERR_MINIMALDATA: 61 0 : return "Data push larger than necessary"; 62 : case SCRIPT_ERR_SIG_PUSHONLY: 63 0 : return "Only push operators allowed in signatures"; 64 : case SCRIPT_ERR_SIG_HIGH_S: 65 0 : return "Non-canonical signature: S value is unnecessarily high"; 66 : case SCRIPT_ERR_SIG_NULLDUMMY: 67 8 : return "Dummy CHECKMULTISIG argument must be zero"; 68 : case SCRIPT_ERR_MINIMALIF: 69 0 : return "OP_IF/NOTIF argument must be minimal"; 70 : case SCRIPT_ERR_SIG_NULLFAIL: 71 0 : return "Signature must be zero for failed CHECK(MULTI)SIG operation"; 72 : case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS: 73 0 : return "NOPx reserved for soft-fork upgrades"; 74 : case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM: 75 3 : return "Witness version reserved for soft-fork upgrades"; 76 : case SCRIPT_ERR_PUBKEYTYPE: 77 0 : return "Public key is neither compressed or uncompressed"; 78 : case SCRIPT_ERR_CLEANSTACK: 79 2 : return "Extra items left on stack after execution"; 80 : case SCRIPT_ERR_WITNESS_PROGRAM_WRONG_LENGTH: 81 2 : return "Witness program has incorrect length"; 82 : case SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY: 83 12 : return "Witness program was passed an empty witness"; 84 : case SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH: 85 15321 : return "Witness program hash mismatch"; 86 : case SCRIPT_ERR_WITNESS_MALLEATED: 87 1 : return "Witness requires empty scriptSig"; 88 : case SCRIPT_ERR_WITNESS_MALLEATED_P2SH: 89 0 : return "Witness requires only-redeemscript scriptSig"; 90 : case SCRIPT_ERR_WITNESS_UNEXPECTED: 91 2 : return "Witness provided for non-witness script"; 92 : case SCRIPT_ERR_WITNESS_PUBKEYTYPE: 93 3 : return "Using non-compressed keys in segwit"; 94 : case SCRIPT_ERR_OP_CODESEPARATOR: 95 7 : return "Using OP_CODESEPARATOR in non-witness script"; 96 : case SCRIPT_ERR_SIG_FINDANDDELETE: 97 5 : return "Signature is found in scriptCode"; 98 : case SCRIPT_ERR_UNKNOWN_ERROR: 99 : case SCRIPT_ERR_ERROR_COUNT: 100 : default: break; 101 : } 102 2 : return "unknown error"; 103 132223 : }