diff --git a/grin.toml b/grin.toml index a16eb775e..425bcfecf 100644 --- a/grin.toml +++ b/grin.toml @@ -56,6 +56,9 @@ capabilities = [7] #will also disable logging to stdout run_tui = false +#Whether to run the wallet listener with the server by default +run_wallet_listener = true + #The P2P server details (i.e. the server that communicates with other #grin server nodes diff --git a/grin/src/types.rs b/grin/src/types.rs index 9c538e65e..130f4d3a5 100644 --- a/grin/src/types.rs +++ b/grin/src/types.rs @@ -151,6 +151,9 @@ pub struct ServerConfig { /// Whether to run the TUI /// if enabled, this will disable logging to stdout pub run_tui: Option, + + /// Whether to run the wallet listener with the server by default + pub run_wallet_listener: Option, } impl Default for ServerConfig { @@ -168,6 +171,7 @@ impl Default for ServerConfig { pool_config: pool::PoolConfig::default(), skip_sync_wait: None, run_tui: None, + run_wallet_listener: Some(false), } } } diff --git a/src/bin/grin.rs b/src/bin/grin.rs index b2d289f1b..bb86925b4 100644 --- a/src/bin/grin.rs +++ b/src/bin/grin.rs @@ -368,7 +368,7 @@ fn server_command(server_args: &ArgMatches, global_config: GlobalConfig) { info!(LOGGER, "Starting the Grin server..."); // just get defaults from the global config - let mut server_config = global_config.members.unwrap().server; + let mut server_config = global_config.members.as_ref().unwrap().server.clone(); if let Some(port) = server_args.value_of("port") { server_config.p2p_config.port = port.parse().unwrap(); @@ -396,6 +396,21 @@ fn server_command(server_args: &ArgMatches, global_config: GlobalConfig) { server_config.seeds = Some(seeds.map(|s| s.to_string()).collect()); } + if let Some(true) = server_config.run_wallet_listener { + let mut wallet_config = global_config.members.unwrap().wallet; + let wallet_seed = + wallet::WalletSeed::from_file(&wallet_config).expect("Failed to read wallet seed file."); + let mut keychain = wallet_seed + .derive_keychain("") + .expect("Failed to derive keychain from seed file and passphrase."); + + let _ = thread::Builder::new() + .name("wallet_listener".to_string()) + .spawn(move || { + wallet::server::start_rest_apis(wallet_config, keychain); + }); + } + // start the server in the different run modes (interactive or daemon) match server_args.subcommand() { ("run", _) => { @@ -513,25 +528,6 @@ fn wallet_command(wallet_args: &ArgMatches, global_config: GlobalConfig) { } wallet::server::start_rest_apis(wallet_config, keychain); } - // The following is gone for now, as a result of aggsig transactions - // being implemented - /*("receive", Some(receive_args)) => { - let input = receive_args.value_of("input").expect("Input file required"); - let mut file = File::open(input).expect("Unable to open transaction file."); - let mut contents = String::new(); - file.read_to_string(&mut contents).expect( - "Unable to read transaction file.", - ); - if let Err(e) = - wallet::receive_json_tx_str( - &wallet_config, &keychain, contents.as_str()) { - - println!("Error receiving transaction, the most likely reasons are:"); - println!(" * the transaction has already been sent"); - println!(" * your node isn't running or can't be reached"); - println!("\nDetailed error: {:?}", e); - } - }*/ ("send", Some(send_args)) => { let amount = send_args .value_of("amount") diff --git a/src/bin/ui.rs b/src/bin/ui.rs index 3b4f2000b..e81caf872 100644 --- a/src/bin/ui.rs +++ b/src/bin/ui.rs @@ -361,7 +361,7 @@ impl Controller { ) } else if stats.mining_stats.combined_gps == 0.0 { ( - "Mining Status: Starting miner and awating first solution...".to_string(), + "Mining Status: Starting miner and awaiting first solution...".to_string(), "".to_string(), ) } else {