Skip to content

Commit

Permalink
Tested wallet config creation fix for Issues: mimblewimble#728 #3394 …
Browse files Browse the repository at this point in the history
…Pull 3420, partial fix for 3002
  • Loading branch information
Anynomouss committed Feb 14, 2025
1 parent 80586cc commit c0216a1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion config/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn comments() -> HashMap<String, String> {
.to_string(),
);
retval.insert(
"node_api_secret_path".to_string().replace("/", "\\"),
"node_api_secret_path".to_string(),
"
#location of the node api secret for basic auth on the Grin API
"
Expand Down
34 changes: 17 additions & 17 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use crate::util::logger::LoggingConfig;
/// Wallet configuration file name
pub const WALLET_CONFIG_FILE_NAME: &str = "grin-wallet.toml";
const WALLET_LOG_FILE_NAME: &str = "grin-wallet.log";
/// .grin folder, usually in home/.grin
pub const GRIN_HOME: &str = ".grin";
/// Wallet data directory
pub const GRIN_WALLET_DIR: &str = "wallet_data";
Expand Down Expand Up @@ -211,22 +212,26 @@ pub fn initial_setup_wallet(
// Update paths relative to current dir, assumes node secret is in user home
default_config.update_paths(&wallet_path, &node_path);
// Write config file, otherwise defaults will be writen
default_config.write_to_file(
&default_config
.config_file_path
.clone()
.unwrap()
.to_str()
.unwrap(),
false,
None,
None,
);
default_config
.write_to_file(
&default_config
.config_file_path
.clone()
.unwrap()
.to_str()
.unwrap(),
false,
None,
None,
)
.unwrap_or_else(|e| {
panic!("Error creating config file: {}", e);
});
(wallet_path, default_config)
}

true => {
let mut path = config_path.clone();
let mut path = wallet_path.clone();
path.pop();
(
path,
Expand Down Expand Up @@ -335,13 +340,8 @@ impl GlobalWalletConfig {
Some(secret_path.to_str().unwrap().to_owned());
let mut node_secret_path = node_home.clone();
node_secret_path.push(API_SECRET_FILE_NAME);
dbg!("Voor update, path to node to set to:{}", &node_secret_path);
self.members.as_mut().unwrap().wallet.node_api_secret_path =
Some(node_secret_path.to_str().unwrap().to_owned());
dbg!(
"Na update, path to node:{}",
&self.members.as_mut().unwrap().wallet.node_api_secret_path
);
let mut log_path = wallet_home.clone();
log_path.push(WALLET_LOG_FILE_NAME);
self.members
Expand Down
13 changes: 7 additions & 6 deletions controller/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use crate::api::TLSConfig;
use crate::apiwallet::{try_slatepack_sync_workflow, Owner};
use crate::config::{TorConfig, WalletConfig, WALLET_CONFIG_FILE_NAME};
use crate::core::{core, global};
use crate::config::{TorConfig, WalletConfig};
use crate::core::core;
use crate::error::Error;
use crate::impls::PathToSlatepack;
use crate::impls::SlateGetter as _;
Expand Down Expand Up @@ -82,12 +82,13 @@ where
K: keychain::Keychain + 'static,
{
// Assume global chain type has already been initialized.
let chain_type = global::get_chain_type();

let mut w_lock = owner_api.wallet_inst.lock();
let p = w_lock.lc_provider()?;
// Config and updating of config was moved to main, avoid overwriting with default value
//p.create_config(&chain_type, WALLET_CONFIG_FILE_NAME, None, None, None)?;
// Config creation was moved to main, only create new if config is ot in arguments
// let chain_type = global::get_chain_type();
// args.config, config: &WalletConfig) {
// p.create_config(&chain_type, WALLET_CONFIG_FILE_NAME, None, None, None)?;
// }
p.create_wallet(
None,
args.recovery_phrase,
Expand Down
4 changes: 2 additions & 2 deletions impls/src/node_clients/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ impl NodeClient for HTTPNodeClient {
verified: Some(false),
});
} 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");
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;
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/bin/grin-wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn real_main() -> i32 {
let res = args.value_of("top_level_dir");
match res {
Some(d) => {
current_dir = Some(PathBuf::from(d));
current_dir = Some(PathBuf::from(d.replace("/", "\\")));
}
None => {
warn!("Argument --top_level_dir needs a value. Defaulting to current directory")
Expand Down Expand Up @@ -138,10 +138,8 @@ fn real_main() -> i32 {
"Using wallet configuration file at {}",
config.config_file_path.as_ref().unwrap().to_str().unwrap()
);
println!("here3");
log_build_info();

dbg!(&config.members.as_mut().unwrap().wallet.node_api_secret_path);
global::init_global_chain_type(
config
.members
Expand All @@ -156,7 +154,6 @@ fn real_main() -> i32 {
global::init_global_accept_fee_base(config.members.as_ref().unwrap().wallet.accept_fee_base());

let wallet_config = config.clone().members.unwrap().wallet;
dbg!(&config.members.as_mut().unwrap().wallet.node_api_secret_path);
let node_client = HTTPNodeClient::new(&wallet_config.check_node_api_http_addr, None).unwrap();
cmd::wallet_command(&args, config, node_client)
}

0 comments on commit c0216a1

Please sign in to comment.