Function zcash_client_sqlite::wallet::get_balance[][src]

pub fn get_balance<P>(
    wdb: &WalletDb<P>,
    account: AccountId
) -> Result<Amount, SqliteClientError>
Expand description

Returns the balance for the account, including all mined unspent notes that we know about.

WARNING: This balance is potentially unreliable, as mined notes may become unmined due to chain reorgs. You should generally not show this balance to users without some caveat. Use get_balance_at where you need a more reliable indication of the wallet balance.

Examples

use tempfile::NamedTempFile;
use zcash_primitives::consensus::Network;
use zcash_client_backend::wallet::AccountId;
use zcash_client_sqlite::{
    WalletDb,
    wallet::get_balance,
};

let data_file = NamedTempFile::new().unwrap();
let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
let addr = get_balance(&db, AccountId(0));