Simplify extraction of recovery phrase.

Co-authored-by: Jack Grigg <str4d@electriccoin.co>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2022-03-09 18:04:27 +00:00
parent 9b20105413
commit d4405feddf
1 changed files with 7 additions and 8 deletions

View File

@ -324,14 +324,13 @@ fn run(opts: &CliOptions) -> anyhow::Result<()> {
.unwrap_or(false)
})
.collect();
if phrase_line.len() != 1 || phrase_line[0].is_err() {
return Err(WalletToolError::RecoveryPhraseNotFound.into());
}
let phrase = phrase_line[0]
.as_ref()
.unwrap()
.trim_start_matches("# - recovery_phrase=\"")
.trim_end_matches('"');
let phrase = match &phrase_line[..] {
[Ok(line)] => line
.trim_start_matches("# - recovery_phrase=\"")
.trim_end_matches('"'),
_ => return Err(WalletToolError::RecoveryPhraseNotFound.into()),
};
// This panic hook allows us to make a best effort to clear the screen (and then print
// another reminder about secrets in the export file) even if a panic occurs.