pub struct AccountProvider { /* private fields */ }
Expand description

Account management. Responsible for unlocking accounts.

Implementations§

source§

impl AccountProvider

source

pub fn new( sstore: Box<dyn SecretStore>, settings: AccountProviderSettings ) -> Self

Creates new account provider.

source

pub fn transient_provider() -> Self

Creates not disk backed provider.

source

pub fn new_account(&self, password: &Password) -> Result<Address, Error>

Creates new random account.

source

pub fn new_account_and_public( &self, password: &Password ) -> Result<(Address, Public), Error>

Creates new random account and returns address and public key

source

pub fn insert_account( &self, secret: Secret, password: &Password ) -> Result<Address, Error>

Inserts new account into underlying store. Does not unlock account!

source

pub fn derive_account( &self, address: &Address, password: Option<Password>, derivation: Derivation, save: bool ) -> Result<Address, SignError>

Generates new derived account based on the existing one If password is not provided, account must be unlocked New account will be created with the same password (if save: true)

source

pub fn import_wallet( &self, json: &[u8], password: &Password, gen_id: bool ) -> Result<Address, Error>

Import a new wallet.

source

pub fn has_account(&self, address: Address) -> bool

Checks whether an account with a given address is present.

source

pub fn accounts(&self) -> Result<Vec<Address>, Error>

Returns addresses of all accounts.

source

pub fn default_account(&self) -> Result<Address, Error>

Returns the address of default account.

source

pub fn addresses_info(&self) -> HashMap<Address, AccountMeta>

Returns each address along with metadata.

source

pub fn set_address_name(&self, account: Address, name: String)

Returns each address along with metadata.

source

pub fn set_address_meta(&self, account: Address, meta: String)

Returns each address along with metadata.

source

pub fn remove_address(&self, addr: Address)

Removes and address from the address book

source

pub fn accounts_info(&self) -> Result<HashMap<Address, AccountMeta>, Error>

Returns each account along with name and meta.

source

pub fn account_meta(&self, address: Address) -> Result<AccountMeta, Error>

Returns each account along with name and meta.

source

pub fn account_public( &self, address: Address, password: &Password ) -> Result<Public, Error>

Returns account public key.

source

pub fn set_account_name( &self, address: Address, name: String ) -> Result<(), Error>

Returns each account along with name and meta.

source

pub fn set_account_meta( &self, address: Address, meta: String ) -> Result<(), Error>

Returns each account along with name and meta.

source

pub fn test_password( &self, address: &Address, password: &Password ) -> Result<bool, Error>

Returns true if the password for account is password. false if not.

source

pub fn kill_account( &self, address: &Address, password: &Password ) -> Result<(), Error>

Permanently removes an account.

source

pub fn change_password( &self, address: &Address, password: Password, new_password: Password ) -> Result<(), Error>

Changes the password of account from password to new_password. Fails if incorrect password given.

source

pub fn export_account( &self, address: &Address, password: Password ) -> Result<KeyFile, Error>

Exports an account for given address.

source

pub fn lock_account(&self, address: Address) -> Result<(), Error>

Lock an account

source

pub fn unlock_account_permanently( &self, account: Address, password: Password ) -> Result<(), Error>

Unlocks account permanently.

source

pub fn unlock_account_temporarily( &self, account: Address, password: Password ) -> Result<(), Error>

Unlocks account temporarily (for one signing).

source

pub fn unlock_account_timed( &self, account: Address, password: Password, duration: Duration ) -> Result<(), Error>

Unlocks account temporarily with a timeout.

source

pub fn is_unlocked(&self, address: &Address) -> bool

Checks if given account is unlocked

source

pub fn is_unlocked_permanently(&self, address: &Address) -> bool

Checks if given account is unlocked permanently

source

pub fn sign( &self, address: Address, password: Option<Password>, message: Message ) -> Result<Signature, SignError>

Signs the message. If password is not provided the account must be unlocked.

source

pub fn sign_derived( &self, address: &Address, password: Option<Password>, derivation: Derivation, message: Message ) -> Result<Signature, SignError>

Signs message using the derived secret. If password is not provided the account must be unlocked.

source

pub fn sign_with_token( &self, address: Address, token: Password, message: Message ) -> Result<(Signature, Password), SignError>

Signs given message with supplied token. Returns a token to use in next signing within this session.

source

pub fn decrypt_with_token( &self, address: Address, token: Password, shared_mac: &[u8], message: &[u8] ) -> Result<(Vec<u8>, Password), SignError>

Decrypts a message with given token. Returns a token to use in next operation for this account.

source

pub fn decrypt( &self, address: Address, password: Option<Password>, shared_mac: &[u8], message: &[u8] ) -> Result<Vec<u8>, SignError>

Decrypts a message. If password is not provided the account must be unlocked.

source

pub fn agree( &self, address: Address, password: Option<Password>, other_public: &Public ) -> Result<Secret, SignError>

Agree on shared key.

source

pub fn list_geth_accounts(&self, testnet: bool) -> Vec<Address>

Returns the underlying SecretStore reference if one exists.

source

pub fn import_geth_accounts( &self, desired: Vec<Address>, testnet: bool ) -> Result<Vec<Address>, Error>

Returns the underlying SecretStore reference if one exists.

source

pub fn create_vault(&self, name: &str, password: &Password) -> Result<(), Error>

Create new vault.

source

pub fn open_vault(&self, name: &str, password: &Password) -> Result<(), Error>

Open existing vault.

source

pub fn close_vault(&self, name: &str) -> Result<(), Error>

Close previously opened vault.

source

pub fn list_vaults(&self) -> Result<Vec<String>, Error>

List all vaults

source

pub fn list_opened_vaults(&self) -> Result<Vec<String>, Error>

List all currently opened vaults

source

pub fn change_vault_password( &self, name: &str, new_password: &Password ) -> Result<(), Error>

Change vault password.

source

pub fn change_vault( &self, address: Address, new_vault: &str ) -> Result<(), Error>

Change vault of the given address.

source

pub fn get_vault_meta(&self, name: &str) -> Result<String, Error>

Get vault metadata string.

source

pub fn set_vault_meta(&self, name: &str, meta: &str) -> Result<(), Error>

Set vault metadata string.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V