cli: enforce rent-exemption balance for stake, vote and program accounts in cli (#6118)

* require minimum balance for stake, vote and program accounts
This commit is contained in:
Parth
2019-10-01 01:14:49 +05:30
committed by GitHub
parent 4fbe36d9c6
commit 2c8c2029d8
8 changed files with 43 additions and 53 deletions

View File

@@ -367,6 +367,16 @@ pub fn process_create_stake_account(
.into());
}
let minimum_balance =
rpc_client.get_minimum_balance_for_rent_exemption(std::mem::size_of::<StakeState>())?;
if lamports < minimum_balance {
Err(WalletError::BadParameter(format!(
"need atleast {} lamports for stake account to be rent exempt, provided lamports: {}",
minimum_balance, lamports
)))?;
}
let ixs = stake_instruction::create_stake_account_with_lockup(
&config.keypair.pubkey(),
stake_account_pubkey,