Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 8ad223a

Browse files
committed
add-validator-stake now cleanly errors if non-active stake is provided
1 parent a029447 commit 8ad223a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

stake-pool/cli/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use {
1616
},
1717
solana_client::{
1818
rpc_client::RpcClient,
19-
rpc_config::RpcAccountInfoConfig,
20-
rpc_config::RpcProgramAccountsConfig,
19+
rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig},
2120
rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType},
21+
rpc_response::StakeActivationState,
2222
},
2323
solana_program::{
2424
borsh::get_packed_len, instruction::Instruction, program_pack::Pack, pubkey::Pubkey,
@@ -284,6 +284,10 @@ fn command_vsa_add(
284284
stake: &Pubkey,
285285
token_receiver: &Option<Pubkey>,
286286
) -> CommandResult {
287+
if config.rpc_client.get_stake_activation(*stake, None)?.state != StakeActivationState::Active {
288+
return Err("Stake account is not active.".into());
289+
}
290+
287291
// Get stake pool state
288292
let pool_data = config.rpc_client.get_account_data(&pool)?;
289293
let pool_data = StakePool::try_from_slice(pool_data.as_slice()).unwrap();

0 commit comments

Comments
 (0)