Răsfoiți Sursa

feat: use try proof in swap within melt (#1384)

tsk 2 luni în urmă
părinte
comite
9524bb9a6a

+ 9 - 6
crates/cdk/src/wallet/melt/melt_bolt11.rs

@@ -494,12 +494,15 @@ impl Wallet {
             );
 
             if let Some(swapped) = self
-                .swap(
-                    Some(swap_amount),
-                    SplitTarget::None,
-                    split_result.proofs_to_swap,
-                    None,
-                    false, // fees already accounted for in inputs_total_needed
+                .try_proof_operation_or_reclaim(
+                    split_result.proofs_to_swap.clone(),
+                    self.swap(
+                        Some(swap_amount),
+                        SplitTarget::None,
+                        split_result.proofs_to_swap,
+                        None,
+                        false, // fees already accounted for in inputs_total_needed
+                    ),
                 )
                 .await?
             {

+ 3 - 3
crates/cdk/src/wallet/reclaim.rs

@@ -70,7 +70,7 @@ impl Wallet {
 
     /// Perform an async task, which is assumed to be a foreign mint call that can fail. If fails,
     /// the proofs used in the request are synchronize with the mint and update it locally
-    #[inline(always)]
+    #[inline]
     pub(crate) fn try_proof_operation_or_reclaim<'a, F, R>(
         &'a self,
         inputs: Proofs,
@@ -102,13 +102,13 @@ impl Wallet {
 
                     if swap_reverted_proofs {
                         tracing::error!(
-                            "Attempting to swap exposed {} proofs to new proofs",
+                            "Checking proofs state for proofs {} used in failed op",
                             inputs.len()
                         );
                         for proofs in inputs.chunks(BATCH_PROOF_SIZE) {
                             let _ = self.sync_proofs_state(proofs.to_owned()).await.inspect_err(
                                 |err| {
-                                    tracing::warn!("Failed to swap exposed proofs ({})", err);
+                                    tracing::warn!("Failed to check exposed proofs ({})", err);
                                 },
                             );
                         }