mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
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:
parent
851d7c7b9b
commit
a8fcc37a36
4 changed files with 24 additions and 21 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -151,6 +151,9 @@ pub struct ServerConfig {
|
|||
/// Whether to run the TUI
|
||||
/// if enabled, this will disable logging to stdout
|
||||
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 {
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue