diff --git a/programs/vote_api/src/vote_instruction.rs b/programs/vote_api/src/vote_instruction.rs index 28a2beebeebdb6..18d4cad7fa2254 100644 --- a/programs/vote_api/src/vote_instruction.rs +++ b/programs/vote_api/src/vote_instruction.rs @@ -23,6 +23,8 @@ pub enum VoteInstruction { InitializeAccount, /// `Delegate` or `Assign` a vote account to a particular node DelegateStake(Pubkey), + /// Authorize a voter to send signed votes. + AuthorizeVoter(Pubkey), Vote(Vote), /// Clear the credits in the vote account /// * Transaction::keys[0] - the "vote account" @@ -40,6 +42,13 @@ impl VoteInstruction { vec![(vote_id, true)], ) } + pub fn new_authorize_voter(vote_id: Pubkey, authorized_voter_id: Pubkey) -> BuilderInstruction { + BuilderInstruction::new( + id(), + &VoteInstruction::AuthorizeVoter(authorized_voter_id), + vec![(vote_id, true)], + ) + } pub fn new_initialize_account(vote_id: Pubkey) -> BuilderInstruction { BuilderInstruction::new( id(), diff --git a/programs/vote_api/src/vote_transaction.rs b/programs/vote_api/src/vote_transaction.rs index cf90ce083eb00a..e317124cbea07d 100644 --- a/programs/vote_api/src/vote_transaction.rs +++ b/programs/vote_api/src/vote_transaction.rs @@ -73,6 +73,21 @@ impl VoteTransaction { .sign(&[from_keypair, voter_keypair], recent_blockhash) } + /// Choose a voter id to accept signed votes from + pub fn new_authorize_voter( + vote_keypair: &Keypair, + recent_blockhash: Hash, + authorized_voter_id: Pubkey, + fee: u64, + ) -> Transaction { + TransactionBuilder::new(fee) + .push(VoteInstruction::new_authorize_voter( + vote_keypair.pubkey(), + authorized_voter_id, + )) + .sign(&[vote_keypair], recent_blockhash) + } + /// Choose a node id to `delegate` or `assign` this vote account to pub fn delegate_vote_account( vote_keypair: &T,