wallet: add show_mnemonic_for_account_in_password

This commit is contained in:
Jon Häggblad
2022-05-04 10:01:34 +02:00
parent 1a5580229b
commit 7adee63ebe
2 changed files with 25 additions and 0 deletions
+1
View File
@@ -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,
@@ -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<String, BackendError> {
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,