mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 04:31:51 +00:00
## Issue Addressed N/A ## Proposed Changes Add a `lighthouse am wallet recover` command that recreates a wallet from a mnemonic but no validator keys. Add a `lighthouse am validator recover` command which would directly create keys from a mnemonic for a given index and count. ## Additional Info Co-authored-by: Paul Hauner <paul@paulhauner.com>
46 lines
1.5 KiB
Rust
46 lines
1.5 KiB
Rust
pub mod create;
|
|
pub mod deposit;
|
|
pub mod import;
|
|
pub mod list;
|
|
pub mod recover;
|
|
|
|
use crate::common::base_wallet_dir;
|
|
use clap::{App, Arg, ArgMatches};
|
|
use environment::Environment;
|
|
use types::EthSpec;
|
|
|
|
pub const CMD: &str = "validator";
|
|
|
|
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|
App::new(CMD)
|
|
.about("Provides commands for managing Eth2 validators.")
|
|
.arg(
|
|
Arg::with_name("base-dir")
|
|
.long("base-dir")
|
|
.value_name("BASE_DIRECTORY")
|
|
.help("A path containing Eth2 EIP-2386 wallets. Defaults to ~/.lighthouse/wallets")
|
|
.takes_value(true),
|
|
)
|
|
.subcommand(create::cli_app())
|
|
.subcommand(deposit::cli_app())
|
|
.subcommand(import::cli_app())
|
|
.subcommand(list::cli_app())
|
|
.subcommand(recover::cli_app())
|
|
}
|
|
|
|
pub fn cli_run<T: EthSpec>(matches: &ArgMatches, env: Environment<T>) -> Result<(), String> {
|
|
let base_wallet_dir = base_wallet_dir(matches, "base-dir")?;
|
|
|
|
match matches.subcommand() {
|
|
(create::CMD, Some(matches)) => create::cli_run::<T>(matches, env, base_wallet_dir),
|
|
(deposit::CMD, Some(matches)) => deposit::cli_run::<T>(matches, env),
|
|
(import::CMD, Some(matches)) => import::cli_run(matches),
|
|
(list::CMD, Some(matches)) => list::cli_run(matches),
|
|
(recover::CMD, Some(matches)) => recover::cli_run(matches),
|
|
(unknown, _) => Err(format!(
|
|
"{} does not have a {} command. See --help",
|
|
CMD, unknown
|
|
)),
|
|
}
|
|
}
|