stake_pool: fix wrong available_for_withdrawal_wo_fee calculation (#2900)

* - fix wrong available_for_withdrawal_wo_fee calculation by prepare_withdraw_accounts

* - fix formatting

* - refactor

* - fix sub issue
This commit is contained in:
Alexander Ray 2022-02-15 21:45:32 +01:00 committed by GitHub
parent 20864c0be7
commit d158bb150c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -1257,7 +1257,9 @@ fn prepare_withdraw_accounts(
(
transient_stake_account_address,
validator.transient_stake_lamports,
validator
.transient_stake_lamports
.saturating_sub(min_balance),
Some(validator.vote_account_address),
)
},
@ -1265,7 +1267,13 @@ fn prepare_withdraw_accounts(
let reserve_stake = rpc_client.get_account(&stake_pool.reserve_stake)?;
accounts.push((stake_pool.reserve_stake, reserve_stake.lamports, None));
accounts.push((
stake_pool.reserve_stake,
reserve_stake.lamports
- rpc_client.get_minimum_balance_for_rent_exemption(STAKE_STATE_LEN)?
- 1,
None,
));
// Prepare the list of accounts to withdraw from
let mut withdraw_from: Vec<WithdrawAccount> = vec![];