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:bf1e9e4b80A second commit in v4 checked that settings.json is present otherwise it does the migration from the gui configuration file to the settings file:3eeba08248We 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: ACK45c7b850a6. Tree-SHA512: a13c042c3842c732117ee8099d5a90d28462c5916408edb9fcee5518427acca5b737cd6e1ebe77a94e7d8dabf7a6bdd124ddf927ed850c58b5f980c6efe4f391
This commit is contained in:
commit
b7a72e064d
@ -1,4 +1,3 @@
|
|||||||
use crate::hw::HardwareWalletConfig;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use tracing_subscriber::filter;
|
use tracing_subscriber::filter;
|
||||||
@ -13,9 +12,6 @@ pub struct Config {
|
|||||||
pub log_level: Option<String>,
|
pub log_level: Option<String>,
|
||||||
/// Use iced debug feature if true.
|
/// Use iced debug feature if true.
|
||||||
pub debug: Option<bool>,
|
pub debug: Option<bool>,
|
||||||
/// hardware wallets config.
|
|
||||||
/// LEGACY: Use Settings module instead.
|
|
||||||
pub hardware_wallets: Option<Vec<HardwareWalletConfig>>,
|
|
||||||
/// Start internal bitcoind executable.
|
/// Start internal bitcoind executable.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub start_internal_bitcoind: bool,
|
pub start_internal_bitcoind: bool,
|
||||||
@ -30,7 +26,6 @@ impl Config {
|
|||||||
daemon_rpc_path: None,
|
daemon_rpc_path: None,
|
||||||
log_level: None,
|
log_level: None,
|
||||||
debug: None,
|
debug: None,
|
||||||
hardware_wallets: None,
|
|
||||||
start_internal_bitcoind,
|
start_internal_bitcoind,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -309,11 +309,8 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_wallet(&mut self) -> Result<Arc<Wallet>, Error> {
|
pub fn load_wallet(&mut self) -> Result<Arc<Wallet>, Error> {
|
||||||
let wallet = Wallet::new(self.wallet.main_descriptor.clone()).load_settings(
|
let wallet = Wallet::new(self.wallet.main_descriptor.clone())
|
||||||
&self.config,
|
.load_settings(&self.data_dir, self.cache.network)?;
|
||||||
&self.data_dir,
|
|
||||||
self.cache.network,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
self.wallet = Arc::new(wallet);
|
self.wallet = Arc::new(wallet);
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,7 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::{
|
use crate::{app::settings, hw::HardwareWalletConfig, signer::Signer};
|
||||||
app::{config::Config, settings},
|
|
||||||
hw::HardwareWalletConfig,
|
|
||||||
signer::Signer,
|
|
||||||
};
|
|
||||||
|
|
||||||
use liana::{miniscript::bitcoin, signer::HotSigner};
|
use liana::{miniscript::bitcoin, signer::HotSigner};
|
||||||
|
|
||||||
@ -93,16 +89,9 @@ impl Wallet {
|
|||||||
|
|
||||||
pub fn load_settings(
|
pub fn load_settings(
|
||||||
self,
|
self,
|
||||||
gui_config: &Config,
|
|
||||||
datadir_path: &Path,
|
datadir_path: &Path,
|
||||||
network: bitcoin::Network,
|
network: bitcoin::Network,
|
||||||
) -> Result<Self, WalletError> {
|
) -> 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) {
|
let mut wallet = match settings::Settings::from_file(datadir_path.to_path_buf(), network) {
|
||||||
Ok(settings) => {
|
Ok(settings) => {
|
||||||
if let Some(wallet_setting) = settings.wallets.first() {
|
if let Some(wallet_setting) = settings.wallets.first() {
|
||||||
@ -110,18 +99,17 @@ impl Wallet {
|
|||||||
.with_hardware_wallets(wallet_setting.hardware_wallets.clone())
|
.with_hardware_wallets(wallet_setting.hardware_wallets.clone())
|
||||||
.with_key_aliases(wallet_setting.keys_aliases())
|
.with_key_aliases(wallet_setting.keys_aliases())
|
||||||
} else {
|
} else {
|
||||||
self.with_hardware_wallets(gui_config_hws)
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(settings::SettingsError::NotFound) => {
|
Err(settings::SettingsError::NotFound) => {
|
||||||
let wallet = self.with_hardware_wallets(gui_config_hws);
|
|
||||||
let s = settings::Settings {
|
let s = settings::Settings {
|
||||||
wallets: vec![settings::WalletSetting::from(&wallet)],
|
wallets: vec![settings::WalletSetting::from(&self)],
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing::info!("Settings file not found, creating one");
|
tracing::info!("Settings file not found, creating one");
|
||||||
s.to_file(datadir_path.to_path_buf(), network)?;
|
s.to_file(datadir_path.to_path_buf(), network)?;
|
||||||
wallet
|
self
|
||||||
}
|
}
|
||||||
Err(e) => return Err(e.into()),
|
Err(e) => return Err(e.into()),
|
||||||
};
|
};
|
||||||
|
|||||||
@ -202,7 +202,6 @@ impl Loader {
|
|||||||
load_application(
|
load_application(
|
||||||
daemon.clone(),
|
daemon.clone(),
|
||||||
info,
|
info,
|
||||||
self.gui_config.clone(),
|
|
||||||
self.datadir_path.clone(),
|
self.datadir_path.clone(),
|
||||||
self.network,
|
self.network,
|
||||||
self.internal_bitcoind.clone(),
|
self.internal_bitcoind.clone(),
|
||||||
@ -355,7 +354,6 @@ impl Loader {
|
|||||||
pub async fn load_application(
|
pub async fn load_application(
|
||||||
daemon: Arc<dyn Daemon + Sync + Send>,
|
daemon: Arc<dyn Daemon + Sync + Send>,
|
||||||
info: GetInfoResult,
|
info: GetInfoResult,
|
||||||
gui_config: GUIConfig,
|
|
||||||
datadir_path: PathBuf,
|
datadir_path: PathBuf,
|
||||||
network: bitcoin::Network,
|
network: bitcoin::Network,
|
||||||
internal_bitcoind: Option<Bitcoind>,
|
internal_bitcoind: Option<Bitcoind>,
|
||||||
@ -368,8 +366,7 @@ pub async fn load_application(
|
|||||||
),
|
),
|
||||||
Error,
|
Error,
|
||||||
> {
|
> {
|
||||||
let wallet =
|
let wallet = Wallet::new(info.descriptors.main).load_settings(&datadir_path, network)?;
|
||||||
Wallet::new(info.descriptors.main).load_settings(&gui_config, &datadir_path, network)?;
|
|
||||||
|
|
||||||
let coins = daemon
|
let coins = daemon
|
||||||
.list_coins(&[CoinStatus::Unconfirmed, CoinStatus::Confirmed], &[])
|
.list_coins(&[CoinStatus::Unconfirmed, CoinStatus::Confirmed], &[])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user