mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-07-30 20:01:26 +00:00
Improve recovery
This commit is contained in:
@@ -27,6 +27,10 @@ macro_rules! configure_clapapp {
|
||||
.long("recover")
|
||||
.help("Attempt to recover the seed from the wallet")
|
||||
.takes_value(false))
|
||||
.arg(Arg::with_name("password")
|
||||
.long("password")
|
||||
.help("When recovering seed, specify a password for the encrypted wallet")
|
||||
.takes_value(true))
|
||||
.arg(Arg::with_name("seed")
|
||||
.short("s")
|
||||
.long("seed")
|
||||
@@ -234,7 +238,7 @@ pub fn command_loop(lightclient: Arc<LightClient>) -> (Sender<(String, Vec<Strin
|
||||
(command_tx, resp_rx)
|
||||
}
|
||||
|
||||
pub fn attempt_recover_seed() {
|
||||
pub fn attempt_recover_seed(password: Option<String>) {
|
||||
// Create a Light Client Config in an attempt to recover the file.
|
||||
let config = LightClientConfig {
|
||||
server: "0.0.0.0:0".parse().unwrap(),
|
||||
@@ -246,7 +250,7 @@ pub fn attempt_recover_seed() {
|
||||
data_dir: None,
|
||||
};
|
||||
|
||||
match LightClient::attempt_recover_seed(&config) {
|
||||
match LightClient::attempt_recover_seed(&config, password) {
|
||||
Ok(seed) => println!("Recovered seed: '{}'", seed),
|
||||
Err(e) => eprintln!("Failed to recover seed. Error: {}", e)
|
||||
};
|
||||
|
@@ -13,9 +13,10 @@ pub fn main() {
|
||||
let fresh_app = App::new("Zecwallet CLI");
|
||||
let configured_app = configure_clapapp!(fresh_app);
|
||||
let matches = configured_app.get_matches();
|
||||
|
||||
if matches.is_present("recover") {
|
||||
// Create a Light Client Config in an attempt to recover the file.
|
||||
attempt_recover_seed();
|
||||
attempt_recover_seed(matches.value_of("password").map(|s| s.to_string()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -55,8 +56,9 @@ pub fn main() {
|
||||
let (command_tx, resp_rx) = match startup(server, dangerous, seed, birthday, !nosync, command.is_none()) {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
eprintln!("Error during startup: {}", e);
|
||||
error!("Error during startup: {}", e);
|
||||
let emsg = format!("Error during startup:{}\nIf you repeatedly run into this issue, you might have to restore your wallet from your seed phrase.", e);
|
||||
eprintln!("{}", emsg);
|
||||
error!("{}", emsg);
|
||||
if cfg!(target_os = "unix" ) {
|
||||
match e.raw_os_error() {
|
||||
Some(13) => report_permission_error(),
|
||||
|
Reference in New Issue
Block a user