diff --git a/gui/src/app/mod.rs b/gui/src/app/mod.rs index cc57fb893..847881b38 100644 --- a/gui/src/app/mod.rs +++ b/gui/src/app/mod.rs @@ -19,6 +19,7 @@ use iced::{clipboard, time, Command, Subscription}; use tokio::runtime::Handle; use tracing::{error, info, warn}; +use liana::config::BitcoinBackend; pub use liana::{commands::CoinStatus, config::Config as DaemonConfig, miniscript::bitcoin}; use liana_ui::{ component::network_banner, @@ -36,7 +37,7 @@ use state::{ use crate::{ app::{cache::Cache, error::Error, menu::Menu, wallet::Wallet}, daemon::{embedded::EmbeddedDaemon, Daemon, DaemonBackend}, - node::bitcoind::Bitcoind, + node::{bitcoind::Bitcoind, NodeType}, }; use self::state::SettingsState; @@ -60,10 +61,11 @@ impl Panels { data_dir: PathBuf, daemon_backend: DaemonBackend, internal_bitcoind: Option<&Bitcoind>, + node_type: Option, ) -> Panels { Self { current: Menu::Home, - home: Home::new(wallet.clone(), &cache.coins, cache.blockheight), + home: Home::new(wallet.clone(), &cache.coins, cache.blockheight, node_type), coins: CoinsPanel::new(&cache.coins, wallet.main_descriptor.first_timelock_value()), transactions: TransactionsPanel::new(wallet.clone()), psbts: PsbtsPanel::new(wallet.clone()), @@ -136,12 +138,21 @@ impl App { data_dir: PathBuf, internal_bitcoind: Option, ) -> (App, Command) { + let node_type = match daemon + .config() + .and_then(|config| config.bitcoin_backend.as_ref()) + { + Some(BitcoinBackend::Bitcoind(_)) => Some(NodeType::Bitcoind), + Some(BitcoinBackend::Electrum(_)) => Some(NodeType::Electrum), + None => None, + }; let mut panels = Panels::new( &cache, wallet.clone(), data_dir, daemon.backend(), internal_bitcoind.as_ref(), + node_type, ); let cmd = panels.home.reload(daemon.clone(), wallet.clone()); ( diff --git a/gui/src/app/state/mod.rs b/gui/src/app/state/mod.rs index 6a4c8f13e..4950be73c 100644 --- a/gui/src/app/state/mod.rs +++ b/gui/src/app/state/mod.rs @@ -23,9 +23,12 @@ use super::{cache::Cache, error::Error, menu::Menu, message::Message, view, wall pub const HISTORY_EVENT_PAGE_SIZE: u64 = 20; -use crate::daemon::{ - model::{remaining_sequence, Coin, HistoryTransaction, Labelled}, - Daemon, +use crate::{ + daemon::{ + model::{remaining_sequence, Coin, HistoryTransaction, Labelled}, + Daemon, + }, + node::NodeType, }; pub use coins::CoinsPanel; use label::LabelsEdited; @@ -69,6 +72,7 @@ pub fn redirect(menu: Menu) -> Command { pub struct Home { wallet: Arc, blockheight: i32, + node_type: Option, balance: Amount, unconfirmed_balance: Amount, remaining_sequence: Option, @@ -83,7 +87,12 @@ pub struct Home { } impl Home { - pub fn new(wallet: Arc, coins: &[Coin], blockheight: i32) -> Self { + pub fn new( + wallet: Arc, + coins: &[Coin], + blockheight: i32, + node_type: Option, + ) -> Self { let (balance, unconfirmed_balance) = coins.iter().fold( (Amount::from_sat(0), Amount::from_sat(0)), |(balance, unconfirmed_balance), coin| { @@ -100,6 +109,7 @@ impl Home { Self { wallet, blockheight, + node_type, balance, unconfirmed_balance, remaining_sequence: None, @@ -115,7 +125,16 @@ impl Home { } fn wallet_is_syncing(&self) -> bool { - self.blockheight <= 0 + if self.node_type == Some(NodeType::Bitcoind) { + // If user imported descriptor and is using a local bitcoind, + // a rescan will need to be performed in order to see + // past transactions and so the syncing status could be + // misleading as it could suggest the rescan is being + // performed. + false + } else { + self.blockheight <= 0 + } } }