use thiserror::Error;
#[derive(Debug, Error)]
pub enum TxError {
#[error("Insufficient funds: need {needed} sat, have {available} sat")]
InsufficientFunds {
needed: u64,
available: u64,
},
#[error("Invalid address: {0}")]
InvalidAddress(String),
#[error("Invalid UTXO: {0}")]
InvalidUtxo(String),
#[error("Signing failed: {0}")]
SigningFailed(String),
#[error("Serialization failed: {0}")]
SerializationFailed(String),
#[error("Dust output: {0} sat is below dust threshold")]
DustOutput(u64),
#[error("No inputs provided")]
NoInputs,
#[error("No outputs provided")]
NoOutputs,
#[error("Invalid transaction: {0}")]
InvalidTransaction(String),
#[error("Input index {index} out of bounds (have {count} inputs)")]
InputIndexOutOfBounds {
index: usize,
count: usize,
},
#[error("RBF not enabled: transaction has no replaceable inputs")]
RbfNotEnabled,
#[error("RBF fee too low: current {current} sat, required at least {required} sat")]
RbfFeeTooLow {
current: u64,
required: u64,
},
#[error("Invalid output index: {0}")]
InvalidOutputIndex(usize),
#[error("Taproot error: {0}")]
TaprootError(String),
}
pub type Result<T> = std::result::Result<T, TxError>;