snarkvm_errors/objects/
transaction.rs1use std::fmt::Debug;
18
19#[derive(Debug, Error)]
20pub enum TransactionError {
21 #[error("UTXO has already been spent {:?} index: {:?}", _0, _1)]
22 AlreadySpent(Vec<u8>, u32),
23
24 #[error("there is a double spend occuring with this transaction {}", _0)]
25 DoubleSpend(String),
26
27 #[error("{}: {}", _0, _1)]
28 Crate(&'static str, String),
29
30 #[error("insufficient funds from input: {} to spend as output: {}", _0, _1)]
31 InsufficientFunds(u64, u64),
32
33 #[error("invalid coinbase transaction")]
34 InvalidCoinbaseTransaction,
35
36 #[error("invalid transaction id {:?}", _0)]
37 InvalidTransactionId(usize),
38
39 #[error("invalid variable size integer: {:?}", _0)]
40 InvalidVariableSizeInteger(usize),
41
42 #[error("{}", _0)]
43 Message(String),
44
45 #[error("missing outpoint script public key")]
46 MissingOutpointScriptPublicKey,
47
48 #[error("the block has multiple coinbase transactions: {:?}", _0)]
49 MultipleCoinbaseTransactions(u32),
50
51 #[error("Null Error {:?}", _0)]
52 NullError(()),
53}
54
55impl From<hex::FromHexError> for TransactionError {
56 fn from(error: hex::FromHexError) -> Self {
57 TransactionError::Crate("hex", format!("{:?}", error))
58 }
59}
60
61impl From<std::io::Error> for TransactionError {
62 fn from(error: std::io::Error) -> Self {
63 TransactionError::Crate("std::io", format!("{:?}", error))
64 }
65}
66
67impl From<std::num::ParseIntError> for TransactionError {
68 fn from(error: std::num::ParseIntError) -> Self {
69 TransactionError::Crate("std::num", format!("{:?}", error))
70 }
71}
72
73impl From<std::str::ParseBoolError> for TransactionError {
74 fn from(error: std::str::ParseBoolError) -> Self {
75 TransactionError::Crate("std::str", format!("{:?}", error))
76 }
77}
78
79impl From<()> for TransactionError {
80 fn from(_error: ()) -> Self {
81 TransactionError::NullError(())
82 }
83}
84
85impl From<&'static str> for TransactionError {
86 fn from(msg: &'static str) -> Self {
87 TransactionError::Message(msg.into())
88 }
89}