Web wallet api updates (#1155)

* CORS for webwallet

* rustfmt

* automatically start up wallet web api (owner) listener
This commit is contained in:
Yeastplume
2018-06-11 18:19:38 +01:00
committed by GitHub
parent 973d46e6aa
commit 05073c5c02
5 changed files with 38 additions and 5 deletions
+23 -2
View File
@@ -371,7 +371,7 @@ fn server_command(server_args: Option<&ArgMatches>, mut global_config: GlobalCon
info!(
LOGGER,
"Starting the Grin server from configuration file at {}",
global_config.config_file_path.unwrap().to_str().unwrap()
global_config.config_file_path.as_ref().unwrap().to_str().unwrap()
);
global::set_mining_mode(
global_config
@@ -414,7 +414,7 @@ fn server_command(server_args: Option<&ArgMatches>, mut global_config: GlobalCon
}
if let Some(true) = server_config.run_wallet_listener {
let mut wallet_config = global_config.members.unwrap().wallet;
let mut wallet_config = global_config.members.as_ref().unwrap().wallet.clone();
if let Err(_) = wallet::WalletSeed::from_file(&wallet_config) {
wallet::WalletSeed::init_file(&wallet_config)
.expect("Failed to create wallet seed file.");
@@ -436,6 +436,27 @@ fn server_command(server_args: Option<&ArgMatches>, mut global_config: GlobalCon
});
});
}
if let Some(true) = server_config.run_wallet_owner_api {
let mut wallet_config = global_config.members.unwrap().wallet;
if let Err(_) = wallet::WalletSeed::from_file(&wallet_config) {
wallet::WalletSeed::init_file(&wallet_config)
.expect("Failed to create wallet seed file.");
};
let _ = thread::Builder::new()
.name("wallet_owner_listener".to_string())
.spawn(move || {
let wallet = FileWallet::new(wallet_config.clone(), "").unwrap_or_else(|e| {
panic!("Error creating wallet: {:?} Config: {:?}", e, wallet_config)
});
wallet::controller::owner_listener(wallet, "127.0.0.1:13420").unwrap_or_else(|e| {
panic!(
"Error creating wallet api listener: {:?} Config: {:?}",
e, wallet_config
)
});
});
}
// start the server in the different run modes (interactive or daemon)
if let Some(a) = server_args {