From f7b3e1ad77f7824cb225aefe68edf280c3dcfe87 Mon Sep 17 00:00:00 2001 From: Philipp Hoenisch Date: Wed, 6 Sep 2023 17:11:14 +0200 Subject: [PATCH] chore: make fetching tx fee more resilliant it looks like we sometimes have a timing issue when fetching a tx because the publishment was not yet finalized, with this we simply retry after one second --- mobile/native/src/channel_fee.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mobile/native/src/channel_fee.rs b/mobile/native/src/channel_fee.rs index 13dbe26f2..d4434b41d 100644 --- a/mobile/native/src/channel_fee.rs +++ b/mobile/native/src/channel_fee.rs @@ -129,9 +129,21 @@ impl ChannelFeePaymentSubscriber { let txid = ln_dlc::get_funding_transaction(channel_id)?; - let transaction: EsploraTransaction = tokio::task::block_in_place(|| { - Handle::current().block_on(fetch_funding_transaction(txid)) - })?; + let transaction: EsploraTransaction = tokio::task::block_in_place( + || match Handle::current().block_on(fetch_funding_transaction(txid)) { + Ok(tx) => Ok(tx), + Err(err) => { + tracing::warn!( + tx_id = txid.to_string(), + "Could not fetch opening transaction due to {err:#}, retrying after a short sleep." + ); + Handle::current().block_on(async { + tokio::time::sleep(Duration::from_secs(1)).await; + fetch_funding_transaction(txid).await + }) + } + }, + )?; tracing::debug!("Successfully fetched transaction fees of {} for new inbound channel with id {channel_id_as_str}", transaction.fee); self.set_open_channel_info(channel_id, transaction); Ok(())