Clarify account creation error messages in CLI (bp #7719) (#7745)

automerge
This commit is contained in:
mergify[bot]
2020-01-10 07:02:11 -08:00
committed by Grimes
parent 1b3be91e3c
commit 32a728d585
4 changed files with 49 additions and 15 deletions

View File

@@ -527,12 +527,16 @@ pub fn process_create_stake_account(
(&stake_account_pubkey, "stake_account_pubkey".to_string()),
)?;
if rpc_client.get_account(&stake_account_pubkey).is_ok() {
return Err(CliError::BadParameter(format!(
"Unable to create stake account. Stake account already exists: {}",
stake_account_pubkey
))
.into());
if let Ok(stake_account) = rpc_client.get_account(&stake_account_pubkey) {
let err_msg = if stake_account.owner == solana_stake_program::id() {
format!("Stake account {} already exists", stake_account_pubkey)
} else {
format!(
"Account {} already exists and is not a stake account",
stake_account_pubkey
)
};
return Err(CliError::BadParameter(err_msg).into());
}
let minimum_balance =