Skip to content

Commit

Permalink
fix: currently newly created wallet does not prompt seed words (#5019) (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
jorgeantonio21 authored Dec 8, 2022
1 parent 9cda0bb commit 96cf8aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion applications/tari_console_wallet/src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
Expand Down
17 changes: 16 additions & 1 deletion applications/tari_console_wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
Expand All @@ -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.");
Expand Down

0 comments on commit 96cf8aa

Please sign in to comment.