diff --git a/nym-wallet/src-tauri/src/main.rs b/nym-wallet/src-tauri/src/main.rs index 0130ca496c..151a13c9a1 100644 --- a/nym-wallet/src-tauri/src/main.rs +++ b/nym-wallet/src-tauri/src/main.rs @@ -47,6 +47,7 @@ fn main() { mixnet::account::logout, mixnet::account::remove_account_for_password, mixnet::account::remove_password, + mixnet::account::show_mnemonic_for_account_in_password, mixnet::account::sign_in_decrypted_account, mixnet::account::sign_in_with_password, mixnet::account::switch_network, diff --git a/nym-wallet/src-tauri/src/operations/mixnet/account.rs b/nym-wallet/src-tauri/src/operations/mixnet/account.rs index b630cfac91..e146983df7 100644 --- a/nym-wallet/src-tauri/src/operations/mixnet/account.rs +++ b/nym-wallet/src-tauri/src/operations/mixnet/account.rs @@ -526,6 +526,30 @@ pub async fn list_accounts( Ok(all_accounts) } +#[tauri::command] +pub fn show_mnemonic_for_account_in_password( + account_id: String, + password: String, +) -> Result { + log::info!("Getting mnemonic for: {account_id}"); + let id = wallet_storage::AccountId::new(DEFAULT_WALLET_ACCOUNT_ID.to_string()); + let account_id = wallet_storage::AccountId::new(account_id); + let password = wallet_storage::UserPassword::new(password); + let stored_account = wallet_storage::load_existing_wallet_login_information(&id, &password)?; + + let mnemonic = match stored_account { + StoredLogin::Mnemonic(_) => return Err(BackendError::WalletUnexpectedMnemonicAccount), + StoredLogin::Multiple(ref accounts) => accounts + .get_account(&account_id) + .ok_or(BackendError::NoSuchIdInWalletLoginEntry)? + .account + .mnemonic() + .clone(), + }; + + Ok(mnemonic.to_string()) +} + #[tauri::command] pub async fn sign_in_decrypted_account( account_id: &str,