From 12a1a629e95e7bdbfbbb08175123f450c387da04 Mon Sep 17 00:00:00 2001 From: David Caseria Date: Wed, 15 May 2024 14:17:27 -0400 Subject: [PATCH] Return total received amount --- crates/cdk/src/wallet.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/cdk/src/wallet.rs b/crates/cdk/src/wallet.rs index a68f5dcc..3a527138 100644 --- a/crates/cdk/src/wallet.rs +++ b/crates/cdk/src/wallet.rs @@ -921,7 +921,7 @@ impl Wallet { encoded_token: &str, signing_keys: Option>, preimages: Option>, - ) -> Result<(), Error> { + ) -> Result { 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))]