From effd2fd83503576577bd7911b7a04b374977ce95 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2019 09:02:28 -0700 Subject: [PATCH] Cleanly error when trying to delegate-stake an existing stake account (#6158) (#6160) (cherry picked from commit 284273a73f76a991018cfda74e05ab971f99e922) --- cli/src/wallet.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/src/wallet.rs b/cli/src/wallet.rs index 623fb25905..bf5e7ca710 100644 --- a/cli/src/wallet.rs +++ b/cli/src/wallet.rs @@ -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(