From 96cf8aaaa4cc3a0b209baa49763bbe18893ab2ae Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Thu, 8 Dec 2022 11:45:08 +0000 Subject: [PATCH] fix: currently newly created wallet does not prompt seed words (#5019) (#5022) Description --- Enforces display of seed words for newly created wallet. Motivation and Context --- In a previous refactor (#4984), a component of the wallet was accidentally removed, namely the prompt of seed words for newly created wallet. How Has This Been Tested? --- In a folder with no wallet db, run `cargo run --release --bin tari_console_wallet` and chose the option create new wallet. --- .../tari_console_wallet/src/init/mod.rs | 2 +- applications/tari_console_wallet/src/lib.rs | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/applications/tari_console_wallet/src/init/mod.rs b/applications/tari_console_wallet/src/init/mod.rs index 7a3072565f..2526752466 100644 --- a/applications/tari_console_wallet/src/init/mod.rs +++ b/applications/tari_console_wallet/src/init/mod.rs @@ -482,7 +482,7 @@ async fn validate_txos(wallet: &mut WalletSqlite) -> Result<(), ExitError> { Ok(()) } -fn confirm_seed_words(wallet: &mut WalletSqlite) -> Result<(), ExitError> { +pub(crate) fn confirm_seed_words(wallet: &mut WalletSqlite) -> Result<(), ExitError> { let seed_words = wallet.get_seed_words(&MnemonicLanguage::English)?; println!(); diff --git a/applications/tari_console_wallet/src/lib.rs b/applications/tari_console_wallet/src/lib.rs index 4d3fba5b93..74225744e6 100644 --- a/applications/tari_console_wallet/src/lib.rs +++ b/applications/tari_console_wallet/src/lib.rs @@ -49,7 +49,7 @@ use tokio::runtime::Runtime; use wallet_modes::{command_mode, grpc_mode, recovery_mode, script_mode, tui_mode, WalletMode}; pub use crate::config::ApplicationConfig; -use crate::init::{boot_with_password, wallet_mode}; +use crate::init::{boot_with_password, confirm_seed_words, wallet_mode}; pub const LOG_TARGET: &str = "wallet::console_wallet::main"; @@ -135,6 +135,9 @@ pub fn run_wallet_with_cli(runtime: Runtime, config: &mut ApplicationConfig, cli ); } + let on_init = matches!(boot_mode, WalletBoot::New); + let not_recovery = recovery_seed.is_none(); + // initialize wallet let mut wallet = runtime.block_on(init_wallet( config, @@ -145,6 +148,18 @@ pub fn run_wallet_with_cli(runtime: Runtime, config: &mut ApplicationConfig, cli cli.non_interactive_mode, ))?; + // if wallet is being set for the first time, wallet seed words are prompted on the screen + if !cli.non_interactive_mode && not_recovery && on_init { + match confirm_seed_words(&mut wallet) { + Ok(()) => { + print!("\x1Bc"); // Clear the screen + }, + Err(error) => { + return Err(error); + }, + }; + } + // Check if there is an in progress recovery in the wallet's database if wallet.is_recovery_in_progress()? { println!("A Wallet Recovery was found to be in progress, continuing.");