Browse Source

feat: in multimint receive continue on error

thesimplekid 7 months ago
parent
commit
6cd930313e
1 changed files with 18 additions and 6 deletions
  1. 18 6
      crates/cdk/src/wallet/multi_mint_wallet.rs

+ 18 - 6
crates/cdk/src/wallet/multi_mint_wallet.rs

@@ -226,6 +226,8 @@ impl MultiMintWallet {
 
         let mut amount_received = Amount::ZERO;
 
+        let mut mint_errors = None;
+
         // Check that all mints in tokes have wallets
         for (mint_url, proofs) in mint_proofs {
             let wallet_key = WalletKey::new(mint_url.clone(), unit);
@@ -233,20 +235,30 @@ impl MultiMintWallet {
                 return Err(Error::UnknownWallet(wallet_key.clone()));
             }
 
-            let wallet_key = WalletKey::new(mint_url, unit);
+            let wallet_key = WalletKey::new(mint_url.clone(), unit);
             let wallet = self
                 .get_wallet(&wallet_key)
                 .await
                 .ok_or(Error::UnknownWallet(wallet_key.clone()))?;
 
-            let amount = wallet
+            match wallet
                 .receive_proofs(proofs, SplitTarget::default(), p2pk_signing_keys, preimages)
-                .await?;
-
-            amount_received += amount;
+                .await
+            {
+                Ok(amount) => {
+                    amount_received += amount;
+                }
+                Err(err) => {
+                    tracing::error!("Could no receive proofs for mint: {}", err);
+                    mint_errors = Some(err);
+                }
+            }
         }
 
-        Ok(amount_received)
+        match mint_errors {
+            None => Ok(amount_received),
+            Some(err) => Err(err),
+        }
     }
 
     /// Pay an bolt11 invoice from specific wallet