use thiserror::Error;
#[derive(Debug, Error)]
pub enum WalletError {
#[error("protocol error (code {code}): {message}")]
Protocol { code: u8, message: String },
#[error("invalid parameter: {0}")]
InvalidParameter(String),
#[error("not implemented: {0}")]
NotImplemented(String),
#[error("internal error: {0}")]
Internal(String),
#[error("insufficient funds: {0}")]
InsufficientFunds(String),
#[error("review actions: {0}")]
ReviewActions(String),
#[error("HMAC is not valid")]
InvalidHmac,
#[error("signature is not valid")]
InvalidSignature,
}
impl From<crate::primitives::PrimitivesError> for WalletError {
fn from(e: crate::primitives::PrimitivesError) -> Self {
WalletError::Internal(e.to_string())
}
}
impl From<crate::script::ScriptError> for WalletError {
fn from(e: crate::script::ScriptError) -> Self {
WalletError::Internal(e.to_string())
}
}
impl From<crate::transaction::TransactionError> for WalletError {
fn from(e: crate::transaction::TransactionError) -> Self {
WalletError::Internal(e.to_string())
}
}
impl From<std::io::Error> for WalletError {
fn from(e: std::io::Error) -> Self {
WalletError::Internal(e.to_string())
}
}