Merge #1084: Remove legacy harware_wallets field from gui config

45c7b850a64318152e245b269ffef25d63033384 Remove legacy harware_wallets field from gui config (edouardparis)

Pull request description:

  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:
  bf1e9e4b80

  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:
  3eeba08248

  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.

  Tested on gui.toml config with legacy field hardware_wallets and it does not fail to launch.

ACKs for top commit:
  jp1ac4:
    ACK 45c7b850a6.

Tree-SHA512: a13c042c3842c732117ee8099d5a90d28462c5916408edb9fcee5518427acca5b737cd6e1ebe77a94e7d8dabf7a6bdd124ddf927ed850c58b5f980c6efe4f391
This commit is contained in:
edouardparis 2024-05-03 18:05:24 +02:00
commit b7a72e064d
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
4 changed files with 7 additions and 30 deletions

View File

@ -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<String>,
/// Use iced debug feature if true.
pub debug: Option<bool>,
/// hardware wallets config.
/// LEGACY: Use Settings module instead.
pub hardware_wallets: Option<Vec<HardwareWalletConfig>>,
/// 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,
}
}

View File

@ -309,11 +309,8 @@ impl App {
}
pub fn load_wallet(&mut self) -> Result<Arc<Wallet>, 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);

View File

@ -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<Self, WalletError> {
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()),
};

View File

@ -202,7 +202,6 @@ impl Loader {
load_application(
daemon.clone(),
info,
self.gui_config.clone(),
self.datadir_path.clone(),
self.network,
self.internal_bitcoind.clone(),
@ -355,7 +354,6 @@ impl Loader {
pub async fn load_application(
daemon: Arc<dyn Daemon + Sync + Send>,
info: GetInfoResult,
gui_config: GUIConfig,
datadir_path: PathBuf,
network: bitcoin::Network,
internal_bitcoind: Option<Bitcoind>,
@ -368,8 +366,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], &[])