use bitcoin::{Amount, FeeRate, Txid};
#[derive(Debug, thiserror::Error)]
pub enum CpfpError {
#[error("Unable to create CPFP transaction: {0}")]
CreateError(String),
#[error("Unable to finalize CPFP transaction: {0}")]
FinalizeError(String),
#[error("You need more confirmations on your on-chain funds, {available} is available but {needed} is needed.")]
InsufficientConfirmedFunds { needed: Amount, available: Amount },
#[error("An internal error occurred while creating CPFP: {0}")]
InternalError(String),
#[error("Transaction has no fee anchor: {0}")]
NoFeeAnchor(Txid),
#[error("Unable to sign CPFP transaction: {0}")]
SigningError(String),
#[error("Unable to store CPFP transaction: {0}")]
StoreError(String),
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum MakeCpfpFees {
Effective(FeeRate),
Rbf {
min_effective_fee_rate: FeeRate,
current_package_fee: Amount,
},
}
impl MakeCpfpFees {
pub fn effective(&self) -> FeeRate {
match self {
MakeCpfpFees::Effective(fr) => *fr,
MakeCpfpFees::Rbf { min_effective_fee_rate, .. } => *min_effective_fee_rate,
}
}
}