1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum WalletError {
8 #[error("protocol error (code {code}): {message}")]
10 Protocol { code: u8, message: String },
11
12 #[error("invalid parameter: {0}")]
14 InvalidParameter(String),
15
16 #[error("not implemented: {0}")]
18 NotImplemented(String),
19
20 #[error("internal error: {0}")]
22 Internal(String),
23
24 #[error("insufficient funds: {0}")]
27 InsufficientFunds(String),
28
29 #[error("review actions: {0}")]
32 ReviewActions(String),
33
34 #[error("HMAC is not valid")]
37 InvalidHmac,
38
39 #[error("signature is not valid")]
42 InvalidSignature,
43}
44
45impl From<crate::primitives::PrimitivesError> for WalletError {
46 fn from(e: crate::primitives::PrimitivesError) -> Self {
47 WalletError::Internal(e.to_string())
48 }
49}
50
51impl From<crate::script::ScriptError> for WalletError {
52 fn from(e: crate::script::ScriptError) -> Self {
53 WalletError::Internal(e.to_string())
54 }
55}
56
57impl From<crate::transaction::TransactionError> for WalletError {
58 fn from(e: crate::transaction::TransactionError) -> Self {
59 WalletError::Internal(e.to_string())
60 }
61}
62
63impl From<std::io::Error> for WalletError {
64 fn from(e: std::io::Error) -> Self {
65 WalletError::Internal(e.to_string())
66 }
67}