kaspa_txscript_errors/
lib.rs1use thiserror::Error;
2
3#[derive(Error, PartialEq, Eq, Debug, Clone)]
4pub enum TxScriptError {
5 #[error("invalid opcode length: {0:02x?}")]
6 MalformedPushSize(Vec<u8>),
7 #[error("opcode requires {0} bytes, but script only has {1} remaining")]
8 MalformedPush(usize, usize),
9 #[error("transaction input index {0} >= {1}")]
10 InvalidIndex(usize, usize),
11 #[error("combined stack size {0} > max allowed {1}")]
12 StackSizeExceeded(usize, usize),
13 #[error("attempt to execute invalid opcode {0}")]
14 InvalidOpcode(String),
15 #[error("attempt to execute reserved opcode {0}")]
16 OpcodeReserved(String),
17 #[error("attempt to execute disabled opcode {0}")]
18 OpcodeDisabled(String),
19 #[error("attempt to read from empty stack")]
20 EmptyStack,
21 #[error("stack contains {0} unexpected items")]
22 CleanStack(usize),
23 #[error("false stack entry at end of script execution")]
25 EvalFalse,
26 #[error("script returned early")]
27 EarlyReturn,
28 #[error("script ran, but verification failed")]
29 VerifyError,
30 #[error("encountered invalid state while running script: {0}")]
31 InvalidState(String),
32 #[error("signature invalid: {0}")]
33 InvalidSignature(secp256k1::Error),
34 #[error("invalid signature in sig cache")]
35 SigcacheSignatureInvalid,
36 #[error("exceeded max operation limit of {0}")]
37 TooManyOperations(i32),
38 #[error("Engine is not running on a transaction input")]
39 NotATransactionInput,
40 #[error("element size {0} exceeds max allowed size {1}")]
41 ElementTooBig(usize, usize),
42 #[error("push encoding is not minimal: {0}")]
43 NotMinimalData(String),
44 #[error("opcode not supported on current source: {0}")]
45 InvalidSource(String),
46 #[error("Unsatisfied lock time: {0}")]
47 UnsatisfiedLockTime(String),
48 #[error("Number too big: {0}")]
49 NumberTooBig(String),
50 #[error("not all signatures empty on failed checkmultisig")]
51 NullFail,
52 #[error("invalid signature count: {0}")]
53 InvalidSignatureCount(String),
54 #[error("invalid pubkey count: {0}")]
55 InvalidPubKeyCount(String),
56 #[error("invalid hash type {0:#04x}")]
57 InvalidSigHashType(u8),
58 #[error("unsupported public key type")]
59 PubKeyFormat,
60 #[error("invalid signature length {0}")]
61 SigLength(usize),
62 #[error("no scripts to run")]
63 NoScripts,
64 #[error("signature script is not push only")]
65 SignatureScriptNotPushOnly,
66 #[error("end of script reached in conditional execution")]
67 ErrUnbalancedConditional,
68 #[error("opcode requires at least {0} but stack has only {1}")]
69 InvalidStackOperation(usize, usize),
70 #[error("script of size {0} exceeded maximum allowed size of {1}")]
71 ScriptSize(usize, usize),
72}