github.com/BlockABC/godash@v0.0.0-20191112120524-f4aa3a32c566/txscript/error.go (about) 1 // Copyright (c) 2013-2015 The btcsuite developers 2 // Copyright (c) 2016 The Dash developers 3 // Use of this source code is governed by an ISC 4 // license that can be found in the LICENSE file. 5 6 package txscript 7 8 import ( 9 "errors" 10 "fmt" 11 ) 12 13 var ( 14 // ErrStackShortScript is returned if the script has an opcode that is 15 // too long for the length of the script. 16 ErrStackShortScript = errors.New("execute past end of script") 17 18 // ErrStackLongScript is returned if the script has an opcode that is 19 // too long for the length of the script. 20 ErrStackLongScript = errors.New("script is longer than maximum allowed") 21 22 // ErrStackUnderflow is returned if an opcode requires more items on the 23 // stack than is present.f 24 ErrStackUnderflow = errors.New("stack underflow") 25 26 // ErrStackInvalidArgs is returned if the argument for an opcode is out 27 // of acceptable range. 28 ErrStackInvalidArgs = errors.New("invalid argument") 29 30 // ErrStackOpDisabled is returned when a disabled opcode is encountered 31 // in the script. 32 ErrStackOpDisabled = errors.New("disabled opcode") 33 34 // ErrStackVerifyFailed is returned when one of the OP_VERIFY or 35 // OP_*VERIFY instructions is executed and the conditions fails. 36 ErrStackVerifyFailed = errors.New("verify failed") 37 38 // ErrStackNumberTooBig is returned when the argument for an opcode that 39 // should be an offset is obviously far too large. 40 ErrStackNumberTooBig = errors.New("number too big") 41 42 // ErrStackInvalidOpcode is returned when an opcode marked as invalid or 43 // a completely undefined opcode is encountered. 44 ErrStackInvalidOpcode = errors.New("invalid opcode") 45 46 // ErrStackReservedOpcode is returned when an opcode marked as reserved 47 // is encountered. 48 ErrStackReservedOpcode = errors.New("reserved opcode") 49 50 // ErrStackEarlyReturn is returned when OP_RETURN is executed in the 51 // script. 52 ErrStackEarlyReturn = errors.New("script returned early") 53 54 // ErrStackNoIf is returned if an OP_ELSE or OP_ENDIF is encountered 55 // without first having an OP_IF or OP_NOTIF in the script. 56 ErrStackNoIf = errors.New("OP_ELSE or OP_ENDIF with no matching OP_IF") 57 58 // ErrStackMissingEndif is returned if the end of a script is reached 59 // without and OP_ENDIF to correspond to a conditional expression. 60 ErrStackMissingEndif = fmt.Errorf("execute fail, in conditional execution") 61 62 // ErrStackTooManyPubKeys is returned if an OP_CHECKMULTISIG is 63 // encountered with more than MaxPubKeysPerMultiSig pubkeys present. 64 ErrStackTooManyPubKeys = errors.New("invalid pubkey count in OP_CHECKMULTISIG") 65 66 // ErrStackTooManyOperations is returned if a script has more than 67 // MaxOpsPerScript opcodes that do not push data. 68 ErrStackTooManyOperations = errors.New("too many operations in script") 69 70 // ErrStackElementTooBig is returned if the size of an element to be 71 // pushed to the stack is over MaxScriptElementSize. 72 ErrStackElementTooBig = errors.New("element in script too large") 73 74 // ErrStackUnknownAddress is returned when ScriptToAddrHash does not 75 // recognize the pattern of the script and thus can not find the address 76 // for payment. 77 ErrStackUnknownAddress = errors.New("non-recognised address") 78 79 // ErrStackScriptFailed is returned when at the end of a script the 80 // boolean on top of the stack is false signifying that the script has 81 // failed. 82 ErrStackScriptFailed = errors.New("execute fail, fail on stack") 83 84 // ErrStackScriptUnfinished is returned when CheckErrorCondition is 85 // called on a script that has not finished executing. 86 ErrStackScriptUnfinished = errors.New("error check when script unfinished") 87 88 // ErrStackEmptyStack is returned when the stack is empty at the end of 89 // execution. Normal operation requires that a boolean is on top of the 90 // stack when the scripts have finished executing. 91 ErrStackEmptyStack = errors.New("stack empty at end of execution") 92 93 // ErrStackP2SHNonPushOnly is returned when a Pay-to-Script-Hash 94 // transaction is encountered and the ScriptSig does operations other 95 // than push data (in violation of bip16). 96 ErrStackP2SHNonPushOnly = errors.New("pay to script hash with non " + 97 "pushonly input") 98 99 // ErrStackInvalidParseType is an internal error returned from 100 // ScriptToAddrHash ony if the internal data tables are wrong. 101 ErrStackInvalidParseType = errors.New("internal error: invalid parsetype found") 102 103 // ErrStackInvalidAddrOffset is an internal error returned from 104 // ScriptToAddrHash ony if the internal data tables are wrong. 105 ErrStackInvalidAddrOffset = errors.New("internal error: invalid offset found") 106 107 // ErrStackInvalidIndex is returned when an out-of-bounds index was 108 // passed to a function. 109 ErrStackInvalidIndex = errors.New("invalid script index") 110 111 // ErrStackNonPushOnly is returned when ScriptInfo is called with a 112 // pkScript that peforms operations other that pushing data to the stack. 113 ErrStackNonPushOnly = errors.New("SigScript is non pushonly") 114 115 // ErrStackOverflow is returned when stack and altstack combined depth 116 // is over the limit. 117 ErrStackOverflow = errors.New("stack overflow") 118 119 // ErrStackInvalidLowSSignature is returned when the ScriptVerifyLowS 120 // flag is set and the script contains any signatures whose S values 121 // are higher than the half order. 122 ErrStackInvalidLowSSignature = errors.New("invalid low s signature") 123 124 // ErrStackInvalidPubKey is returned when the ScriptVerifyScriptEncoding 125 // flag is set and the script contains invalid pubkeys. 126 ErrStackInvalidPubKey = errors.New("invalid strict pubkey") 127 128 // ErrStackCleanStack is returned when the ScriptVerifyCleanStack flag 129 // is set and after evalution the stack does not contain only one element, 130 // which also must be true if interpreted as a boolean. 131 ErrStackCleanStack = errors.New("stack is not clean") 132 133 // ErrStackMinimalData is returned when the ScriptVerifyMinimalData flag 134 // is set and the script contains push operations that do not use 135 // the minimal opcode required. 136 ErrStackMinimalData = errors.New("non-minimally encoded script number") 137 ) 138 139 var ( 140 // ErrInvalidFlags is returned when the passed flags to NewScript 141 // contain an invalid combination. 142 ErrInvalidFlags = errors.New("invalid flags combination") 143 144 // ErrInvalidIndex is returned when the passed input index for the 145 // provided transaction is out of range. 146 ErrInvalidIndex = errors.New("invalid input index") 147 148 // ErrUnsupportedAddress is returned when a concrete type that 149 // implements a godashutil.Address is not a supported type. 150 ErrUnsupportedAddress = errors.New("unsupported address type") 151 152 // ErrBadNumRequired is returned from MultiSigScript when nrequired is 153 // larger than the number of provided public keys. 154 ErrBadNumRequired = errors.New("more signatures required than keys present") 155 )