Group the StackErrX definitions.

This improves the godoc display and provides a cleaner separation of the
error definitions from other variables.
This commit is contained in:
Dave Collins 2014-01-04 09:56:02 -06:00
parent eb4fc19b95
commit b713590902

147
script.go
View file

@ -19,99 +19,104 @@ import (
"time" "time"
) )
// StackErrShortScript is returned if the script has an opcode that is too long var (
// for the length of the script. // StackErrShortScript is returned if the script has an opcode that is
var StackErrShortScript = errors.New("execute past end of script") // too long for the length of the script.
StackErrShortScript = errors.New("execute past end of script")
// StackErrUnderflow is returned if an opcode requires more items on the stack // StackErrUnderflow is returned if an opcode requires more items on the
// than is present. // stack than is present.
var StackErrUnderflow = errors.New("stack underflow") StackErrUnderflow = errors.New("stack underflow")
// StackErrInvalidArgs is returned if the argument for an opcode is out of // StackErrInvalidArgs is returned if the argument for an opcode is out
// acceptable range. // of acceptable range.
var StackErrInvalidArgs = errors.New("invalid argument") StackErrInvalidArgs = errors.New("invalid argument")
// StackErrOpDisabled is returned when a disabled opcode is encountered in the // StackErrOpDisabled is returned when a disabled opcode is encountered
// script. // in the script.
var StackErrOpDisabled = errors.New("Disabled Opcode") StackErrOpDisabled = errors.New("Disabled Opcode")
// StackErrVerifyFailed is returned when one of the OP_VERIFY or OP_*VERIFY // StackErrVerifyFailed is returned when one of the OP_VERIFY or
// instructions is executed and the conditions fails. // OP_*VERIFY instructions is executed and the conditions fails.
var StackErrVerifyFailed = errors.New("Verify failed") StackErrVerifyFailed = errors.New("Verify failed")
// StackErrNumberTooBig is returned when the argument for an opcode that should // StackErrNumberTooBig is returned when the argument for an opcode that
// be an offset is obviously far too large. // should be an offset is obviously far too large.
var StackErrNumberTooBig = errors.New("number too big") StackErrNumberTooBig = errors.New("number too big")
// StackErrInvalidOpcode is returned when an opcode marked as invalid or a // StackErrInvalidOpcode is returned when an opcode marked as invalid or
// completely undefined opcode is encountered. // a completely undefined opcode is encountered.
var StackErrInvalidOpcode = errors.New("Invalid Opcode") StackErrInvalidOpcode = errors.New("Invalid Opcode")
// StackErrReservedOpcode is returned when an opcode marked as reserved is // StackErrReservedOpcode is returned when an opcode marked as reserved
// encountered. // is encountered.
var StackErrReservedOpcode = errors.New("Reserved Opcode") StackErrReservedOpcode = errors.New("Reserved Opcode")
// StackErrEarlyReturn is returned when OP_RETURN is executed in the script. // StackErrEarlyReturn is returned when OP_RETURN is executed in the
var StackErrEarlyReturn = errors.New("Script returned early") // script.
StackErrEarlyReturn = errors.New("Script returned early")
// StackErrNoIf is returned if an OP_ELSE or OP_ENDIF is encountered without // StackErrNoIf is returned if an OP_ELSE or OP_ENDIF is encountered
// first having an OP_IF or OP_NOTIF in the script. // without first having an OP_IF or OP_NOTIF in the script.
var StackErrNoIf = errors.New("OP_ELSE or OP_ENDIF with no matching OP_IF") StackErrNoIf = errors.New("OP_ELSE or OP_ENDIF with no matching OP_IF")
// StackErrMissingEndif is returned if the end of a script is reached without // StackErrMissingEndif is returned if the end of a script is reached
// and OP_ENDIF to correspond to a conditional expression. // without and OP_ENDIF to correspond to a conditional expression.
var StackErrMissingEndif = fmt.Errorf("execute fail, in conditional execution") StackErrMissingEndif = fmt.Errorf("execute fail, in conditional execution")
// StackErrTooManyPubkeys is returned if an OP_CHECKMULTISIG is encountered // StackErrTooManyPubkeys is returned if an OP_CHECKMULTISIG is
// with more than MaxPubKeysPerMultiSig pubkeys present. // encountered with more than MaxPubKeysPerMultiSig pubkeys present.
var StackErrTooManyPubkeys = errors.New("Invalid pubkey count in OP_CHECKMULTISIG") StackErrTooManyPubkeys = errors.New("Invalid pubkey count in OP_CHECKMULTISIG")
// StackErrTooManyOperations is returned if a script has more then // StackErrTooManyOperations is returned if a script has more than
// MaxOpsPerScript opcodes that do not push data. // MaxOpsPerScript opcodes that do not push data.
var StackErrTooManyOperations = errors.New("Too many operations in script") StackErrTooManyOperations = errors.New("Too many operations in script")
// StackErrElementTooBig is returned if the size of an element to be pushed to // StackErrElementTooBig is returned if the size of an element to be
// the stack is over MaxScriptElementSize. // pushed to the stack is over MaxScriptElementSize.
var StackErrElementTooBig = errors.New("Element in script too large") StackErrElementTooBig = errors.New("Element in script too large")
// StackErrUnknownAddress is returned when ScriptToAddrHash does not recognise // StackErrUnknownAddress is returned when ScriptToAddrHash does not
// the pattern of the script and thus can not find the address for payment. // recognise the pattern of the script and thus can not find the address
var StackErrUnknownAddress = errors.New("non-recognised address") // for payment.
StackErrUnknownAddress = errors.New("non-recognised address")
// StackErrScriptFailed is returned when at the end of a script the boolean // StackErrScriptFailed is returned when at the end of a script the
// on top of the stack is false signifying that the script has failed. // boolean on top of the stack is false signifying that the script has
var StackErrScriptFailed = errors.New("execute fail, fail on stack") // failed.
StackErrScriptFailed = errors.New("execute fail, fail on stack")
// StackErrScriptUnfinished is returned when CheckErrorCondition is called // StackErrScriptUnfinished is returned when CheckErrorCondition is
// on a script that has not finished executing. // called on a script that has not finished executing.
var StackErrScriptUnfinished = errors.New("Error check when script unfinished") StackErrScriptUnfinished = errors.New("Error check when script unfinished")
// StackErrEmpyStack is returned when the stack is empty at the end of // StackErrEmpyStack is returned when the stack is empty at the end of
// execution. Normal operation requires that a boolean is on top of the stack // execution. Normal operation requires that a boolean is on top of the
// when the scripts have finished executing. // stack when the scripts have finished executing.
var StackErrEmptyStack = errors.New("Stack empty at end of execution") StackErrEmptyStack = errors.New("Stack empty at end of execution")
// StackErrP2SHNonPushOnly is returned when a Pay-to-Script-Hash transaction // StackErrP2SHNonPushOnly is returned when a Pay-to-Script-Hash
// is encountered and the ScriptSig does operations other than push data (in // transaction is encountered and the ScriptSig does operations other
// violation of bip16). // than push data (in violation of bip16).
var StackErrP2SHNonPushOnly = errors.New("pay to script hash with non " + StackErrP2SHNonPushOnly = errors.New("pay to script hash with non " +
"pushonly input") "pushonly input")
// StackErrInvalidParseType is an internal error returned from ScriptToAddrHash // StackErrInvalidParseType is an internal error returned from
// ony if the internal data tables are wrong. // ScriptToAddrHash ony if the internal data tables are wrong.
var StackErrInvalidParseType = errors.New("internal error: invalid parsetype found") StackErrInvalidParseType = errors.New("internal error: invalid parsetype found")
// StackErrInvalidAddrOffset is an internal error returned from ScriptToAddrHash // StackErrInvalidAddrOffset is an internal error returned from
// ony if the internal data tables are wrong. // ScriptToAddrHash ony if the internal data tables are wrong.
var StackErrInvalidAddrOffset = errors.New("internal error: invalid offset found") StackErrInvalidAddrOffset = errors.New("internal error: invalid offset found")
// StackErrInvalidIndex is returned when an out-of-bounds index was passed to // StackErrInvalidIndex is returned when an out-of-bounds index was
// a function. // passed to a function.
var StackErrInvalidIndex = errors.New("Invalid script index") StackErrInvalidIndex = errors.New("Invalid script index")
// StackErrNonPushOnly is returned when ScriptInfo is called with a pkScript // StackErrNonPushOnly is returned when ScriptInfo is called with a
// that peforms operations other that pushing data to the stack. // pkScript that peforms operations other that pushing data to the stack.
var StackErrNonPushOnly = errors.New("SigScript is non pushonly") StackErrNonPushOnly = errors.New("SigScript is non pushonly")
)
// ErrUnsupportedAddress is returned when a concrete type that implements // ErrUnsupportedAddress is returned when a concrete type that implements
// a btcutil.Address is not a supported type. // a btcutil.Address is not a supported type.