`vote-authorize-voter` now accepts either the vote or withdraw authority
This commit is contained in:
parent
51f5524e2f
commit
c8c3c4359f
|
@ -1383,17 +1383,12 @@ pub fn process_stake_authorize(
|
||||||
};
|
};
|
||||||
if let Some(authorized) = authorized {
|
if let Some(authorized) = authorized {
|
||||||
match authorization_type {
|
match authorization_type {
|
||||||
StakeAuthorize::Staker => {
|
StakeAuthorize::Staker => check_current_authority(
|
||||||
// first check authorized withdrawer
|
&[authorized.withdrawer, authorized.staker],
|
||||||
check_current_authority(&authorized.withdrawer, &authority.pubkey())
|
&authority.pubkey(),
|
||||||
.or_else(|_| {
|
)?,
|
||||||
// ...then check authorized staker. If neither matches, error will
|
|
||||||
// print the stake key as `expected`
|
|
||||||
check_current_authority(&authorized.staker, &authority.pubkey())
|
|
||||||
})?;
|
|
||||||
}
|
|
||||||
StakeAuthorize::Withdrawer => {
|
StakeAuthorize::Withdrawer => {
|
||||||
check_current_authority(&authorized.withdrawer, &authority.pubkey())?;
|
check_current_authority(&[authorized.withdrawer], &authority.pubkey())?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1935,7 +1930,7 @@ pub fn process_stake_set_lockup(
|
||||||
};
|
};
|
||||||
if let Some(lockup) = lockup {
|
if let Some(lockup) = lockup {
|
||||||
if lockup.custodian != Pubkey::default() {
|
if lockup.custodian != Pubkey::default() {
|
||||||
check_current_authority(&lockup.custodian, &custodian.pubkey())?;
|
check_current_authority(&[lockup.custodian], &custodian.pubkey())?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err(CliError::RpcRequestError(format!(
|
return Err(CliError::RpcRequestError(format!(
|
||||||
|
@ -2119,13 +2114,13 @@ fn get_stake_account_state(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn check_current_authority(
|
pub(crate) fn check_current_authority(
|
||||||
account_current_authority: &Pubkey,
|
permitted_authorities: &[Pubkey],
|
||||||
provided_current_authority: &Pubkey,
|
provided_current_authority: &Pubkey,
|
||||||
) -> Result<(), CliError> {
|
) -> Result<(), CliError> {
|
||||||
if account_current_authority != provided_current_authority {
|
if !permitted_authorities.contains(provided_current_authority) {
|
||||||
Err(CliError::RpcRequestError(format!(
|
Err(CliError::RpcRequestError(format!(
|
||||||
"Invalid current authority provided: {:?}, expected {:?}",
|
"Invalid authority provided: {:?}, expected {:?}",
|
||||||
provided_current_authority, account_current_authority
|
provided_current_authority, permitted_authorities
|
||||||
)))
|
)))
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -910,7 +910,10 @@ pub fn process_vote_authorize(
|
||||||
"Invalid vote account state; no authorized voters found".to_string(),
|
"Invalid vote account state; no authorized voters found".to_string(),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
check_current_authority(¤t_authorized_voter, &authorized.pubkey())?;
|
check_current_authority(
|
||||||
|
&[current_authorized_voter, vote_state.authorized_withdrawer],
|
||||||
|
&authorized.pubkey(),
|
||||||
|
)?;
|
||||||
if let Some(signer) = new_authorized_signer {
|
if let Some(signer) = new_authorized_signer {
|
||||||
if signer.is_interactive() {
|
if signer.is_interactive() {
|
||||||
return Err(CliError::BadParameter(format!(
|
return Err(CliError::BadParameter(format!(
|
||||||
|
@ -927,7 +930,7 @@ pub fn process_vote_authorize(
|
||||||
(new_authorized_pubkey, "new_authorized_pubkey".to_string()),
|
(new_authorized_pubkey, "new_authorized_pubkey".to_string()),
|
||||||
)?;
|
)?;
|
||||||
if let Some(vote_state) = vote_state {
|
if let Some(vote_state) = vote_state {
|
||||||
check_current_authority(&vote_state.authorized_withdrawer, &authorized.pubkey())?
|
check_current_authority(&[vote_state.authorized_withdrawer], &authorized.pubkey())?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue