From 45c7b850a64318152e245b269ffef25d63033384 Mon Sep 17 00:00:00 2001 From: edouardparis Date: Thu, 25 Apr 2024 14:41:41 +0200 Subject: [PATCH] Remove legacy harware_wallets field from gui config Ledger hmacs, wallet name and fingerprint labels where moved one year ago in the settings.json file. Here the commit of the new settings module: https://github.com/wizardsardine/liana/commit/bf1e9e4b808a7c275766975467e637b883524236 A second commit in v4 checked that settings.json is present otherwise it does the migration from the gui configuration file to the settings file: https://github.com/wizardsardine/liana/commit/3eeba082483c06318ca7a1f018ce2c5da47f5f32 We remove the legacy field from the config field so the wallet module does not depend on the config module anymore to load hardware wallet information. --- gui/src/app/config.rs | 5 ----- gui/src/app/mod.rs | 7 ++----- gui/src/app/wallet.rs | 20 ++++---------------- gui/src/loader.rs | 5 +---- 4 files changed, 7 insertions(+), 30 deletions(-) diff --git a/gui/src/app/config.rs b/gui/src/app/config.rs index 041a05d5..f39ea1ee 100644 --- a/gui/src/app/config.rs +++ b/gui/src/app/config.rs @@ -1,4 +1,3 @@ -use crate::hw::HardwareWalletConfig; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; use tracing_subscriber::filter; @@ -13,9 +12,6 @@ pub struct Config { pub log_level: Option, /// Use iced debug feature if true. pub debug: Option, - /// hardware wallets config. - /// LEGACY: Use Settings module instead. - pub hardware_wallets: Option>, /// Start internal bitcoind executable. #[serde(default)] pub start_internal_bitcoind: bool, @@ -30,7 +26,6 @@ impl Config { daemon_rpc_path: None, log_level: None, debug: None, - hardware_wallets: None, start_internal_bitcoind, } } diff --git a/gui/src/app/mod.rs b/gui/src/app/mod.rs index 6049530a..6205db8e 100644 --- a/gui/src/app/mod.rs +++ b/gui/src/app/mod.rs @@ -309,11 +309,8 @@ impl App { } pub fn load_wallet(&mut self) -> Result, Error> { - let wallet = Wallet::new(self.wallet.main_descriptor.clone()).load_settings( - &self.config, - &self.data_dir, - self.cache.network, - )?; + let wallet = Wallet::new(self.wallet.main_descriptor.clone()) + .load_settings(&self.data_dir, self.cache.network)?; self.wallet = Arc::new(wallet); diff --git a/gui/src/app/wallet.rs b/gui/src/app/wallet.rs index e9cd483d..d6b4405d 100644 --- a/gui/src/app/wallet.rs +++ b/gui/src/app/wallet.rs @@ -1,11 +1,7 @@ use std::collections::{HashMap, HashSet}; use std::path::Path; -use crate::{ - app::{config::Config, settings}, - hw::HardwareWalletConfig, - signer::Signer, -}; +use crate::{app::settings, hw::HardwareWalletConfig, signer::Signer}; use liana::{miniscript::bitcoin, signer::HotSigner}; @@ -93,16 +89,9 @@ impl Wallet { pub fn load_settings( self, - gui_config: &Config, datadir_path: &Path, network: bitcoin::Network, ) -> Result { - let gui_config_hws = gui_config - .hardware_wallets - .as_ref() - .cloned() - .unwrap_or_default(); - let mut wallet = match settings::Settings::from_file(datadir_path.to_path_buf(), network) { Ok(settings) => { if let Some(wallet_setting) = settings.wallets.first() { @@ -110,18 +99,17 @@ impl Wallet { .with_hardware_wallets(wallet_setting.hardware_wallets.clone()) .with_key_aliases(wallet_setting.keys_aliases()) } else { - self.with_hardware_wallets(gui_config_hws) + self } } Err(settings::SettingsError::NotFound) => { - let wallet = self.with_hardware_wallets(gui_config_hws); let s = settings::Settings { - wallets: vec![settings::WalletSetting::from(&wallet)], + wallets: vec![settings::WalletSetting::from(&self)], }; tracing::info!("Settings file not found, creating one"); s.to_file(datadir_path.to_path_buf(), network)?; - wallet + self } Err(e) => return Err(e.into()), }; diff --git a/gui/src/loader.rs b/gui/src/loader.rs index 8efcd107..14df533c 100644 --- a/gui/src/loader.rs +++ b/gui/src/loader.rs @@ -203,7 +203,6 @@ impl Loader { load_application( daemon.clone(), info, - self.gui_config.clone(), self.datadir_path.clone(), self.network, self.internal_bitcoind.clone(), @@ -356,7 +355,6 @@ impl Loader { pub async fn load_application( daemon: Arc, info: GetInfoResult, - gui_config: GUIConfig, datadir_path: PathBuf, network: bitcoin::Network, internal_bitcoind: Option, @@ -369,8 +367,7 @@ pub async fn load_application( ), Error, > { - let wallet = - Wallet::new(info.descriptors.main).load_settings(&gui_config, &datadir_path, network)?; + let wallet = Wallet::new(info.descriptors.main).load_settings(&datadir_path, network)?; let coins = daemon .list_coins(&[CoinStatus::Unconfirmed, CoinStatus::Confirmed], &[])