rialo_validator_registry_interface/
pda.rs1use rialo_s_pubkey::Pubkey;
7
8pub const VALIDATOR_INFO_SEED: &[u8] = b"validator-info";
10
11pub const SELF_BOND_SEED: &[u8] = b"self-bond";
13
14pub fn derive_self_bond_address(validator_info_pubkey: &Pubkey) -> Pubkey {
20 let (address, _bump) = Pubkey::find_program_address(
21 &[SELF_BOND_SEED, validator_info_pubkey.as_ref()],
22 &crate::ID,
23 );
24 address
25}
26
27pub fn derive_self_bond_address_with_bump(validator_info_pubkey: &Pubkey) -> (Pubkey, u8) {
29 Pubkey::find_program_address(
30 &[SELF_BOND_SEED, validator_info_pubkey.as_ref()],
31 &crate::ID,
32 )
33}
34
35pub fn derive_validator_info_address(authority_key: &[u8; 96]) -> Pubkey {
37 let (address, _bump) = derive_validator_info_address_with_bump(authority_key);
38 address
39}
40
41pub fn derive_validator_info_address_with_bump(authority_key: &[u8; 96]) -> (Pubkey, u8) {
45 let authority_key_hash = rialo_s_sha256_hasher::hash(authority_key);
46
47 Pubkey::find_program_address(
48 &[VALIDATOR_INFO_SEED, authority_key_hash.as_ref()],
49 &crate::ID,
50 )
51}