Skip to content

Commit

Permalink
minor changes to code arrangement in update_seed_storage_password
Browse files Browse the repository at this point in the history
  • Loading branch information
borngraced committed Jan 9, 2025
1 parent dc16267 commit 4a536c6
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions mm2src/mm2_main/src/lp_wallet/mnemonics_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

0 comments on commit 4a536c6

Please sign in to comment.