Fix for many wallet config errors (#731)

* Added an extra warning message when failing to reach the node, work in progress on changing default dir for node api ssecret 'foreign_api_secret'

* In the middle of debugging hell, default overwrite any updates to the config made earlier, its never written to a file when running init

* More debugging, next trace the overwrite of the config

* Added get get_node_path function, seperating wallet dir and node_dir -compiling but some  warnings

* Tested wallet config creation fix for Issues: #728 #3394 Pull 3420, partial fix for 3002

* Removed some debugging code

* Fixed passing config to create_config function, some more test needed before pulling to main

* All test succeed: a) normal, b) top-dir, c) here, d) with default config template in working dir

* Cleaning up

* Fixed a single test for config that needed adjusting
This commit is contained in:
Anynomouss
2025-03-08 12:22:59 +00:00
committed by GitHub
parent 3b0cc2401a
commit 7ceade4449
7 changed files with 108 additions and 42 deletions
+14 -8
View File
@@ -87,11 +87,12 @@ where
None => None,
},
};
let wallet = match wallet_config {
Some(w) => w,
// Check if config was provided, if not load default and set update to "true"
let (wallet, update) = match wallet_config {
Some(w) => (w, false),
None => match default_config.members.as_ref() {
Some(m) => m.clone().wallet,
None => WalletConfig::default(),
Some(m) => (m.clone().wallet, true),
None => (WalletConfig::default(), true),
},
};
let tor = match tor_config {
@@ -136,11 +137,16 @@ where
if config_file_name.exists() {
return Ok(());
}
// default settings are updated if no config was provided, no support for top_dir/here
let mut abs_path_node = std::env::current_dir()?;
abs_path_node.push(self.data_dir.clone());
let mut absolute_path_wallet = std::env::current_dir()?;
absolute_path_wallet.push(self.data_dir.clone());
let mut abs_path = std::env::current_dir()?;
abs_path.push(self.data_dir.clone());
default_config.update_paths(&abs_path);
// if no config provided, update defaults
if update == true {
default_config.update_paths(&abs_path_node, &absolute_path_wallet);
};
let res =
default_config.write_to_file(config_file_name.to_str().unwrap(), false, None, None);
if let Err(e) = res {
+2 -1
View File
@@ -128,7 +128,8 @@ impl NodeClient for HTTPNodeClient {
verified: Some(false),
});
} else {
error!("Unable to contact Node to get version info: {}", e);
error!("Unable to contact Node to get version info: {}, check your node is running", e);
warn!("Warning: a) Node is offline, or b) 'node_api_secret_path' in 'grin-wallet.toml' is set incorrectly");
return None;
}
}