use std::collections::HashMap;
use crate::core::asset::WalletAsset;
#[derive(Debug, Clone)]
pub struct RecoveredOutput<A: WalletAsset> {
pub secret_hex: String,
pub hash: String,
pub amount_wats: Option<i64>,
pub chain: crate::hd::ChainCode,
pub depth: u64,
pub namespace: A::Namespace,
}
#[derive(Debug, Clone)]
pub struct RecoveryReport<A: WalletAsset> {
pub recovered: Vec<RecoveredOutput<A>>,
pub last_used_depth: HashMap<crate::hd::ChainCode, u64>,
}
impl<A: WalletAsset> RecoveryReport<A> {
pub fn empty() -> Self {
Self {
recovered: Vec::new(),
last_used_depth: HashMap::new(),
}
}
pub fn count(&self) -> usize {
self.recovered.len()
}
pub fn total_wats(&self) -> i64 {
self.recovered.iter().filter_map(|o| o.amount_wats).sum()
}
}
#[derive(Debug, thiserror::Error)]
pub enum RecoveryError {
#[error("recovery aborted on {chain} at depth {depth}: {source}")]
Server {
chain: &'static str,
depth: u64,
source: crate::server_client::ClientError,
},
#[error("malformed health_check response: {0}")]
Decode(String),
#[error("gap_limit must be > 0")]
InvalidGapLimit,
}