diff --git a/controller/src/command.rs b/controller/src/command.rs index ea3322ce..afc848b4 100644 --- a/controller/src/command.rs +++ b/controller/src/command.rs @@ -99,7 +99,6 @@ where /// Argument for recover pub struct RecoverArgs { - pub recovery_phrase: Option, pub passphrase: ZeroingString, } @@ -114,13 +113,8 @@ where { let mut w_lock = wallet.lock(); let p = w_lock.lc_provider()?; - match args.recovery_phrase { - None => { - let m = p.get_mnemonic(None, args.passphrase)?; - show_recovery_phrase(m); - } - Some(phrase) => p.recover_from_mnemonic(phrase, args.passphrase)?, - } + let m = p.get_mnemonic(None, args.passphrase)?; + show_recovery_phrase(m); Ok(()) } diff --git a/src/bin/grin-wallet.rs b/src/bin/grin-wallet.rs index 7956fa7b..31070dea 100644 --- a/src/bin/grin-wallet.rs +++ b/src/bin/grin-wallet.rs @@ -90,7 +90,6 @@ fn real_main() -> i32 { })); } } - ("recover", _) => {} _ => {} } diff --git a/src/bin/grin-wallet.yml b/src/bin/grin-wallet.yml index c0e5c767..8a181d4b 100644 --- a/src/bin/grin-wallet.yml +++ b/src/bin/grin-wallet.yml @@ -347,13 +347,7 @@ subcommands: long: recover takes_value: false - recover: - about: Recover a wallet.seed file from a recovery phrase (default) or displays a recovery phrase for an existing seed file - args: - - display: - help: Display wallet recovery phrase - short: d - long: display - takes_value: false + about: Displays a recovery phrase for the wallet. (use `init -r` to perform recovery) - address: about: Display the wallet's payment proof address - scan: diff --git a/src/cmd/wallet_args.rs b/src/cmd/wallet_args.rs index 57e771fc..88f6d2a2 100644 --- a/src/cmd/wallet_args.rs +++ b/src/cmd/wallet_args.rs @@ -89,33 +89,6 @@ fn prompt_password_confirm() -> ZeroingString { first } -fn prompt_replace_seed() -> Result { - let interface = Arc::new(Interface::new("replace_seed")?); - interface.set_report_signal(Signal::Interrupt, true); - interface.set_prompt("Replace seed? (y/n)> ")?; - println!(); - println!("Existing wallet.seed file already exists. Continue?"); - println!("Continuing will back up your existing 'wallet.seed' file as 'wallet.seed.bak'"); - println!(); - loop { - let res = interface.read_line()?; - match res { - ReadResult::Eof => return Ok(false), - ReadResult::Signal(sig) => { - if sig == Signal::Interrupt { - interface.cancel_read_line()?; - return Err(ParseError::CancelledError); - } - } - ReadResult::Input(line) => match line.trim() { - "Y" | "y" => return Ok(true), - "N" | "n" => return Ok(false), - _ => println!("Please respond y or n"), - }, - } - } -} - fn prompt_recovery_phrase( wallet: Arc>>>, ) -> Result @@ -361,42 +334,14 @@ where }) } -pub fn parse_recover_args( - wallet: Arc>>>, +pub fn parse_recover_args( g_args: &command::GlobalArgs, - args: &ArgMatches, ) -> Result where - DefaultWalletImpl<'static, C>: WalletInst<'static, L, C, K>, - L: WalletLCProvider<'static, C, K>, - C: NodeClient + 'static, - K: keychain::Keychain + 'static, { - let (passphrase, recovery_phrase) = { - match args.is_present("display") { - true => (prompt_password(&g_args.password), None), - false => { - let cont = { - let mut w_lock = wallet.lock(); - let p = w_lock.lc_provider().unwrap(); - if p.wallet_exists(None).unwrap() { - prompt_replace_seed()? - } else { - true - } - }; - if !cont { - return Err(ParseError::CancelledError); - } - let phrase = prompt_recovery_phrase(wallet.clone())?; - println!("Please provide a new password for the recovered wallet"); - (prompt_password_confirm(), Some(phrase.to_owned())) - } - } - }; + let passphrase = prompt_password(&g_args.password); Ok(command::RecoverArgs { passphrase: passphrase, - recovery_phrase: recovery_phrase, }) } @@ -955,12 +900,8 @@ where )); command::init(wallet, &global_wallet_args, a) } - ("recover", Some(args)) => { - let a = arg_parse!(parse_recover_args( - wallet.clone(), - &global_wallet_args, - &args - )); + ("recover", Some(_)) => { + let a = arg_parse!(parse_recover_args(&global_wallet_args,)); command::recover(wallet, a) } ("listen", Some(args)) => {