mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-01-17 13:04:20 +01:00
fix: ensure wallet and chain service tips are within leeway
This commit is contained in:
@@ -23,6 +23,8 @@ use crate::{
|
||||
utils,
|
||||
};
|
||||
|
||||
const LIQUID_TIP_LEEWAY: u32 = 3;
|
||||
|
||||
pub(crate) struct Recoverer {
|
||||
master_blinding_key: MasterBlindingKey,
|
||||
swapper: Arc<dyn Swapper>,
|
||||
@@ -171,6 +173,14 @@ impl Recoverer {
|
||||
&self,
|
||||
swaps: &mut [Swap],
|
||||
) -> Result<HashMap<Txid, WalletTx>> {
|
||||
let wallet_tip = self.onchain_wallet.tip().await.height();
|
||||
let liquid_tip = self.liquid_chain_service.tip().await?;
|
||||
if wallet_tip.abs_diff(liquid_tip) > LIQUID_TIP_LEEWAY {
|
||||
let msg = format!("Skipping recovery: wallet and liquid chain service tips are too far apart - chain_service_tip {liquid_tip} wallet_tip {wallet_tip}");
|
||||
log::debug!("{msg}");
|
||||
anyhow::bail!(msg)
|
||||
}
|
||||
|
||||
let recovery_started_at = utils::now();
|
||||
|
||||
let raw_tx_map = self.onchain_wallet.transactions_by_tx_id().await?;
|
||||
|
||||
Reference in New Issue
Block a user