From 006a5c5c88b9255e5df708afd849ee832f7a5d52 Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Mon, 13 Jul 2020 21:49:59 -0600 Subject: [PATCH] CLI: Fix explicitly plumb withdraw_authority through vote-update-validator (cherry picked from commit 22846998894df8de0a7e225b451add68464c5460) --- cli/src/cli.rs | 5 +++++ cli/src/vote.rs | 8 ++++++-- cli/tests/vote.rs | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 00156768e5..fb584fd434 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -407,6 +407,7 @@ pub enum CliCommand { VoteUpdateValidator { vote_account_pubkey: Pubkey, new_identity_account: SignerIndex, + withdraw_authority: SignerIndex, }, VoteUpdateCommission { vote_account_pubkey: Pubkey, @@ -2219,11 +2220,13 @@ pub fn process_command(config: &CliConfig) -> ProcessResult { CliCommand::VoteUpdateValidator { vote_account_pubkey, new_identity_account, + withdraw_authority, } => process_vote_update_validator( &rpc_client, config, &vote_account_pubkey, *new_identity_account, + *withdraw_authority, ), CliCommand::VoteUpdateCommission { vote_account_pubkey, @@ -3505,6 +3508,7 @@ mod tests { config.command = CliCommand::VoteUpdateValidator { vote_account_pubkey: bob_pubkey, new_identity_account: 2, + withdraw_authority: 1, }; let result = process_command(&config); assert!(result.is_ok()); @@ -3724,6 +3728,7 @@ mod tests { config.command = CliCommand::VoteUpdateValidator { vote_account_pubkey: bob_pubkey, new_identity_account: 1, + withdraw_authority: 1, }; assert!(process_command(&config).is_err()); diff --git a/cli/src/vote.rs b/cli/src/vote.rs index 85100b3890..2cd042b74b 100644 --- a/cli/src/vote.rs +++ b/cli/src/vote.rs @@ -340,7 +340,8 @@ pub fn parse_vote_update_validator( pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap(); let (new_identity_account, new_identity_pubkey) = signer_of(matches, "new_identity_account", wallet_manager)?; - let (authorized_withdrawer, _) = signer_of(matches, "authorized_withdrawer", wallet_manager)?; + let (authorized_withdrawer, authorized_withdrawer_pubkey) = + signer_of(matches, "authorized_withdrawer", wallet_manager)?; let payer_provided = None; let signer_info = generate_unique_signers( @@ -354,6 +355,7 @@ pub fn parse_vote_update_validator( command: CliCommand::VoteUpdateValidator { vote_account_pubkey, new_identity_account: signer_info.index_of(new_identity_pubkey).unwrap(), + withdraw_authority: signer_info.index_of(authorized_withdrawer_pubkey).unwrap(), }, signers: signer_info.signers, }) @@ -566,8 +568,9 @@ pub fn process_vote_update_validator( config: &CliConfig, vote_account_pubkey: &Pubkey, new_identity_account: SignerIndex, + withdraw_authority: SignerIndex, ) -> ProcessResult { - let authorized_withdrawer = config.signers[1]; + let authorized_withdrawer = config.signers[withdraw_authority]; let new_identity_account = config.signers[new_identity_account]; let new_identity_pubkey = new_identity_account.pubkey(); check_unique_pubkeys( @@ -934,6 +937,7 @@ mod tests { command: CliCommand::VoteUpdateValidator { vote_account_pubkey: pubkey, new_identity_account: 2, + withdraw_authority: 1, }, signers: vec![ read_keypair_file(&default_keypair_file).unwrap().into(), diff --git a/cli/tests/vote.rs b/cli/tests/vote.rs index b55e80bb1a..71587f534f 100644 --- a/cli/tests/vote.rs +++ b/cli/tests/vote.rs @@ -111,6 +111,7 @@ fn test_vote_authorize_and_withdraw() { config.command = CliCommand::VoteUpdateValidator { vote_account_pubkey, new_identity_account: 2, + withdraw_authority: 1, }; process_command(&config).unwrap();