mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-05 05:06:14 +01:00
feat(wallet): total balance
This commit is contained in:
@@ -124,6 +124,22 @@ impl Wallet {
|
||||
self.mnemonic.clone()
|
||||
}
|
||||
|
||||
/// Total Balance of wallet
|
||||
pub async fn total_balance(&self) -> Result<Amount, Error> {
|
||||
let mints = self.localstore.get_mints().await?;
|
||||
let mut balance = Amount::ZERO;
|
||||
|
||||
for (mint, _) in mints {
|
||||
if let Some(proofs) = self.localstore.get_proofs(mint.clone()).await? {
|
||||
let amount = proofs.iter().map(|p| p.amount).sum();
|
||||
|
||||
balance += amount;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(balance)
|
||||
}
|
||||
|
||||
pub async fn mint_balances(&self) -> Result<HashMap<UncheckedUrl, Amount>, Error> {
|
||||
let mints = self.localstore.get_mints().await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user