1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum TxError {
8 #[error("Insufficient funds: need {needed} sat, have {available} sat")]
10 InsufficientFunds {
11 needed: u64,
13 available: u64,
15 },
16
17 #[error("Invalid address: {0}")]
19 InvalidAddress(String),
20
21 #[error("Invalid UTXO: {0}")]
23 InvalidUtxo(String),
24
25 #[error("Signing failed: {0}")]
27 SigningFailed(String),
28
29 #[error("Serialization failed: {0}")]
31 SerializationFailed(String),
32
33 #[error("Dust output: {0} sat is below dust threshold")]
35 DustOutput(u64),
36
37 #[error("No inputs provided")]
39 NoInputs,
40
41 #[error("No outputs provided")]
43 NoOutputs,
44
45 #[error("Invalid transaction: {0}")]
47 InvalidTransaction(String),
48
49 #[error("Input index {index} out of bounds (have {count} inputs)")]
51 InputIndexOutOfBounds {
52 index: usize,
54 count: usize,
56 },
57}
58
59pub type Result<T> = std::result::Result<T, TxError>;