Skip to content

Commit

Permalink
fix: on duplicate wallet files (encrypted & plain), favour the plain one
Browse files Browse the repository at this point in the history
  • Loading branch information
mickvandijke committed Dec 13, 2024
1 parent 123f592 commit 707e923
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ant-cli/src/wallet/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ pub(crate) fn load_private_key(wallet_address: &str) -> Result<String, Error> {
let encrypted_file_path =
wallets_folder.join(format!("{wallet_address}{ENCRYPTED_PRIVATE_KEY_EXT}"));

let is_encrypted = encrypted_file_path.exists();
let is_plain = wallets_folder.join(&file_name).exists();

// Trick to favour the plain file in case they both exist
let is_encrypted = encrypted_file_path.exists() && !is_plain;

if is_encrypted {
file_name.push_str(ENCRYPTED_PRIVATE_KEY_EXT);
Expand Down

0 comments on commit 707e923

Please sign in to comment.