Cleanly error when trying to delegate-stake an existing stake account (#6158) (#6160)

(cherry picked from commit 284273a73f)
This commit is contained in:
mergify[bot]
2019-10-01 09:02:28 -07:00
committed by Michael Vines
parent 2cd832521a
commit effd2fd835

View File

@ -624,6 +624,18 @@ fn process_delegate_stake(
"stake_account_keypair".to_string(),
),
)?;
if rpc_client
.get_account(&stake_account_keypair.pubkey())
.is_ok()
{
return Err(WalletError::BadParameter(format!(
"Unable to delegate. Stake account already exists: {}",
stake_account_keypair.pubkey()
))
.into());
}
let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;
let ixs = stake_instruction::create_stake_account_and_delegate_stake(