From 8b3e84f7fe8731d2cc670f3294c19d5e6f11f2ca Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 6 Apr 2016 14:03:53 +0300 Subject: [PATCH 1/2] passing key path to all invocations --- parity/main.rs | 8 ++++---- util/src/keys/store.rs | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/parity/main.rs b/parity/main.rs index c5e0dce54..872c91d03 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -82,7 +82,7 @@ Parity. Ethereum Client. Usage: parity daemon [options] - parity account (new | list) + parity account (new | list) [options] parity [options] Protocol Options: @@ -93,7 +93,7 @@ Protocol Options: -d --db-path PATH Specify the database & configuration directory path [default: $HOME/.parity]. --keys-path PATH Specify the path for JSON key files to be found - [default: $HOME/.web3/keys]. + [default: $HOME/.parity/keys]. --identity NAME Specify your node's name. Account Options: @@ -505,7 +505,7 @@ impl Configuration { fn execute_account_cli(&self) { use util::keys::store::SecretStore; use rpassword::read_password; - let mut secret_store = SecretStore::new(); + let mut secret_store = SecretStore::new_in(Path::new(&self.args.flag_keys_path)); if self.args.cmd_new { println!("Please note that password is NOT RECOVERABLE."); println!("Type password: "); @@ -539,7 +539,7 @@ impl Configuration { .into_iter() }).collect::>(); - let account_service = AccountService::new(); + let account_service = AccountService::new_in(Path::new(&self.args.flag_keys_path)); 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) diff --git a/util/src/keys/store.rs b/util/src/keys/store.rs index a4b6f2c7b..5dec27fc3 100644 --- a/util/src/keys/store.rs +++ b/util/src/keys/store.rs @@ -128,7 +128,7 @@ impl Default for AccountService { } impl AccountService { - /// New account service with the default location + /// New account service with the keys store in default location pub fn new() -> Self { let secret_store = RwLock::new(SecretStore::new()); secret_store.write().unwrap().try_import_existing(); @@ -137,6 +137,15 @@ impl AccountService { } } + /// New account service with the keys store in specific location + pub fn new_in(path: &Path) -> Self { + let secret_store = RwLock::new(SecretStore::new_in(path)); + secret_store.write().unwrap().try_import_existing(); + AccountService { + secret_store: secret_store + } + } + #[cfg(test)] fn new_test(temp: &::devtools::RandomTempPath) -> Self { let secret_store = RwLock::new(SecretStore::new_test(temp)); From e6be5016f93ac8a0589c59b6d44ce240f54f62f6 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 6 Apr 2016 14:21:19 +0300 Subject: [PATCH 2/2] replacing /home/nikky also --- parity/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parity/main.rs b/parity/main.rs index 872c91d03..674be24f3 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -383,7 +383,7 @@ impl Configuration { } } - fn _keys_path(&self) -> String { + fn keys_path(&self) -> String { self.args.flag_keys_path.replace("$HOME", env::home_dir().unwrap().to_str().unwrap()) } @@ -505,7 +505,7 @@ impl Configuration { fn execute_account_cli(&self) { use util::keys::store::SecretStore; use rpassword::read_password; - let mut secret_store = SecretStore::new_in(Path::new(&self.args.flag_keys_path)); + let mut secret_store = SecretStore::new_in(Path::new(&self.keys_path())); if self.args.cmd_new { println!("Please note that password is NOT RECOVERABLE."); println!("Type password: "); @@ -539,7 +539,7 @@ impl Configuration { .into_iter() }).collect::>(); - let account_service = AccountService::new_in(Path::new(&self.args.flag_keys_path)); + let account_service = AccountService::new_in(Path::new(&self.keys_path())); 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)