From 9697e602dfa276db75a7d9f5fdb8f3d920bb7374 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Sat, 8 Feb 2025 22:27:32 +0000 Subject: [PATCH] refactor: use Mint check payment status --- .../tests/fake_wallet.rs | 4 +++- crates/cdk/src/mint/start_up_check.rs | 24 ++++--------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/crates/cdk-integration-tests/tests/fake_wallet.rs b/crates/cdk-integration-tests/tests/fake_wallet.rs index 401fea1b..cd5591be 100644 --- a/crates/cdk-integration-tests/tests/fake_wallet.rs +++ b/crates/cdk-integration-tests/tests/fake_wallet.rs @@ -867,7 +867,9 @@ async fn test_fake_mint_input_output_mismatch() -> Result<()> { match response { Err(err) => match err { cdk::Error::UnsupportedUnit => (), - _ => {} + _ => { + bail!("Wrong error returned"); + } }, Ok(_) => { bail!("Should not have allowed to mint with multiple units"); diff --git a/crates/cdk/src/mint/start_up_check.rs b/crates/cdk/src/mint/start_up_check.rs index 39362ff7..5dedd793 100644 --- a/crates/cdk/src/mint/start_up_check.rs +++ b/crates/cdk/src/mint/start_up_check.rs @@ -14,26 +14,10 @@ impl Mint { pub async fn check_pending_mint_quotes(&self) -> Result<(), Error> { let pending_quotes = self.get_pending_mint_quotes().await?; tracing::info!("There are {} pending mint quotes.", pending_quotes.len()); - - for ln in self.ln.values() { - for quote in pending_quotes.iter() { - tracing::debug!("Checking status of mint quote: {}", quote.id); - let lookup_id = quote.request_lookup_id.as_str(); - match ln.check_incoming_invoice_status(lookup_id).await { - Ok(state) => { - if state != quote.state { - tracing::trace!("Mint quote status changed: {}", quote.id); - self.localstore - .update_mint_quote_state("e.id, state) - .await?; - } - } - - Err(err) => { - tracing::warn!("Could not check state of pending invoice: {}", lookup_id); - tracing::error!("{}", err); - } - } + for quote in pending_quotes.iter() { + tracing::debug!("Checking status of mint quote: {}", quote.id); + if let Err(err) = self.check_mint_quote_paid("e.id).await { + tracing::error!("Could not check status of {}, {}", quote.id, err); } } Ok(())