Struct cfxstore::CfxStore

source ·
pub struct CfxStore { /* private fields */ }
Expand description

Accounts store.

Implementations§

source§

impl CfxStore

source

pub fn open(directory: Box<dyn KeyDirectory>) -> Result<Self, Error>

Open a new accounts store with given key directory backend.

source

pub fn open_with_iterations( directory: Box<dyn KeyDirectory>, iterations: u32 ) -> Result<Self, Error>

Open a new account store with given key directory backend and custom number of iterations.

source

pub fn set_refresh_time(&self, time: Duration)

Modify account refresh timeout - how often they are re-read from KeyDirectory.

Setting this to low values (or 0) will cause new accounts to be picked up quickly, although it may induce heavy disk reads and is not recommended if you manage many keys (say over 10k).

By default refreshing is disabled, so only accounts created using this instance of CfxStore are taken into account.

Trait Implementations§

source§

impl SecretStore for CfxStore

source§

fn raw_secret( &self, account: &StoreAccountRef, password: &Password ) -> Result<OpaqueSecret, Error>

Returns a raw opaque Secret that can be later used to sign a message.
source§

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

Imports existing JSON wallet
source§

fn test_password( &self, account: &StoreAccountRef, password: &Password ) -> Result<bool, Error>

Checks if password matches given account.
source§

fn copy_account( &self, new_store: &dyn SimpleSecretStore, new_vault: SecretVaultRef, account: &StoreAccountRef, password: &Password, new_password: &Password ) -> Result<(), Error>

Copies account between stores and vaults.
source§

fn public( &self, account: &StoreAccountRef, password: &Password ) -> Result<Public, Error>

Returns a public key for given account.
source§

fn uuid(&self, account: &StoreAccountRef) -> Result<Uuid, Error>

Returns uuid of an account.
source§

fn name(&self, account: &StoreAccountRef) -> Result<String, Error>

Returns account’s name.
source§

fn meta(&self, account: &StoreAccountRef) -> Result<String, Error>

Returns account’s metadata.
source§

fn set_name( &self, account_ref: &StoreAccountRef, name: String ) -> Result<(), Error>

Modifies account metadata.
source§

fn set_meta( &self, account_ref: &StoreAccountRef, meta: String ) -> Result<(), Error>

Modifies account name.
source§

fn local_path(&self) -> PathBuf

Returns local path of the store.
source§

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

Lists all found geth accounts.
source§

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

Imports geth accounts to the store/vault.
source§

fn sign_with_secret( &self, secret: &OpaqueSecret, message: &Message ) -> Result<Signature, Error>

Signs a message with raw secret.
source§

impl SimpleSecretStore for CfxStore

source§

fn insert_account( &self, vault: SecretVaultRef, secret: Secret, password: &Password ) -> Result<StoreAccountRef, Error>

Inserts new accounts to the store (or vault) with given password.
source§

fn insert_derived( &self, vault: SecretVaultRef, account_ref: &StoreAccountRef, password: &Password, derivation: Derivation ) -> Result<StoreAccountRef, Error>

Inserts new derived account to the store (or vault) with given password.
source§

fn generate_derived( &self, account_ref: &StoreAccountRef, password: &Password, derivation: Derivation ) -> Result<Address, Error>

Generates new derived account.
source§

fn account_ref(&self, address: &Address) -> Result<StoreAccountRef, Error>

Get reference to some account with given address. This method could be removed if we will guarantee that there is max(1) account for given address.
source§

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

Returns all accounts in this secret store.
source§

fn change_password( &self, account: &StoreAccountRef, old_password: &Password, new_password: &Password ) -> Result<(), Error>

Changes accounts password.
source§

fn export_account( &self, account: &StoreAccountRef, password: &Password ) -> Result<OpaqueKeyFile, Error>

Exports key details for account.
source§

fn remove_account( &self, account: &StoreAccountRef, password: &Password ) -> Result<(), Error>

Entirely removes account from the store and underlying storage.
source§

fn sign( &self, account: &StoreAccountRef, password: &Password, message: &Message ) -> Result<Signature, Error>

Sign a message with given account.
source§

fn sign_derived( &self, account_ref: &StoreAccountRef, password: &Password, derivation: Derivation, message: &Message ) -> Result<Signature, Error>

Sign a message with derived account.
source§

fn agree( &self, account: &StoreAccountRef, password: &Password, other: &Public ) -> Result<Secret, Error>

Agree on shared key.
source§

fn decrypt( &self, account: &StoreAccountRef, password: &Password, shared_mac: &[u8], message: &[u8] ) -> Result<Vec<u8>, Error>

Decrypt a messages with given account.
source§

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

Create new vault with given password
source§

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

Open vault with given password
source§

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

Close vault
source§

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

List all vaults
source§

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

List all currently opened vaults
source§

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

Change vault password
source§

fn change_account_vault( &self, vault: SecretVaultRef, account: StoreAccountRef ) -> Result<StoreAccountRef, Error>

Cnage account’ vault
source§

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

Get vault metadata string.
source§

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