Struct openethereum::account_utils::AccountProvider
source · [−]pub struct AccountProvider {
pub(crate) unlocked_secrets: RwLock<RawRwLock, HashMap<StoreAccountRef, OpaqueSecret, RandomState>>,
pub(crate) unlocked: RwLock<RawRwLock, HashMap<StoreAccountRef, AccountData, RandomState>>,
pub(crate) address_book: RwLock<RawRwLock, AddressBook>,
pub(crate) sstore: Box<dyn SecretStore + 'static, Global>,
pub(crate) transient_sstore: EthMultiStore,
pub(crate) unlock_keep_secret: bool,
pub(crate) blacklisted_accounts: Vec<H160, Global>,
}
Expand description
Account management. Responsible for unlocking accounts.
Fields
unlocked_secrets: RwLock<RawRwLock, HashMap<StoreAccountRef, OpaqueSecret, RandomState>>
For performance reasons some methods can re-use unlocked secrets.
unlocked: RwLock<RawRwLock, HashMap<StoreAccountRef, AccountData, RandomState>>
Unlocked account data.
address_book: RwLock<RawRwLock, AddressBook>
Address book.
sstore: Box<dyn SecretStore + 'static, Global>
Accounts on disk
transient_sstore: EthMultiStore
Accounts unlocked with rolling tokens
unlock_keep_secret: bool
When unlocking account permanently we additionally keep a raw secret in memory to increase the performance of transaction signing.
blacklisted_accounts: Vec<H160, Global>
Disallowed accounts.
Implementations
sourceimpl AccountProvider
impl AccountProvider
sourcepub fn new(
sstore: Box<dyn SecretStore + 'static, Global>,
settings: AccountProviderSettings
) -> AccountProvider
pub fn new(
sstore: Box<dyn SecretStore + 'static, Global>,
settings: AccountProviderSettings
) -> AccountProvider
Creates new account provider.
sourcepub fn transient_provider() -> AccountProvider
pub fn transient_provider() -> AccountProvider
Creates not disk backed provider.
sourcepub fn new_account(&self, password: &Password) -> Result<H160, Error>
pub fn new_account(&self, password: &Password) -> Result<H160, Error>
Creates new random account.
sourcepub fn new_account_and_public(
&self,
password: &Password
) -> Result<(H160, H512), Error>
pub fn new_account_and_public(
&self,
password: &Password
) -> Result<(H160, H512), Error>
Creates new random account and returns address and public key
sourcepub fn insert_account(
&self,
secret: Secret,
password: &Password
) -> Result<H160, Error>
pub fn insert_account(
&self,
secret: Secret,
password: &Password
) -> Result<H160, Error>
Inserts new account into underlying store. Does not unlock account!
sourcepub fn derive_account(
&self,
address: &H160,
password: Option<Password>,
derivation: Derivation,
save: bool
) -> Result<H160, SignError>
pub fn derive_account(
&self,
address: &H160,
password: Option<Password>,
derivation: Derivation,
save: bool
) -> Result<H160, 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)
sourcepub fn import_presale(
&self,
presale_json: &[u8],
password: &Password
) -> Result<H160, Error>
pub fn import_presale(
&self,
presale_json: &[u8],
password: &Password
) -> Result<H160, Error>
Import a new presale wallet.
sourcepub fn import_wallet(
&self,
json: &[u8],
password: &Password,
gen_id: bool
) -> Result<H160, Error>
pub fn import_wallet(
&self,
json: &[u8],
password: &Password,
gen_id: bool
) -> Result<H160, Error>
Import a new wallet.
sourcepub fn has_account(&self, address: H160) -> bool
pub fn has_account(&self, address: H160) -> bool
Checks whether an account with a given address is present.
sourcepub fn default_account(&self) -> Result<H160, Error>
pub fn default_account(&self) -> Result<H160, Error>
Returns the address of default account.
sourcepub fn addresses_info(&self) -> HashMap<H160, AccountMeta, RandomState>
pub fn addresses_info(&self) -> HashMap<H160, AccountMeta, RandomState>
Returns each address along with metadata.
sourcepub fn set_address_name(&self, account: H160, name: String)
pub fn set_address_name(&self, account: H160, name: String)
Returns each address along with metadata.
sourcepub fn set_address_meta(&self, account: H160, meta: String)
pub fn set_address_meta(&self, account: H160, meta: String)
Returns each address along with metadata.
sourcepub fn remove_address(&self, addr: H160)
pub fn remove_address(&self, addr: H160)
Removes and address from the address book
sourcepub fn accounts_info(
&self
) -> Result<HashMap<H160, AccountMeta, RandomState>, Error>
pub fn accounts_info(
&self
) -> Result<HashMap<H160, AccountMeta, RandomState>, Error>
Returns each account along with name and meta.
sourcepub fn account_meta(&self, address: H160) -> Result<AccountMeta, Error>
pub fn account_meta(&self, address: H160) -> Result<AccountMeta, Error>
Returns each account along with name and meta.
sourcepub fn account_public(
&self,
address: H160,
password: &Password
) -> Result<H512, Error>
pub fn account_public(
&self,
address: H160,
password: &Password
) -> Result<H512, Error>
Returns account public key.
sourcepub fn set_account_name(&self, address: H160, name: String) -> Result<(), Error>
pub fn set_account_name(&self, address: H160, name: String) -> Result<(), Error>
Returns each account along with name and meta.
sourcepub fn set_account_meta(&self, address: H160, meta: String) -> Result<(), Error>
pub fn set_account_meta(&self, address: H160, meta: String) -> Result<(), Error>
Returns each account along with name and meta.
sourcepub fn test_password(
&self,
address: &H160,
password: &Password
) -> Result<bool, Error>
pub fn test_password(
&self,
address: &H160,
password: &Password
) -> Result<bool, Error>
Returns true
if the password for account
is password
. false
if not.
sourcepub fn kill_account(
&self,
address: &H160,
password: &Password
) -> Result<(), Error>
pub fn kill_account(
&self,
address: &H160,
password: &Password
) -> Result<(), Error>
Permanently removes an account.
sourcepub fn change_password(
&self,
address: &H160,
password: Password,
new_password: Password
) -> Result<(), Error>
pub fn change_password(
&self,
address: &H160,
password: Password,
new_password: Password
) -> Result<(), Error>
Changes the password of account
from password
to new_password
. Fails if incorrect password
given.
sourcepub fn export_account(
&self,
address: &H160,
password: Password
) -> Result<OpaqueKeyFile, Error>
pub fn export_account(
&self,
address: &H160,
password: Password
) -> Result<OpaqueKeyFile, Error>
Exports an account for given address.
sourcepub fn unlock_account_permanently(
&self,
account: H160,
password: Password
) -> Result<(), Error>
pub fn unlock_account_permanently(
&self,
account: H160,
password: Password
) -> Result<(), Error>
Unlocks account permanently.
sourcepub fn unlock_account_temporarily(
&self,
account: H160,
password: Password
) -> Result<(), Error>
pub fn unlock_account_temporarily(
&self,
account: H160,
password: Password
) -> Result<(), Error>
Unlocks account temporarily (for one signing).
sourcepub fn unlock_account_timed(
&self,
account: H160,
password: Password,
duration: Duration
) -> Result<(), Error>
pub fn unlock_account_timed(
&self,
account: H160,
password: Password,
duration: Duration
) -> Result<(), Error>
Unlocks account temporarily with a timeout.
sourcepub fn is_unlocked(&self, address: &H160) -> bool
pub fn is_unlocked(&self, address: &H160) -> bool
Checks if given account is unlocked
sourcepub fn is_unlocked_permanently(&self, address: &H160) -> bool
pub fn is_unlocked_permanently(&self, address: &H160) -> bool
Checks if given account is unlocked permanently
sourcepub fn sign(
&self,
address: H160,
password: Option<Password>,
message: H256
) -> Result<Signature, SignError>
pub fn sign(
&self,
address: H160,
password: Option<Password>,
message: H256
) -> Result<Signature, SignError>
Signs the message. If password is not provided the account must be unlocked.
sourcepub fn sign_derived(
&self,
address: &H160,
password: Option<Password>,
derivation: Derivation,
message: H256
) -> Result<Signature, SignError>
pub fn sign_derived(
&self,
address: &H160,
password: Option<Password>,
derivation: Derivation,
message: H256
) -> Result<Signature, SignError>
Signs message using the derived secret. If password is not provided the account must be unlocked.
sourcepub fn sign_with_token(
&self,
address: H160,
token: Password,
message: H256
) -> Result<(Signature, Password), SignError>
pub fn sign_with_token(
&self,
address: H160,
token: Password,
message: H256
) -> Result<(Signature, Password), SignError>
Signs given message with supplied token. Returns a token to use in next signing within this session.
sourcepub fn decrypt_with_token(
&self,
address: H160,
token: Password,
shared_mac: &[u8],
message: &[u8]
) -> Result<(Vec<u8, Global>, Password), SignError>
pub fn decrypt_with_token(
&self,
address: H160,
token: Password,
shared_mac: &[u8],
message: &[u8]
) -> Result<(Vec<u8, Global>, Password), SignError>
Decrypts a message with given token. Returns a token to use in next operation for this account.
sourcepub fn decrypt(
&self,
address: H160,
password: Option<Password>,
shared_mac: &[u8],
message: &[u8]
) -> Result<Vec<u8, Global>, SignError>
pub fn decrypt(
&self,
address: H160,
password: Option<Password>,
shared_mac: &[u8],
message: &[u8]
) -> Result<Vec<u8, Global>, SignError>
Decrypts a message. If password is not provided the account must be unlocked.
sourcepub fn agree(
&self,
address: H160,
password: Option<Password>,
other_public: &H512
) -> Result<Secret, SignError>
pub fn agree(
&self,
address: H160,
password: Option<Password>,
other_public: &H512
) -> Result<Secret, SignError>
Agree on shared key.
sourcepub fn create_vault(&self, name: &str, password: &Password) -> Result<(), Error>
pub fn create_vault(&self, name: &str, password: &Password) -> Result<(), Error>
Create new vault.
sourcepub fn open_vault(&self, name: &str, password: &Password) -> Result<(), Error>
pub fn open_vault(&self, name: &str, password: &Password) -> Result<(), Error>
Open existing vault.
sourcepub fn list_opened_vaults(&self) -> Result<Vec<String, Global>, Error>
pub fn list_opened_vaults(&self) -> Result<Vec<String, Global>, Error>
List all currently opened vaults
sourcepub fn change_vault_password(
&self,
name: &str,
new_password: &Password
) -> Result<(), Error>
pub fn change_vault_password(
&self,
name: &str,
new_password: &Password
) -> Result<(), Error>
Change vault password.
Auto Trait Implementations
impl !RefUnwindSafe for AccountProvider
impl Send for AccountProvider
impl Sync for AccountProvider
impl Unpin for AccountProvider
impl !UnwindSafe for AccountProvider
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more