fn create_validator_config_script(
        &self,
        owner_account: AccountAddress,
    ) -> Result<Script, Error> {
        // Retrieve keys from local storage
        let local_storage = self.backends.local.clone().create_storage(LocalStorage)?;
        let consensus_key = ed25519_from_storage(CONSENSUS_KEY, &local_storage)?;
        let fullnode_network_key = x25519_from_storage(FULLNODE_NETWORK_KEY, &local_storage)?;
        let validator_network_key = x25519_from_storage(VALIDATOR_NETWORK_KEY, &local_storage)?;

        // Only supports one address for now
        let addr_idx = 0;

        // Append ln-noise-ik and ln-handshake protocols to base network addresses
        // and encrypt the validator address.
        let validator_address = self
            .validator_address
            .clone()
            .append_prod_protos(validator_network_key, HANDSHAKE_VERSION);
        let raw_validator_address =
            RawNetworkAddress::try_from(&validator_address).map_err(|e| {
                Error::UnexpectedError(format!(
                    "error serializing validator address: \"{}\", error: {}",
                    validator_address, e
                ))
            })?;
        // TODO(davidiw): In genesis this is irrelevant -- afterward we need to obtain the
        // current sequence number by querying the blockchain.
        let sequence_number = 0;
        let enc_validator_address = raw_validator_address.encrypt(
            &TEST_SHARED_VAL_NETADDR_KEY,
            TEST_SHARED_VAL_NETADDR_KEY_VERSION,
            &owner_account,
            sequence_number,
            addr_idx,
        );
        let raw_enc_validator_address = RawEncNetworkAddress::try_from(&enc_validator_address)
            .map_err(|e| {
                Error::UnexpectedError(format!(
                    "error serializing encrypted validator address: {:?}, error: {}",
                    enc_validator_address, e
                ))
            })?;
        let fullnode_address = self
            .fullnode_address
            .clone()
            .append_prod_protos(fullnode_network_key, HANDSHAKE_VERSION);
        let raw_fullnode_address = RawNetworkAddress::try_from(&fullnode_address).map_err(|e| {
            Error::UnexpectedError(format!(
                "error serializing fullnode address: \"{}\", error: {}",
                fullnode_address, e
            ))
        })?;

        // Generate the validator config script
        // TODO(philiphayes): remove network identity pubkey field from struct when
        // transition complete
        Ok(transaction_builder::encode_set_validator_config_script(
            owner_account,
            consensus_key.to_bytes().to_vec(),
            validator_network_key.to_bytes(),
            raw_enc_validator_address.into(),
            fullnode_network_key.to_bytes(),
            raw_fullnode_address.into(),
        ))
    }
/// Creates and returns a validator config script using the keys stored in local storage. The
/// validator address will be the given owner account address.
Creates and returns a validator config script using the keys stored in local storage. The
validator address will be the given owner account address.
Creates and returns a validator config script using the keys stored in local storage . The validator address will be the given owner account address .
fn create_validator_config_script(
        &self,
        owner_account: AccountAddress,
    ) -> Result<Script, Error> {
        // Retrieve keys from local storage
        let local_storage = self.backends.local.clone().create_storage(LocalStorage)?;
        let consensus_key = ed25519_from_storage(CONSENSUS_KEY, &local_storage)?;
        let fullnode_network_key = x25519_from_storage(FULLNODE_NETWORK_KEY, &local_storage)?;
        let validator_network_key = x25519_from_storage(VALIDATOR_NETWORK_KEY, &local_storage)?;
        // Only supports one address for now
        let addr_idx = 0;
        // Append ln-noise-ik and ln-handshake protocols to base network addresses
        // and encrypt the validator address.
        let validator_address = self
            .validator_address
            .clone()
            .append_prod_protos(validator_network_key, HANDSHAKE_VERSION);
        let raw_validator_address =
            RawNetworkAddress::try_from(&validator_address).map_err(|e| {
                Error::UnexpectedError(format!(
                    "error serializing validator address: \"{}\", error: {}",
                    validator_address, e
                ))
            })?;
        // TODO(davidiw): In genesis this is irrelevant -- afterward we need to obtain the
        // current sequence number by querying the blockchain.
        let sequence_number = 0;
        let enc_validator_address = raw_validator_address.encrypt(
            &TEST_SHARED_VAL_NETADDR_KEY,
            TEST_SHARED_VAL_NETADDR_KEY_VERSION,
            &owner_account,
            sequence_number,
            addr_idx,
        );
        let raw_enc_validator_address = RawEncNetworkAddress::try_from(&enc_validator_address)
            .map_err(|e| {
                Error::UnexpectedError(format!(
                    "error serializing encrypted validator address: {:?}, error: {}",
                    enc_validator_address, e
                ))
            })?;
        let fullnode_address = self
            .fullnode_address
            .clone()
            .append_prod_protos(fullnode_network_key, HANDSHAKE_VERSION);
        let raw_fullnode_address = RawNetworkAddress::try_from(&fullnode_address).map_err(|e| {
            Error::UnexpectedError(format!(
                "error serializing fullnode address: \"{}\", error: {}",
                fullnode_address, e
            ))
        })?;
        // Generate the validator config script
        // TODO(philiphayes): remove network identity pubkey field from struct when
        // transition complete
        Ok(transaction_builder::encode_set_validator_config_script(
            owner_account,
            consensus_key.to_bytes().to_vec(),
            validator_network_key.to_bytes(),
            raw_enc_validator_address.into(),
            fullnode_network_key.to_bytes(),
            raw_fullnode_address.into(),
        ))
    }
