mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-02-01 17:01:10 +03:00
Remove manual recovery (#268)
* remove recovery command * Remove manual recovery option from command line * rustfmt
This commit is contained in:
parent
43a7bfecef
commit
56396b85ff
4 changed files with 7 additions and 79 deletions
|
@ -99,7 +99,6 @@ where
|
||||||
|
|
||||||
/// Argument for recover
|
/// Argument for recover
|
||||||
pub struct RecoverArgs {
|
pub struct RecoverArgs {
|
||||||
pub recovery_phrase: Option<ZeroingString>,
|
|
||||||
pub passphrase: ZeroingString,
|
pub passphrase: ZeroingString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,13 +113,8 @@ where
|
||||||
{
|
{
|
||||||
let mut w_lock = wallet.lock();
|
let mut w_lock = wallet.lock();
|
||||||
let p = w_lock.lc_provider()?;
|
let p = w_lock.lc_provider()?;
|
||||||
match args.recovery_phrase {
|
|
||||||
None => {
|
|
||||||
let m = p.get_mnemonic(None, args.passphrase)?;
|
let m = p.get_mnemonic(None, args.passphrase)?;
|
||||||
show_recovery_phrase(m);
|
show_recovery_phrase(m);
|
||||||
}
|
|
||||||
Some(phrase) => p.recover_from_mnemonic(phrase, args.passphrase)?,
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,6 @@ fn real_main() -> i32 {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
("recover", _) => {}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -347,13 +347,7 @@ subcommands:
|
||||||
long: recover
|
long: recover
|
||||||
takes_value: false
|
takes_value: false
|
||||||
- recover:
|
- recover:
|
||||||
about: Recover a wallet.seed file from a recovery phrase (default) or displays a recovery phrase for an existing seed file
|
about: Displays a recovery phrase for the wallet. (use `init -r` to perform recovery)
|
||||||
args:
|
|
||||||
- display:
|
|
||||||
help: Display wallet recovery phrase
|
|
||||||
short: d
|
|
||||||
long: display
|
|
||||||
takes_value: false
|
|
||||||
- address:
|
- address:
|
||||||
about: Display the wallet's payment proof address
|
about: Display the wallet's payment proof address
|
||||||
- scan:
|
- scan:
|
||||||
|
|
|
@ -89,33 +89,6 @@ fn prompt_password_confirm() -> ZeroingString {
|
||||||
first
|
first
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prompt_replace_seed() -> Result<bool, ParseError> {
|
|
||||||
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<L, C, K>(
|
fn prompt_recovery_phrase<L, C, K>(
|
||||||
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
|
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
|
||||||
) -> Result<ZeroingString, ParseError>
|
) -> Result<ZeroingString, ParseError>
|
||||||
|
@ -361,42 +334,14 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_recover_args<L, C, K>(
|
pub fn parse_recover_args(
|
||||||
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
|
|
||||||
g_args: &command::GlobalArgs,
|
g_args: &command::GlobalArgs,
|
||||||
args: &ArgMatches,
|
|
||||||
) -> Result<command::RecoverArgs, ParseError>
|
) -> Result<command::RecoverArgs, ParseError>
|
||||||
where
|
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) = {
|
let passphrase = prompt_password(&g_args.password);
|
||||||
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()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Ok(command::RecoverArgs {
|
Ok(command::RecoverArgs {
|
||||||
passphrase: passphrase,
|
passphrase: passphrase,
|
||||||
recovery_phrase: recovery_phrase,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -955,12 +900,8 @@ where
|
||||||
));
|
));
|
||||||
command::init(wallet, &global_wallet_args, a)
|
command::init(wallet, &global_wallet_args, a)
|
||||||
}
|
}
|
||||||
("recover", Some(args)) => {
|
("recover", Some(_)) => {
|
||||||
let a = arg_parse!(parse_recover_args(
|
let a = arg_parse!(parse_recover_args(&global_wallet_args,));
|
||||||
wallet.clone(),
|
|
||||||
&global_wallet_args,
|
|
||||||
&args
|
|
||||||
));
|
|
||||||
command::recover(wallet, a)
|
command::recover(wallet, a)
|
||||||
}
|
}
|
||||||
("listen", Some(args)) => {
|
("listen", Some(args)) => {
|
||||||
|
|
Loading…
Reference in a new issue