Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Make getStakeActivation response consistent for undelegated accounts (#…
Browse files Browse the repository at this point in the history
…16038)

(cherry picked from commit 2ec24d4)
  • Loading branch information
CriesofCarrots authored and mergify-bot committed Mar 19, 2021
1 parent 4e3f2c3 commit 7b49d51
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,9 +1157,25 @@ impl JsonRpcRequestProcessor {
let stake_state: StakeState = stake_account
.state()
.map_err(|_| Error::invalid_params("Invalid param: not a stake account".to_string()))?;
let delegation = stake_state.delegation().ok_or_else(|| {
Error::invalid_params("Invalid param: stake account has not been delegated".to_string())
})?;
let delegation = stake_state.delegation();
if delegation.is_none() {
match stake_state.meta() {
None => {
return Err(Error::invalid_params(
"Invalid param: stake account not initialized".to_string(),
));
}
Some(meta) => {
let rent_exempt_reserve = meta.rent_exempt_reserve;
return Ok(RpcStakeActivation {
state: StakeActivationState::Inactive,
active: 0,
inactive: stake_account.lamports().saturating_sub(rent_exempt_reserve),
});
}
}
}
let delegation = delegation.unwrap();

let stake_history_account = bank
.get_account(&stake_history::id())
Expand Down

0 comments on commit 7b49d51

Please sign in to comment.