From e739ac3aa6aebaddb605a8a00432211bcdeb3546 Mon Sep 17 00:00:00 2001 From: brianp Date: Tue, 6 Aug 2024 18:47:10 +0200 Subject: [PATCH] don't show seed words when recovering from hardware wallets --- applications/minotari_console_wallet/src/lib.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/applications/minotari_console_wallet/src/lib.rs b/applications/minotari_console_wallet/src/lib.rs index a2c97bf07e..eb825ad083 100644 --- a/applications/minotari_console_wallet/src/lib.rs +++ b/applications/minotari_console_wallet/src/lib.rs @@ -55,6 +55,7 @@ use tari_common::{ configuration::bootstrap::ApplicationType, exit_codes::{ExitCode, ExitError}, }; +use tari_common_types::wallet_types::WalletType; use tari_key_manager::cipher_seed::CipherSeed; #[cfg(all(unix, feature = "libtor"))] use tari_libtor::tor::Tor; @@ -128,8 +129,6 @@ pub fn run_wallet_with_cli( // check for recovery based on existence of wallet file let (mut boot_mode, password) = boot_with_password(&cli, &config.wallet)?; - let recovery_seed = get_recovery_seed(boot_mode, &cli)?; - let wallet_type = prompt_wallet_type( boot_mode, &config.wallet, @@ -138,6 +137,8 @@ pub fn run_wallet_with_cli( cli.spend_key.clone(), ); + let recovery_seed = get_recovery_seed(boot_mode, &cli, &wallet_type)?; + // get command line password if provided let seed_words_file_name = cli.seed_words_file_name.clone(); @@ -168,6 +169,7 @@ pub fn run_wallet_with_cli( let on_init = matches!(boot_mode, WalletBoot::New); let not_recovery = recovery_seed.is_none(); + let hardware_wallet = matches!(wallet_type, Some(WalletType::Ledger(_))); // initialize wallet let mut wallet = runtime.block_on(init_wallet( @@ -195,7 +197,7 @@ pub fn run_wallet_with_cli( } // 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 { + if !cli.non_interactive_mode && not_recovery && on_init && !hardware_wallet { match confirm_seed_words(&mut wallet) { Ok(()) => { print!("\x1Bc"); // Clear the screen @@ -263,8 +265,12 @@ fn get_password(config: &ApplicationConfig, cli: &Cli) -> Option { .map(|s| s.to_owned()) } -fn get_recovery_seed(boot_mode: WalletBoot, cli: &Cli) -> Result, ExitError> { - if matches!(boot_mode, WalletBoot::Recovery) { +fn get_recovery_seed( + boot_mode: WalletBoot, + cli: &Cli, + wallet_type: &Option, +) -> Result, ExitError> { + if matches!(boot_mode, WalletBoot::Recovery) && !matches!(wallet_type, Some(WalletType::Ledger(_))) { let seed = if let Some(ref seed_words) = cli.seed_words { get_seed_from_seed_words(seed_words)? } else {