1use bitcoin::{Amount, FeeRate, Txid};
2
3#[derive(Debug, thiserror::Error)]
5pub enum CpfpError {
6 #[error("Unable to create CPFP transaction: {0}")]
7 CreateError(String),
8 #[error("Unable to finalize CPFP transaction: {0}")]
9 FinalizeError(String),
10 #[error("You need more confirmations on your on-chain funds, {available} is available but {needed} is needed.")]
11 InsufficientConfirmedFunds { needed: Amount, available: Amount },
12 #[error("An internal error occurred while creating CPFP: {0}")]
13 InternalError(String),
14 #[error("Transaction has no fee anchor: {0}")]
15 NoFeeAnchor(Txid),
16 #[error("Unable to sign CPFP transaction: {0}")]
17 SigningError(String),
18 #[error("Unable to store CPFP transaction: {0}")]
19 StoreError(String),
20}
21
22#[derive(Copy, Clone, Debug, PartialEq, Eq)]
24pub enum MakeCpfpFees {
25 Effective(FeeRate),
29 Rbf {
35 min_effective_fee_rate: FeeRate,
39 current_package_fee: Amount,
42 },
43}
44
45impl MakeCpfpFees {
46 pub fn effective(&self) -> FeeRate {
47 match self {
48 MakeCpfpFees::Effective(fr) => *fr,
49 MakeCpfpFees::Rbf { min_effective_fee_rate, .. } => *min_effective_fee_rate,
50 }
51 }
52}