From 4a536c6c4d894c7f05c7a054cdf0b450b2fb2db8 Mon Sep 17 00:00:00 2001 From: Samuel Onoja Date: Thu, 9 Jan 2025 15:50:47 +0100 Subject: [PATCH] minor changes to code arrangement in update_seed_storage_password --- .../src/lp_wallet/mnemonics_storage.rs | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mm2src/mm2_main/src/lp_wallet/mnemonics_storage.rs b/mm2src/mm2_main/src/lp_wallet/mnemonics_storage.rs index 31229dde28..079bc6f961 100644 --- a/mm2src/mm2_main/src/lp_wallet/mnemonics_storage.rs +++ b/mm2src/mm2_main/src/lp_wallet/mnemonics_storage.rs @@ -94,16 +94,15 @@ pub async fn update_seed_storage_password( .clone() .ok_or_else(|| WalletsStorageError::Internal("`wallet_name` cannot be None!".to_string()))?; // read mnemonic for a wallet_name using current user's password. - let decrypted = read_and_decrypt_passphrase_if_available(ctx, current_password).await?; - if let Some(mnemonic) = decrypted { - // encrypt mnemonic with new passphrase. - let encrypted_data = encrypt_mnemonic(&mnemonic, new_password)?; - // save new encrypted mnemonic data with new password - save_encrypted_passphrase(ctx, &wallet_name, &encrypted_data).await?; - return Ok(()); - }; + let mnemonic = read_and_decrypt_passphrase_if_available(ctx, current_password) + .await? + .ok_or(MmError::new(WalletsStorageError::Internal(format!( + "{wallet_name}: wallet mnemonic file not found" + ))))?; + // encrypt mnemonic with new passphrase. + let encrypted_data = encrypt_mnemonic(&mnemonic, new_password)?; + // save new encrypted mnemonic data with new password + save_encrypted_passphrase(ctx, &wallet_name, &encrypted_data).await?; - MmError::err(WalletsStorageError::Internal(format!( - "{wallet_name}: wallet mnemonic file not found" - ))) + Ok(()) }