Skip to main content

Keyring

Trait Keyring 

Source
pub trait Keyring: Send + Sync {
    // Required methods
    fn keyring_type(&self) -> &str;
    fn serialize(&self) -> Result<Vec<u8>, KeyringError>;
    fn deserialize(data: &[u8]) -> Result<Self, KeyringError>
       where Self: Sized;
    fn add_accounts(
        &mut self,
        private_keys: &[String],
    ) -> Result<Vec<KeyringAccount>, KeyringError>;
    fn get_accounts(&self) -> Vec<KeyringAccount>;
    fn export_account(&self, address: &str) -> Result<String, KeyringError>;
    fn remove_account(&mut self, address: &str) -> Result<(), KeyringError>;
    fn sign_hash(
        &self,
        address: &str,
        hash: &[u8; 32],
    ) -> Result<[u8; 65], KeyringError>;
}

Required Methods§

Source

fn keyring_type(&self) -> &str

Keyring type identifier (e.g., “simple”, “hd”)

Source

fn serialize(&self) -> Result<Vec<u8>, KeyringError>

Serialize keyring state (for encrypted storage)

Source

fn deserialize(data: &[u8]) -> Result<Self, KeyringError>
where Self: Sized,

Deserialize keyring state

Source

fn add_accounts( &mut self, private_keys: &[String], ) -> Result<Vec<KeyringAccount>, KeyringError>

Add accounts (for SimpleKeyring: import private keys)

Source

fn get_accounts(&self) -> Vec<KeyringAccount>

Get all accounts managed by this keyring

Source

fn export_account(&self, address: &str) -> Result<String, KeyringError>

Export a private key for a given address

Source

fn remove_account(&mut self, address: &str) -> Result<(), KeyringError>

Remove an account by address

Source

fn sign_hash( &self, address: &str, hash: &[u8; 32], ) -> Result<[u8; 65], KeyringError>

Sign an arbitrary message hash (32 bytes) with the key for the given address

Implementors§