Skip to content

Commit 96cf8aa

Browse files
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.
1 parent 9cda0bb commit 96cf8aa

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

applications/tari_console_wallet/src/init/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ async fn validate_txos(wallet: &mut WalletSqlite) -> Result<(), ExitError> {
482482
Ok(())
483483
}
484484

485-
fn confirm_seed_words(wallet: &mut WalletSqlite) -> Result<(), ExitError> {
485+
pub(crate) fn confirm_seed_words(wallet: &mut WalletSqlite) -> Result<(), ExitError> {
486486
let seed_words = wallet.get_seed_words(&MnemonicLanguage::English)?;
487487

488488
println!();

applications/tari_console_wallet/src/lib.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use tokio::runtime::Runtime;
4949
use wallet_modes::{command_mode, grpc_mode, recovery_mode, script_mode, tui_mode, WalletMode};
5050

5151
pub use crate::config::ApplicationConfig;
52-
use crate::init::{boot_with_password, wallet_mode};
52+
use crate::init::{boot_with_password, confirm_seed_words, wallet_mode};
5353

5454
pub const LOG_TARGET: &str = "wallet::console_wallet::main";
5555

@@ -135,6 +135,9 @@ pub fn run_wallet_with_cli(runtime: Runtime, config: &mut ApplicationConfig, cli
135135
);
136136
}
137137

138+
let on_init = matches!(boot_mode, WalletBoot::New);
139+
let not_recovery = recovery_seed.is_none();
140+
138141
// initialize wallet
139142
let mut wallet = runtime.block_on(init_wallet(
140143
config,
@@ -145,6 +148,18 @@ pub fn run_wallet_with_cli(runtime: Runtime, config: &mut ApplicationConfig, cli
145148
cli.non_interactive_mode,
146149
))?;
147150

151+
// if wallet is being set for the first time, wallet seed words are prompted on the screen
152+
if !cli.non_interactive_mode && not_recovery && on_init {
153+
match confirm_seed_words(&mut wallet) {
154+
Ok(()) => {
155+
print!("\x1Bc"); // Clear the screen
156+
},
157+
Err(error) => {
158+
return Err(error);
159+
},
160+
};
161+
}
162+
148163
// Check if there is an in progress recovery in the wallet's database
149164
if wallet.is_recovery_in_progress()? {
150165
println!("A Wallet Recovery was found to be in progress, continuing.");

0 commit comments

Comments
 (0)