Struct iota_wallet::account_manager::AccountManager
source · [−]pub struct AccountManager {
pub(crate) accounts: Arc<RwLock<Vec<AccountHandle>>>,
pub(crate) background_syncing_status: Arc<AtomicUsize>,
pub(crate) client_options: Arc<RwLock<ClientOptions>>,
pub(crate) coin_type: Arc<AtomicU32>,
pub(crate) secret_manager: Arc<RwLock<SecretManager>>,
pub(crate) event_emitter: Arc<Mutex<EventEmitter>>,
pub(crate) storage_options: StorageOptions,
pub(crate) storage_manager: Arc<Mutex<StorageManager>>,
}
Expand description
The account manager, used to create and get accounts. One account manager can hold many accounts, but they should all share the same secret_manager type with the same seed/mnemonic.
Fields
accounts: Arc<RwLock<Vec<AccountHandle>>>
background_syncing_status: Arc<AtomicUsize>
client_options: Arc<RwLock<ClientOptions>>
coin_type: Arc<AtomicU32>
secret_manager: Arc<RwLock<SecretManager>>
event_emitter: Arc<Mutex<EventEmitter>>
storage_options: StorageOptions
storage_manager: Arc<Mutex<StorageManager>>
Implementations
sourceimpl AccountManager
impl AccountManager
sourcepub async fn recover_accounts(
&self,
account_start_index: u32,
account_gap_limit: u32,
address_gap_limit: u32,
sync_options: Option<SyncOptions>
) -> Result<Vec<AccountHandle>>
pub async fn recover_accounts(
&self,
account_start_index: u32,
account_gap_limit: u32,
address_gap_limit: u32,
sync_options: Option<SyncOptions>
) -> Result<Vec<AccountHandle>>
Find accounts with unspent outputs.
Arguments:
account_start_index
: The index of the first account to search for.account_gap_limit
: The number of accounts to search for, after the last account with unspent outputs.address_gap_limit
: The number of addresses to search for, after the last address with unspent outputs, in each account.sync_options
: Optional parameter to specify the sync options. Theaddress_start_index
andforce_syncing
fields will be overwritten to skip existing addresses.
Returns:
A vector of AccountHandle
sourceasync fn search_new_accounts(
&self,
account_gap_limit: u32,
address_gap_limit: u32,
max_account_index_to_keep: &mut Option<u32>,
sync_options: Option<SyncOptions>
) -> Result<()>
async fn search_new_accounts(
&self,
account_gap_limit: u32,
address_gap_limit: u32,
max_account_index_to_keep: &mut Option<u32>,
sync_options: Option<SyncOptions>
) -> Result<()>
Generate new accounts and search for unspent outputs
sourceimpl AccountManager
impl AccountManager
sourcepub async fn start_background_syncing(
&self,
options: Option<SyncOptions>,
interval: Option<Duration>
) -> Result<()>
pub async fn start_background_syncing(
&self,
options: Option<SyncOptions>,
interval: Option<Duration>
) -> Result<()>
Start the background syncing process for all accounts, default interval is 7 seconds
sourceimpl AccountManager
impl AccountManager
sourcepub async fn get_account<I: Into<AccountIdentifier>>(
&self,
identifier: I
) -> Result<AccountHandle>
pub async fn get_account<I: Into<AccountIdentifier>>(
&self,
identifier: I
) -> Result<AccountHandle>
Get an account with an AccountIdentifier
sourceimpl AccountManager
impl AccountManager
sourcepub async fn get_ledger_nano_status(&self) -> Result<LedgerNanoStatus>
pub async fn get_ledger_nano_status(&self) -> Result<LedgerNanoStatus>
Get the ledger nano status
sourceimpl AccountManager
impl AccountManager
sourcepub async fn set_stronghold_password(&self, password: &str) -> Result<()>
pub async fn set_stronghold_password(&self, password: &str) -> Result<()>
Sets the Stronghold password
sourcepub async fn change_stronghold_password(
&self,
current_password: &str,
new_password: &str
) -> Result<()>
pub async fn change_stronghold_password(
&self,
current_password: &str,
new_password: &str
) -> Result<()>
Change the Stronghold password to another one and also re-encrypt the values in the loaded snapshot with it.
sourcepub async fn set_stronghold_password_clear_interval(
&self,
timeout: Option<Duration>
) -> Result<()>
pub async fn set_stronghold_password_clear_interval(
&self,
timeout: Option<Duration>
) -> Result<()>
Sets the Stronghold password clear interval
sourcepub async fn store_mnemonic(&self, mnemonic: String) -> Result<()>
pub async fn store_mnemonic(&self, mnemonic: String) -> Result<()>
Stores a mnemonic into the Stronghold vault
sourcepub async fn clear_stronghold_password(&self) -> Result<()>
pub async fn clear_stronghold_password(&self) -> Result<()>
Clears the Stronghold password from memory.
sourcepub async fn is_stronghold_password_available(&self) -> Result<bool>
pub async fn is_stronghold_password_available(&self) -> Result<bool>
Checks if the Stronghold password is available.
sourceimpl AccountManager
impl AccountManager
sourcepub async fn backup(
&self,
backup_path: PathBuf,
stronghold_password: String
) -> Result<()>
pub async fn backup(
&self,
backup_path: PathBuf,
stronghold_password: String
) -> Result<()>
Backup the account manager data in a Stronghold file stronghold_password must be the current one when Stronghold is used as SecretManager.
sourcepub async fn restore_backup(
&self,
backup_path: PathBuf,
stronghold_password: String
) -> Result<()>
pub async fn restore_backup(
&self,
backup_path: PathBuf,
stronghold_password: String
) -> Result<()>
Restore a backup from a Stronghold file Replaces client_options, coin_type, secret_manager and accounts. Returns an error if accounts were already created If Stronghold is used as secret_manager, the existing Stronghold file will be overwritten. If a mnemonic was stored, it will be gone.
sourceimpl AccountManager
impl AccountManager
sourcepub async fn verify_integrity(&self) -> Result<()>
pub async fn verify_integrity(&self) -> Result<()>
Checks if there is no missing account for example indexes [0, 1, 3] should panic (for now, later return error, automatically fix?) Also checks for each account if there is a gap in an address list and no address is duplicated
sourceimpl AccountManager
impl AccountManager
sourcepub fn builder() -> AccountManagerBuilder
pub fn builder() -> AccountManagerBuilder
Initialises the account manager builder.
sourcepub fn create_account(&self) -> AccountBuilder
pub fn create_account(&self) -> AccountBuilder
Create a new account
sourcepub async fn get_accounts(&self) -> Result<Vec<AccountHandle>>
pub async fn get_accounts(&self) -> Result<Vec<AccountHandle>>
Get all accounts
sourcepub async fn remove_latest_account(&self) -> Result<()>
pub async fn remove_latest_account(&self) -> Result<()>
Removes the latest account (account with the largest account index).
sourcepub fn get_secret_manager(&self) -> Arc<RwLock<SecretManager>>
pub fn get_secret_manager(&self) -> Arc<RwLock<SecretManager>>
Get the SecretManager
sourcepub async fn set_client_options(&self, options: ClientOptions) -> Result<()>
pub async fn set_client_options(&self, options: ClientOptions) -> Result<()>
Sets the client options for all accounts and sets the new bech32_hrp for the addresses.
sourcepub async fn get_client_options(&self) -> ClientOptions
pub async fn get_client_options(&self) -> ClientOptions
Get the used client options
sourcepub async fn get_node_info(&self) -> Result<NodeInfoWrapper>
pub async fn get_node_info(&self) -> Result<NodeInfoWrapper>
Get the node info
sourcepub async fn balance(&self) -> Result<AccountBalance>
pub async fn balance(&self) -> Result<AccountBalance>
Get the balance of all accounts added together
sourcepub async fn sync(&self, options: Option<SyncOptions>) -> Result<AccountBalance>
pub async fn sync(&self, options: Option<SyncOptions>) -> Result<AccountBalance>
Sync all accounts
sourcepub fn stop_background_syncing(&self) -> Result<()>
pub fn stop_background_syncing(&self) -> Result<()>
Stop the background syncing of the accounts
sourcepub async fn listen<F>(&self, events: Vec<WalletEventType>, handler: F) where
F: Fn(&Event) + 'static + Clone + Send + Sync,
pub async fn listen<F>(&self, events: Vec<WalletEventType>, handler: F) where
F: Fn(&Event) + 'static + Clone + Send + Sync,
Listen to wallet events, empty vec will listen to all events
sourcepub async fn clear_listeners(&self, events: Vec<WalletEventType>)
pub async fn clear_listeners(&self, events: Vec<WalletEventType>)
Remove wallet event listeners, empty vec will remove all listeners
sourcepub fn generate_mnemonic(&self) -> Result<String>
pub fn generate_mnemonic(&self) -> Result<String>
Generates a new random mnemonic.
sourcepub fn verify_mnemonic(&self, mnemonic: &str) -> Result<()>
pub fn verify_mnemonic(&self, mnemonic: &str) -> Result<()>
Verify that a &str is a valid mnemonic.
sourcepub async fn emit_test_event(&self, event: WalletEvent) -> Result<()>
pub async fn emit_test_event(&self, event: WalletEvent) -> Result<()>
Helper function to test events. Emits a provided event with account index 0.
sourcepub async fn delete_accounts_and_database(&self) -> Result<()>
pub async fn delete_accounts_and_database(&self) -> Result<()>
Deletes the accounts and database folder.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for AccountManager
impl Send for AccountManager
impl Sync for AccountManager
impl Unpin for AccountManager
impl !UnwindSafe for AccountManager
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more