Automatically run wallet listener

Convenience option, set to true by default in grin.toml, to
fork a wallet listener thread by default. Should make it easier
for people to get started on testnet2.

People who want to configure a password for their wallet seed,
run multiple listeners, change default address should set this
to false and manually configure and start their wallet listener.

This might break some tooling. Hopefully not.
This commit is contained in:
Ignotus Peverell 2018-03-11 00:36:54 +00:00
parent 851d7c7b9b
commit a8fcc37a36
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211
4 changed files with 24 additions and 21 deletions

View file

@ -56,6 +56,9 @@ capabilities = [7]
#will also disable logging to stdout #will also disable logging to stdout
run_tui = false 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 #The P2P server details (i.e. the server that communicates with other
#grin server nodes #grin server nodes

View file

@ -151,6 +151,9 @@ pub struct ServerConfig {
/// Whether to run the TUI /// Whether to run the TUI
/// if enabled, this will disable logging to stdout /// if enabled, this will disable logging to stdout
pub run_tui: Option<bool>, pub run_tui: Option<bool>,
/// Whether to run the wallet listener with the server by default
pub run_wallet_listener: Option<bool>,
} }
impl Default for ServerConfig { impl Default for ServerConfig {
@ -168,6 +171,7 @@ impl Default for ServerConfig {
pool_config: pool::PoolConfig::default(), pool_config: pool::PoolConfig::default(),
skip_sync_wait: None, skip_sync_wait: None,
run_tui: None, run_tui: None,
run_wallet_listener: Some(false),
} }
} }
} }

View file

@ -368,7 +368,7 @@ fn server_command(server_args: &ArgMatches, global_config: GlobalConfig) {
info!(LOGGER, "Starting the Grin server..."); info!(LOGGER, "Starting the Grin server...");
// just get defaults from the global config // 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") { if let Some(port) = server_args.value_of("port") {
server_config.p2p_config.port = port.parse().unwrap(); 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()); 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) // start the server in the different run modes (interactive or daemon)
match server_args.subcommand() { match server_args.subcommand() {
("run", _) => { ("run", _) => {
@ -513,25 +528,6 @@ fn wallet_command(wallet_args: &ArgMatches, global_config: GlobalConfig) {
} }
wallet::server::start_rest_apis(wallet_config, keychain); 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)) => { ("send", Some(send_args)) => {
let amount = send_args let amount = send_args
.value_of("amount") .value_of("amount")

View file

@ -361,7 +361,7 @@ impl Controller {
) )
} else if stats.mining_stats.combined_gps == 0.0 { } 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(), "".to_string(),
) )
} else { } else {