Add Ws Json rpc client and command line utils

This commit is contained in:
Kristoffer Ström
2016-09-20 12:19:07 +02:00
committed by arkpar
parent 2226324495
commit 4e3f8bab10
14 changed files with 796 additions and 7 deletions

View File

@@ -31,6 +31,8 @@ usage! {
cmd_import: bool,
cmd_signer: bool,
cmd_new_token: bool,
cmd_sign: bool,
cmd_reject: bool,
cmd_snapshot: bool,
cmd_restore: bool,
cmd_ui: bool,
@@ -41,6 +43,7 @@ usage! {
arg_pid_file: String,
arg_file: Option<String>,
arg_path: Vec<String>,
arg_id: Option<usize>,
// Flags
// -- Legacy Options

View File

@@ -12,6 +12,9 @@ Usage:
parity import [ <file> ] [options]
parity export (blocks | state) [ <file> ] [options]
parity signer new-token [options]
parity signer list [options]
parity signer sign [ <id> ] [ --password FILE ] [options]
parity signer reject <id> [options]
parity snapshot <file> [options]
parity restore [ <file> ] [options]
parity tools hash <file>

View File

@@ -51,6 +51,21 @@ pub enum Cmd {
ImportPresaleWallet(ImportWallet),
Blockchain(BlockchainCmd),
SignerToken(SignerConfiguration),
SignerSign {
id: Option<usize>,
pwfile: Option<PathBuf>,
port: u16,
authfile: PathBuf,
},
SignerList {
port: u16,
authfile: PathBuf
},
SignerReject {
id: usize,
port: u16,
authfile: PathBuf
},
Snapshot(SnapshotCommand),
Hash(Option<String>),
}
@@ -103,8 +118,43 @@ impl Configuration {
let cmd = if self.args.flag_version {
Cmd::Version
<<<<<<< HEAD
} else if self.args.cmd_signer && self.args.cmd_new_token {
Cmd::SignerToken(signer_conf)
=======
} else if self.args.cmd_signer {
let mut authfile = PathBuf::from(signer_conf.signer_path);
authfile.push("authcodes");
if self.args.cmd_new_token {
Cmd::SignerToken(dirs.signer)
} else if self.args.cmd_sign {
let pwfile = match self.args.flag_password.get(0) {
Some(pwfile) => Some(PathBuf::from(pwfile)),
None => None,
};
Cmd::SignerSign {
id: self.args.arg_id,
pwfile: pwfile,
port: signer_conf.port,
authfile: authfile,
}
} else if self.args.cmd_reject {
Cmd::SignerReject {
// id is a required field for this command
id: self.args.arg_id.unwrap(),
port: signer_conf.port,
authfile: authfile,
}
} else if self.args.cmd_list {
Cmd::SignerList {
port: signer_conf.port,
authfile: authfile,
}
} else {
unreachable!();
}
>>>>>>> Add Ws Json rpc client and command line utils
} else if self.args.cmd_tools && self.args.cmd_hash {
Cmd::Hash(self.args.arg_file)
} else if self.args.cmd_account {
@@ -1126,4 +1176,3 @@ mod tests {
assert!(conf.init_reserved_nodes().is_ok());
}
}

View File

@@ -69,6 +69,8 @@ extern crate ethcore_stratum;
#[cfg(feature = "dapps")]
extern crate ethcore_dapps;
extern crate rpc_cli;
macro_rules! dependency {
($dep_ty:ident, $url:expr) => {
{
@@ -145,6 +147,12 @@ fn execute(command: Execute) -> Result<String, String> {
Cmd::ImportPresaleWallet(presale_cmd) => presale::execute(presale_cmd),
Cmd::Blockchain(blockchain_cmd) => blockchain::execute(blockchain_cmd),
Cmd::SignerToken(signer_cmd) => signer::execute(signer_cmd),
Cmd::SignerSign { id, pwfile, port, authfile } =>
rpc_cli::cmd_signer_sign(id, pwfile, port, authfile),
Cmd::SignerList { port, authfile } =>
rpc_cli::cmd_signer_list(port, authfile),
Cmd::SignerReject { id, port, authfile } =>
rpc_cli::cmd_signer_reject(id, port, authfile),
Cmd::Snapshot(snapshot_cmd) => snapshot::execute(snapshot_cmd),
}
}