Merge remote-tracking branch 'origin/unlockcli' into unlock-pass
This commit is contained in:
commit
a37647b3d1
@ -39,6 +39,7 @@ extern crate rpassword;
|
|||||||
#[cfg(feature = "rpc")]
|
#[cfg(feature = "rpc")]
|
||||||
extern crate ethcore_rpc as rpc;
|
extern crate ethcore_rpc as rpc;
|
||||||
|
|
||||||
|
use std::fs::File;
|
||||||
use std::net::{SocketAddr, IpAddr};
|
use std::net::{SocketAddr, IpAddr};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
@ -89,6 +90,11 @@ Protocol Options:
|
|||||||
[default: $HOME/.web3/keys].
|
[default: $HOME/.web3/keys].
|
||||||
--identity NAME Specify your node's name.
|
--identity NAME Specify your node's name.
|
||||||
|
|
||||||
|
Account Options:
|
||||||
|
--unlock ACCOUNT Unlock ACCOUNT for the duration of the execution.
|
||||||
|
--password FILE Provide a file containing a password for unlocking
|
||||||
|
an account.
|
||||||
|
|
||||||
Networking Options:
|
Networking Options:
|
||||||
--port PORT Override the port on which the node should listen
|
--port PORT Override the port on which the node should listen
|
||||||
[default: 30303].
|
[default: 30303].
|
||||||
@ -176,6 +182,8 @@ struct Args {
|
|||||||
flag_chain: String,
|
flag_chain: String,
|
||||||
flag_db_path: String,
|
flag_db_path: String,
|
||||||
flag_identity: String,
|
flag_identity: String,
|
||||||
|
flag_unlock: Vec<String>,
|
||||||
|
flag_password: Vec<String>,
|
||||||
flag_cache: Option<usize>,
|
flag_cache: Option<usize>,
|
||||||
flag_keys_path: String,
|
flag_keys_path: String,
|
||||||
flag_bootnodes: Option<String>,
|
flag_bootnodes: Option<String>,
|
||||||
@ -490,6 +498,26 @@ impl Configuration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn account_service(&self) -> AccountService {
|
||||||
|
// Secret Store
|
||||||
|
let passwords = self.args.flag_password.iter().map(|filename| {
|
||||||
|
let mut buffer = String::new();
|
||||||
|
File::open(filename).and_then(|mut f| f.read_to_string(&mut buffer)).unwrap_or_else(|_| die!("{} Unable to read password file. Ensure it exists and permissions are correct.", filename));
|
||||||
|
buffer
|
||||||
|
}).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let account_service = AccountService::new();
|
||||||
|
for d in &self.args.flag_unlock {
|
||||||
|
let a = Address::from_str(clean_0x(&d)).unwrap_or_else(|_| {
|
||||||
|
die!("{}: Invalid address for --unlock. Must be 40 hex characters, without the 0x at the beginning.", d)
|
||||||
|
});
|
||||||
|
if passwords.iter().find(|p| account_service.unlock_account(&a, p).is_ok()).is_none() {
|
||||||
|
die!("No password given to unlock account {}. Pass the password using `--password`.", a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
account_service
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature="dev", allow(useless_format))]
|
#[cfg_attr(feature="dev", allow(useless_format))]
|
||||||
fn execute_client(&self) {
|
fn execute_client(&self) {
|
||||||
// Setup panic handler
|
// Setup panic handler
|
||||||
@ -504,6 +532,9 @@ impl Configuration {
|
|||||||
let net_settings = self.net_settings(&spec);
|
let net_settings = self.net_settings(&spec);
|
||||||
let sync_config = self.sync_config(&spec);
|
let sync_config = self.sync_config(&spec);
|
||||||
|
|
||||||
|
// Secret Store
|
||||||
|
let account_service = Arc::new(self.account_service());
|
||||||
|
|
||||||
// Build client
|
// Build client
|
||||||
let mut service = ClientService::start(self.client_config(), spec, net_settings, &Path::new(&self.path())).unwrap();
|
let mut service = ClientService::start(self.client_config(), spec, net_settings, &Path::new(&self.path())).unwrap();
|
||||||
panic_handler.forward_from(&service);
|
panic_handler.forward_from(&service);
|
||||||
@ -519,9 +550,6 @@ impl Configuration {
|
|||||||
// Sync
|
// Sync
|
||||||
let sync = EthSync::register(service.network(), sync_config, client.clone(), miner.clone());
|
let sync = EthSync::register(service.network(), sync_config, client.clone(), miner.clone());
|
||||||
|
|
||||||
// Secret Store
|
|
||||||
let account_service = Arc::new(AccountService::new());
|
|
||||||
|
|
||||||
// Setup rpc
|
// Setup rpc
|
||||||
if self.args.flag_jsonrpc || self.args.flag_rpc {
|
if self.args.flag_jsonrpc || self.args.flag_rpc {
|
||||||
let url = format!("{}:{}",
|
let url = format!("{}:{}",
|
||||||
|
Loading…
Reference in New Issue
Block a user