rustywallet_coinjoin/
error.rs

1//! Error types for CoinJoin operations.
2
3use thiserror::Error;
4
5/// Result type for CoinJoin operations.
6pub type Result<T> = std::result::Result<T, CoinJoinError>;
7
8/// Errors that can occur during CoinJoin operations.
9#[derive(Debug, Error)]
10pub enum CoinJoinError {
11    /// Invalid PSBT.
12    #[error("Invalid PSBT: {0}")]
13    InvalidPsbt(String),
14
15    /// Invalid transaction.
16    #[error("Invalid transaction: {0}")]
17    InvalidTransaction(String),
18
19    /// Insufficient funds.
20    #[error("Insufficient funds: need {needed}, have {available}")]
21    InsufficientFunds { needed: u64, available: u64 },
22
23    /// Invalid amount.
24    #[error("Invalid amount: {0}")]
25    InvalidAmount(String),
26
27    /// No participants.
28    #[error("No participants in CoinJoin")]
29    NoParticipants,
30
31    /// Invalid participant.
32    #[error("Invalid participant: {0}")]
33    InvalidParticipant(String),
34
35    /// Fee calculation error.
36    #[error("Fee calculation error: {0}")]
37    FeeError(String),
38
39    /// PayJoin protocol error.
40    #[error("PayJoin error: {0}")]
41    PayJoinError(String),
42
43    /// Invalid output.
44    #[error("Invalid output: {0}")]
45    InvalidOutput(String),
46
47    /// Unequal outputs.
48    #[error("Outputs must be equal: expected {expected}, got {actual}")]
49    UnequalOutputs { expected: u64, actual: u64 },
50
51    /// Serialization error.
52    #[error("Serialization error: {0}")]
53    SerializationError(String),
54
55    /// Cryptographic error.
56    #[error("Crypto error: {0}")]
57    CryptoError(String),
58
59    /// Invalid address.
60    #[error("Invalid address: {0}")]
61    InvalidAddress(String),
62
63    /// Verification failed.
64    #[error("Verification failed: {0}")]
65    VerificationFailed(String),
66}