Return total received amount

This commit is contained in:
David Caseria
2024-05-15 14:17:27 -04:00
parent 79b5349653
commit 12a1a629e9

View File

@@ -921,7 +921,7 @@ impl Wallet {
encoded_token: &str,
signing_keys: Option<Vec<SigningKey>>,
preimages: Option<Vec<String>>,
) -> Result<(), Error> {
) -> Result<Amount, Error> {
let token_data = Token::from_str(encoded_token)?;
let unit = token_data.unit.unwrap_or_default();
@@ -1050,11 +1050,13 @@ impl Wallet {
mint_proofs.extend(p);
}
let mut total_amount = Amount::ZERO;
for (mint, proofs) in received_proofs {
total_amount += proofs.iter().map(|p| p.amount).sum();
self.localstore.add_proofs(mint, proofs).await?;
}
Ok(())
Ok(total_amount)
}
#[instrument(skip(self, proofs), fields(mint_url = %mint_url))]