Skip to main content

Account

Trait Account 

Source
pub trait Account {
    type AccountId: Copy;

    // Required methods
    fn id(&self) -> Self::AccountId;
    fn name(&self) -> Option<&str>;
    fn birthday_height(&self) -> BlockHeight;
    fn source(&self) -> &AccountSource;
    fn ufvk(&self) -> Option<&UnifiedFullViewingKey>;
    fn uivk(&self) -> UnifiedIncomingViewingKey;

    // Provided method
    fn purpose(&self) -> AccountPurpose { ... }
}
Expand description

A set of capabilities that a client account must provide.

An account represents a distinct set of viewing keys within the wallet; the keys for an account must not be shared with any other account in the wallet, and an application managing wallet accounts must ensure that it either maintains spending keys that can be used for spending all outputs detectable by the viewing keys of the account, or for none of them (i.e. the account is view-only.)

Balance information is available for any full-viewing-key based account; for an incoming-viewing-key only account balance cannot be determined because spends cannot be detected, and so balance-related APIs and APIs that rely upon spentness checks MUST be implemented to return errors if invoked for an IVK-only account.

For spending accounts in implementations that support the transparent-key-import feature, care must be taken to ensure that spending keys corresponding to every imported transparent address in an account are maintained by the application.

Required Associated Types§

Required Methods§

Source

fn id(&self) -> Self::AccountId

Returns the unique identifier for the account.

Source

fn name(&self) -> Option<&str>

Returns the human-readable name for the account, if any has been configured.

Source

fn birthday_height(&self) -> BlockHeight

Returns the birthday height for the account.

Source

fn source(&self) -> &AccountSource

Returns whether this account is derived or imported, and the derivation parameters if applicable.

Source

fn ufvk(&self) -> Option<&UnifiedFullViewingKey>

Returns the UFVK that the wallet backend has stored for the account, if any.

Accounts for which this returns None cannot be used in wallet contexts, because they are unable to maintain an accurate balance.

Source

fn uivk(&self) -> UnifiedIncomingViewingKey

Returns the UIVK that the wallet backend has stored for the account.

All accounts are required to have at least an incoming viewing key. This gives no indication about whether an account can be used in a wallet context; for that, use Account::ufvk.

Provided Methods§

Source

fn purpose(&self) -> AccountPurpose

Returns whether the account is a spending account or a view-only account.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<A: Copy> Account for (A, UnifiedFullViewingKey, BlockHeight)

Available on crate features test-dependencies only.
Source§

impl<A: Copy> Account for (A, UnifiedIncomingViewingKey, BlockHeight)

Available on crate features test-dependencies only.

Implementors§

Source§

impl<A: Account> Account for TestAccount<A>

Available on crate features test-dependencies only.