File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -659,25 +659,21 @@ impl Processor {
659659 return Err ( StakeError :: LockupInForce . into ( ) ) ;
660660 }
661661
662- let withdraw_lamports_and_reserve = checked_add ( withdraw_lamports, reserve) ?;
663662 let stake_account_lamports = source_stake_account_info. lamports ( ) ;
664-
665- // if the stake is active, we mustn't allow the account to go away
666- if is_staked && withdraw_lamports_and_reserve > stake_account_lamports {
667- return Err ( ProgramError :: InsufficientFunds ) ;
668- }
669-
670- // a partial withdrawal must not deplete the reserve
671- if withdraw_lamports != stake_account_lamports
672- && withdraw_lamports_and_reserve > stake_account_lamports
673- {
674- assert ! ( !is_staked) ;
675- return Err ( ProgramError :: InsufficientFunds ) ;
676- }
677-
678- // Deinitialize state upon zero balance
679663 if withdraw_lamports == stake_account_lamports {
664+ // if the stake is active, we mustn't allow the account to go away
665+ if is_staked {
666+ return Err ( ProgramError :: InsufficientFunds ) ;
667+ }
668+
669+ // Deinitialize state upon zero balance
680670 set_stake_state ( source_stake_account_info, & StakeStateV2 :: Uninitialized ) ?;
671+ } else {
672+ // a partial withdrawal must not deplete the reserve
673+ let withdraw_lamports_and_reserve = checked_add ( withdraw_lamports, reserve) ?;
674+ if withdraw_lamports_and_reserve > stake_account_lamports {
675+ return Err ( ProgramError :: InsufficientFunds ) ;
676+ }
681677 }
682678
683679 relocate_lamports (
You can’t perform that action at this time.
0 commit comments