Skip to content

Commit

Permalink
chore: prompt password (foundry-rs#3101)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Sep 6, 2022
1 parent 959d15d commit 76be373
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions cli/src/cmd/cast/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ impl WalletSubcommands {
password
} else {
// if no --unsafe-password was provided read via stdin
println!("Insert secret:");
rpassword::read_password()?
rpassword::prompt_password("Enter secret: ")?
};

let (key, uuid) = LocalWallet::new_keystore(&path, &mut rng, password, None)?;
Expand Down
6 changes: 2 additions & 4 deletions cli/src/opts/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ impl WalletTrait for Wallet {}

pub trait WalletTrait {
fn get_from_interactive(&self) -> Result<LocalWallet> {
println!("Insert private key:");
let private_key = rpassword::read_password()?;
let private_key = rpassword::prompt_password("Enter private key: ")?;
let private_key = private_key.strip_prefix("0x").unwrap_or(&private_key);
Ok(LocalWallet::from_str(private_key)?)
}
Expand Down Expand Up @@ -242,8 +241,7 @@ pub trait WalletTrait {
Ok(match (keystore_path, keystore_password) {
(Some(path), Some(password)) => Some(LocalWallet::decrypt_keystore(path, password)?),
(Some(path), None) => {
println!("Insert keystore password:");
let password = rpassword::read_password().unwrap();
let password = rpassword::prompt_password("Enter keystore password:")?;
Some(LocalWallet::decrypt_keystore(path, password)?)
}
(None, _) => None,
Expand Down

0 comments on commit 76be373

Please sign in to comment.