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

This commit is contained in:
Michael Vines 2019-09-27 14:35:49 -07:00 committed by GitHub
parent 4c5d0fc51f
commit 284273a73f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -622,6 +622,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(