fn create_validator_config_script ( & self , owner_account : AccountAddress , ) -> Result < Script , Error > { // Retrieve keys from local storage let local_storage = self . backends . local . clone ( ) . create_storage ( LocalStorage ) ? ; let consensus_key = ed25519_from_storage ( CONSENSUS_KEY , & local_storage ) ? ; let fullnode_network_key = x25519_from_storage ( FULLNODE_NETWORK_KEY , & local_storage ) ? ; let validator_network_key = x25519_from_storage ( VALIDATOR_NETWORK_KEY , & local_storage ) ? ; // Only supports one address for now let addr_idx = 0 ; // Append ln-noise-ik and ln-handshake protocols to base network addresses // and encrypt the validator address. let validator_address = self . validator_address . clone ( ) . append_prod_protos ( validator_network_key , HANDSHAKE_VERSION ) ; let raw_validator_address = RawNetworkAddress :: try_from ( & validator_address ) . map_err ( | e | { Error :: UnexpectedError ( format ! ( " \" \" " validator_address e ) ) } ) ? ; // TODO(davidiw): In genesis this is irrelevant -- afterward we need to obtain the // current sequence number by querying the blockchain. let sequence_number = 0 ; let enc_validator_address = raw_validator_address . encrypt ( & TEST_SHARED_VAL_NETADDR_KEY , TEST_SHARED_VAL_NETADDR_KEY_VERSION , & owner_account , sequence_number , addr_idx , ) ; let raw_enc_validator_address = RawEncNetworkAddress :: try_from ( & enc_validator_address ) . map_err ( | e | { Error :: UnexpectedError ( format ! ( " " enc_validator_address e ) ) } ) ? ; let fullnode_address = self . fullnode_address . clone ( ) . append_prod_protos ( fullnode_network_key , HANDSHAKE_VERSION ) ; let raw_fullnode_address = RawNetworkAddress :: try_from ( & fullnode_address ) . map_err ( | e | { Error :: UnexpectedError ( format ! ( " \" \" " fullnode_address e ) ) } ) ? ; // Generate the validator config script // TODO(philiphayes): remove network identity pubkey field from struct when // transition complete Ok ( transaction_builder :: encode_set_validator_config_script ( owner_account , consensus_key . to_bytes ( ) . to_vec ( ) , validator_network_key . to_bytes ( ) , raw_enc_validator_address . into ( ) , fullnode_network_key . to_bytes ( ) , raw_fullnode_address . into ( ) , ) ) }
Creates and returns a validator config script using the keys stored in local storage.
Creates and returns a validator config script using the keys stored in local storage .
&self
owner_account
AccountAddress
&self
owner_account
AccountAddress