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:
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.
This commit is contained in:
edouardparis 2024-04-25 14:41:41 +02:00
parent 6b225777b2
commit 45c7b850a6
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

@ -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<dyn Daemon + Sync + Send>,
info: GetInfoResult,
gui_config: GUIConfig,
datadir_path: PathBuf,
network: bitcoin::Network,
internal_bitcoind: Option<Bitcoind>,
@ -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], &[])