Withdraw authority no longer implies a custodian (#11302)

* Withdraw authority no longer implies a custodian

Before this change, if the withdraw authority and custodian had
the same public key, then a withdraw authority signature would
imply a custodian signature and lockup would be not be enforced.

After this change, the client's withdraw instruction must
explictly reference a custodian account in its optional sixth
account argument.

Likewise, the fee-payer no longer implies either a withdraw
authority or custodian.

* Fix test

The test was configuring the stake account with the fee-payer as
the withdraw authority, but then passing in a different key to
the withdraw instruction's withdraw authority parameter. It only
worked because the second transaction was signed by the fee-payer.
This commit is contained in:
Greg Fitzgerald
2020-07-31 13:37:53 -06:00
committed by GitHub
parent 0f551d4f75
commit 61d9d219f9
5 changed files with 124 additions and 43 deletions

View File

@ -32,7 +32,7 @@ use solana_stake_program::{
stake_state::{Authorized, Lockup, Meta, StakeAuthorize, StakeState},
};
use solana_vote_program::vote_state::VoteState;
use std::{collections::HashSet, ops::Deref, sync::Arc};
use std::{ops::Deref, sync::Arc};
pub const STAKE_AUTHORITY_ARG: ArgConstant<'static> = ArgConstant {
name: "stake_authority",
@ -1485,7 +1485,7 @@ pub fn build_stake_state(
let (active_stake, activating_stake, deactivating_stake) = stake
.delegation
.stake_activating_and_deactivating(current_epoch, Some(stake_history));
let lockup = if lockup.is_in_force(clock, &HashSet::new()) {
let lockup = if lockup.is_in_force(clock, None) {
Some(lockup.into())
} else {
None
@ -1535,7 +1535,7 @@ pub fn build_stake_state(
authorized,
lockup,
}) => {
let lockup = if lockup.is_in_force(clock, &HashSet::new()) {
let lockup = if lockup.is_in_force(clock, None) {
Some(lockup.into())
} else {
None