getStakeActivation now correctly returns the inactivate lamports for deactivat{ed,ing} stake account in all cases
This commit is contained in:
parent
1aa9215411
commit
06ae906e90
|
@ -1739,24 +1739,24 @@ impl JsonRpcRequestProcessor {
|
||||||
.state()
|
.state()
|
||||||
.map_err(|_| Error::invalid_params("Invalid param: not a stake account".to_string()))?;
|
.map_err(|_| Error::invalid_params("Invalid param: not a stake account".to_string()))?;
|
||||||
let delegation = stake_state.delegation();
|
let delegation = stake_state.delegation();
|
||||||
if delegation.is_none() {
|
|
||||||
match stake_state.meta() {
|
let rent_exempt_reserve = stake_state
|
||||||
None => {
|
.meta()
|
||||||
return Err(Error::invalid_params(
|
.ok_or_else(|| {
|
||||||
"Invalid param: stake account not initialized".to_string(),
|
Error::invalid_params("Invalid param: stake account not initialized".to_string())
|
||||||
));
|
})?
|
||||||
}
|
.rent_exempt_reserve;
|
||||||
Some(meta) => {
|
|
||||||
let rent_exempt_reserve = meta.rent_exempt_reserve;
|
let delegation = match delegation {
|
||||||
return Ok(RpcStakeActivation {
|
None => {
|
||||||
state: StakeActivationState::Inactive,
|
return Ok(RpcStakeActivation {
|
||||||
active: 0,
|
state: StakeActivationState::Inactive,
|
||||||
inactive: stake_account.lamports().saturating_sub(rent_exempt_reserve),
|
active: 0,
|
||||||
});
|
inactive: stake_account.lamports().saturating_sub(rent_exempt_reserve),
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
Some(delegation) => delegation,
|
||||||
let delegation = delegation.unwrap();
|
};
|
||||||
|
|
||||||
let stake_history_account = bank
|
let stake_history_account = bank
|
||||||
.get_account(&stake_history::id())
|
.get_account(&stake_history::id())
|
||||||
|
@ -1782,8 +1782,12 @@ impl JsonRpcRequestProcessor {
|
||||||
let inactive_stake = match stake_activation_state {
|
let inactive_stake = match stake_activation_state {
|
||||||
StakeActivationState::Activating => activating,
|
StakeActivationState::Activating => activating,
|
||||||
StakeActivationState::Active => 0,
|
StakeActivationState::Active => 0,
|
||||||
StakeActivationState::Deactivating => delegation.stake.saturating_sub(effective),
|
StakeActivationState::Deactivating => stake_account
|
||||||
StakeActivationState::Inactive => delegation.stake,
|
.lamports()
|
||||||
|
.saturating_sub(effective + rent_exempt_reserve),
|
||||||
|
StakeActivationState::Inactive => {
|
||||||
|
stake_account.lamports().saturating_sub(rent_exempt_reserve)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Ok(RpcStakeActivation {
|
Ok(RpcStakeActivation {
|
||||||
state: stake_activation_state,
|
state: stake_activation_state,
|
||||||
|
|
Loading…
Reference in New Issue