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 #[error("RBF not enabled: transaction has no replaceable inputs")]
60 RbfNotEnabled,
61
62 #[error("RBF fee too low: current {current} sat, required at least {required} sat")]
64 RbfFeeTooLow {
65 current: u64,
67 required: u64,
69 },
70
71 #[error("Invalid output index: {0}")]
73 InvalidOutputIndex(usize),
74
75 #[error("Taproot error: {0}")]
77 TaprootError(String),
78}
79
80pub type Result<T> = std::result::Result<T, TxError>;