presale wallet cli for parity
This commit is contained in:
parent
94a0193047
commit
bbe5cd001a
@ -25,6 +25,7 @@ Usage:
|
|||||||
parity daemon <pid-file> [options]
|
parity daemon <pid-file> [options]
|
||||||
parity account (new | list ) [options]
|
parity account (new | list ) [options]
|
||||||
parity account import <path>... [options]
|
parity account import <path>... [options]
|
||||||
|
parity wallet import <path> --password FILE [options]
|
||||||
parity import [ <file> ] [options]
|
parity import [ <file> ] [options]
|
||||||
parity export [ <file> ] [options]
|
parity export [ <file> ] [options]
|
||||||
parity signer new-token [options]
|
parity signer new-token [options]
|
||||||
@ -215,6 +216,7 @@ Miscellaneous Options:
|
|||||||
pub struct Args {
|
pub struct Args {
|
||||||
pub cmd_daemon: bool,
|
pub cmd_daemon: bool,
|
||||||
pub cmd_account: bool,
|
pub cmd_account: bool,
|
||||||
|
pub cmd_wallet: bool,
|
||||||
pub cmd_new: bool,
|
pub cmd_new: bool,
|
||||||
pub cmd_list: bool,
|
pub cmd_list: bool,
|
||||||
pub cmd_export: bool,
|
pub cmd_export: bool,
|
||||||
|
@ -129,6 +129,11 @@ fn execute(conf: Configuration) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if conf.args.cmd_wallet {
|
||||||
|
execute_wallet_cli(conf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if conf.args.cmd_export {
|
if conf.args.cmd_export {
|
||||||
execute_export(conf);
|
execute_export(conf);
|
||||||
return;
|
return;
|
||||||
@ -534,6 +539,30 @@ fn execute_account_cli(conf: Configuration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn execute_wallet_cli(conf: Configuration) {
|
||||||
|
use ethcore::ethstore::{PresaleWallet, SecretStore, EthStore};
|
||||||
|
use ethcore::ethstore::dir::DiskDirectory;
|
||||||
|
use ethcore::account_provider::AccountProvider;
|
||||||
|
|
||||||
|
let wallet_path = conf.args.arg_path.first().unwrap();
|
||||||
|
let filename = conf.args.flag_password.first().unwrap();
|
||||||
|
let mut file = File::open(filename).unwrap_or_else(|_| die!("{} Unable to read password file.", filename));
|
||||||
|
let mut file_content = String::new();
|
||||||
|
file.read_to_string(&mut file_content).unwrap_or_else(|_| die!("{} Unable to read password file.", filename));
|
||||||
|
|
||||||
|
let dir = Box::new(DiskDirectory::create(conf.keys_path()).unwrap());
|
||||||
|
let iterations = conf.keys_iterations();
|
||||||
|
let store = AccountProvider::new(Box::new(EthStore::open_with_iterations(dir, iterations).unwrap()));
|
||||||
|
|
||||||
|
// remove eof
|
||||||
|
let pass = &file_content[..file_content.len() - 1];
|
||||||
|
let wallet = PresaleWallet::open(wallet_path).unwrap_or_else(|_| die!("Unable to open presale wallet."));
|
||||||
|
let kp = wallet.decrypt(pass).unwrap_or_else(|_| die!("Invalid password"));
|
||||||
|
let address = store.insert_account(kp.secret().clone(), pass).unwrap();
|
||||||
|
|
||||||
|
println!("Imported account: {}", address);
|
||||||
|
}
|
||||||
|
|
||||||
fn wait_for_exit(
|
fn wait_for_exit(
|
||||||
panic_handler: Arc<PanicHandler>,
|
panic_handler: Arc<PanicHandler>,
|
||||||
_rpc_server: Option<RpcServer>,
|
_rpc_server: Option<RpcServer>,
|
||||||
|
Loading…
Reference in New Issue
Block a user