Cesar Rodas 2 주 전
부모
커밋
d259f93519
2개의 변경된 파일18개의 추가작업 그리고 18개의 파일을 삭제
  1. 1 1
      crates/cdk/src/wallet/mod.rs
  2. 17 17
      crates/cdk/src/wallet/multi_mint_wallet.rs

+ 1 - 1
crates/cdk/src/wallet/mod.rs

@@ -90,7 +90,7 @@ use crate::nuts::nut00::ProofsMethods;
 /// The CDK [`Wallet`] is a high level cashu wallet.
 ///
 /// A [`Wallet`] is for a single mint and single unit.
-#[derive(Debug, Clone)]
+#[derive(Debug)]
 pub struct Wallet {
     /// Mint Url
     pub mint_url: MintUrl,

+ 17 - 17
crates/cdk/src/wallet/multi_mint_wallet.rs

@@ -1546,14 +1546,7 @@ impl MultiMintWallet {
 
         // Spawn parallel tasks to get quotes from each mint
         for (mint_url, amount) in mint_amounts {
-            let wallets = self.wallets.read().await;
-            let wallet = wallets
-                .get(&mint_url)
-                .ok_or(Error::UnknownMint {
-                    mint_url: mint_url.to_string(),
-                })?
-                .clone();
-            drop(wallets);
+            let wallets = self.wallets.clone();
 
             let bolt11_clone = bolt11.clone();
             let mint_url_clone = mint_url.clone();
@@ -1563,6 +1556,14 @@ impl MultiMintWallet {
             let options = Some(MeltOptions::new_mpp(amount_msat));
 
             let task = spawn(async move {
+                let wallets = wallets.read().await;
+                let wallet = wallets
+                    .get(&mint_url)
+                    .ok_or(Error::UnknownMint {
+                        mint_url: mint_url.to_string(),
+                    })?
+                    .clone();
+                drop(wallets);
                 let quote = wallet.melt_quote(bolt11_clone, options).await;
                 (mint_url_clone, quote)
             });
@@ -1600,18 +1601,17 @@ impl MultiMintWallet {
         let mut tasks = Vec::new();
 
         for (mint_url, quote_id) in quotes {
-            let wallets = self.wallets.read().await;
-            let wallet = wallets
-                .get(&mint_url)
-                .ok_or(Error::UnknownMint {
-                    mint_url: mint_url.to_string(),
-                })?
-                .clone();
-            drop(wallets);
-
             let mint_url_clone = mint_url.clone();
+            let wallets = self.wallets.clone();
 
             let task = spawn(async move {
+                let wallets = wallets.read().await;
+                let wallet = wallets
+                    .get(&mint_url)
+                    .ok_or(Error::UnknownMint {
+                        mint_url: mint_url.to_string(),
+                    })
+                    .expect("xxx");
                 let melted = wallet.melt(&quote_id).await;
                 (mint_url_clone, melted)
             });