basic commands

This commit is contained in:
Nikolay Volf
2016-03-09 17:11:15 +04:00
parent 3655354980
commit 6ad0ba8fe2
4 changed files with 56 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ extern crate fdlimit;
extern crate daemonize;
extern crate time;
extern crate number_prefix;
extern crate rpassword;
#[cfg(feature = "rpc")]
extern crate ethcore_rpc as rpc;
@@ -70,6 +71,7 @@ Parity. Ethereum Client.
Usage:
parity daemon <pid-file> [options] [ --no-bootstrap | <enode>... ]
parity account <command>
parity [options] [ --no-bootstrap | <enode>... ]
Protocol Options:
@@ -126,8 +128,10 @@ Miscellaneous Options:
#[derive(Debug, RustcDecodable)]
struct Args {
cmd_daemon: bool,
cmd_account: bool,
arg_pid_file: String,
arg_enode: Vec<String>,
arg_command: String,
flag_chain: String,
flag_testnet: bool,
flag_datadir: String,
@@ -337,9 +341,39 @@ impl Configuration {
.start()
.unwrap_or_else(|e| die!("Couldn't daemonize; {}", e));
}
if self.args.cmd_account {
self.execute_account_cli(&self.args.arg_command);
return;
}
self.execute_client();
}
fn execute_account_cli(&self, command: &str) {
use util::keys::store::SecretStore;
use rpassword::read_password;
let mut secret_store = SecretStore::new();
if command == "new" {
println!("Please note that password is NOT RECOVERABLE.");
println!("Type password: ");
let password = read_password().unwrap();
println!("Repeat password: ");
let password_repeat = read_password().unwrap();
if password != password_repeat {
println!("Passwords do not match!");
return;
}
println!("New account address:");
let new_address = secret_store.new_account(&password).unwrap();
println!("{:?}", new_address);
}
if command == "list" {
println!("Known addresses:");
for &(addr, _) in secret_store.accounts().unwrap().iter() {
println!("{:?}", addr);
}
}
}
fn execute_client(&self) {
// Setup logging
setup_log(&self.args.flag_logging);