From 82e61dd28a8a4946faf2a3262fa639832d4591ca Mon Sep 17 00:00:00 2001 From: Anynomouss Date: Fri, 24 Jan 2025 13:45:55 +0100 Subject: [PATCH] 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' --- config/src/config.rs | 25 +++++++++++++++++++++++-- impls/src/node_clients/http.rs | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/config/src/config.rs b/config/src/config.rs index d112980..9db501e 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -83,6 +83,22 @@ fn check_config_current_dir(path: &str) -> Option { None } +/// Checks if the node api secret in wallet dir, else return default path +fn check_node_api_exists(path: &str) -> Option { + let p = env::current_dir(); + let mut c = match p { + Ok(c) => c, + Err(_) => { + return None; + } + }; + c.push(path); + if c.exists() { + return Some(c); + } + None +} + /// Whether a config file exists at the given directory pub fn config_file_exists(path: &str) -> bool { let mut path = PathBuf::from(path); @@ -279,8 +295,13 @@ impl GlobalWalletConfig { Some(secret_path.to_str().unwrap().to_owned()); let mut node_secret_path = wallet_home.clone(); node_secret_path.push(API_SECRET_FILE_NAME); - self.members.as_mut().unwrap().wallet.node_api_secret_path = - Some(node_secret_path.to_str().unwrap().to_owned()); + // Set node API secret path to the wallet dir if it exists, else keep default home dir + // if node_secret_path.exists(){ + // self.members.as_mut().unwrap().wallet.node_api_secret_path = + // Some(node_secret_path.to_str().unwrap().to_owned()); + // println!("It node path does actually exists") + // } + let mut log_path = wallet_home.clone(); log_path.push(WALLET_LOG_FILE_NAME); self.members diff --git a/impls/src/node_clients/http.rs b/impls/src/node_clients/http.rs index 83e0488..cd293f9 100644 --- a/impls/src/node_clients/http.rs +++ b/impls/src/node_clients/http.rs @@ -129,6 +129,7 @@ impl NodeClient for HTTPNodeClient { }); } else { error!("Unable to contact Node to get version info: {}", e); + warn!("Warning: You might need to correct 'node_api_secret_path' in your 'grin-wallet.toml' file"); return None; } }