use bitcoin::{Amount, FeeRate, Weight};
use crate::exit::models::{ExitTx, ExitTxStatus};
use crate::WalletVtxo;
pub(crate) fn count_broadcast(status: &[ExitTx]) -> usize {
status.iter().filter(|s| match s.status {
ExitTxStatus::AwaitingConfirmation { .. } => true,
ExitTxStatus::Confirmed { .. } => true,
_ => false,
}).count()
}
pub(crate) fn count_confirmed(status: &[ExitTx]) -> usize {
status.iter().filter(|s| match s.status {
ExitTxStatus::Confirmed { .. } => true,
_ => false,
}).count()
}
pub(crate) fn estimate_exit_cost<'a, I>(vtxos: I, fee_rate: FeeRate) -> Amount
where
I: IntoIterator<Item = &'a WalletVtxo>
{
let total_weight = vtxos.into_iter().map(|vtxo| vtxo.exit_tx_weight).sum::<Weight>();
fee_rate * total_weight * 2
}