diff --git a/applications/tari_console_wallet/src/init/mod.rs b/applications/tari_console_wallet/src/init/mod.rs index f9f3871752..da6a0db554 100644 --- a/applications/tari_console_wallet/src/init/mod.rs +++ b/applications/tari_console_wallet/src/init/mod.rs @@ -59,7 +59,7 @@ use tari_wallet::{ WalletConfig, WalletSqlite, }; -use zxcvbn::{feedback::Suggestion, zxcvbn}; +use zxcvbn::zxcvbn; use crate::{ cli::Cli, @@ -79,19 +79,13 @@ pub enum WalletBoot { } /// Get feedback, if available, for a weak passphrase -fn get_password_feedback(passphrase: &SafePassword) -> Option> { - if let Ok(passphrase_str) = std::str::from_utf8(passphrase.reveal()) { - match zxcvbn(passphrase_str, &[]) { - Ok(scoring) => scoring - .feedback() - .to_owned() - .map(|feedback| feedback.suggestions().to_owned()), - _ => None, - } - } else { - // Fail empty if we can't convert the passphrase back to a string, which shouldn't happen - None - } +fn get_password_feedback(passphrase: &SafePassword) -> Option> { + std::str::from_utf8(passphrase.reveal()) + .ok() + .and_then(|passphrase| zxcvbn(passphrase, &[]).ok()) + .and_then(|scored| scored.feedback().to_owned()) + .map(|feedback| feedback.suggestions().to_owned()) + .map(|suggestion| suggestion.into_iter().map(|item| item.to_string()).collect()) } // Display password feedback to the user