From abb43c39b1adfac14c2327c1c5bd253fad412a65 Mon Sep 17 00:00:00 2001 From: David Caseria Date: Thu, 3 Jul 2025 16:07:14 -0400 Subject: [PATCH 1/3] Wallet: Get active mint quotes --- crates/cdk/src/wallet/mint.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/cdk/src/wallet/mint.rs b/crates/cdk/src/wallet/mint.rs index 11def1e7..0ef94f29 100644 --- a/crates/cdk/src/wallet/mint.rs +++ b/crates/cdk/src/wallet/mint.rs @@ -141,6 +141,16 @@ impl Wallet { Ok(total_amount) } + /// Get active mint quotes + /// Mint quotes that are not expired and not paid will be returned (including those that are paid but not yet issued). + #[instrument(skip(self))] + pub async fn get_active_mint_quotes(&self) -> Result, Error> { + let mut mint_quotes = self.localstore.get_mint_quotes().await?; + let unix_time = unix_time(); + mint_quotes.retain(|quote| quote.state != MintQuoteState::Paid && quote.expiry > unix_time); + Ok(mint_quotes) + } + /// Mint /// # Synopsis /// ```rust,no_run From 54f53eb8775762161d1444fa15e42e28d13a6601 Mon Sep 17 00:00:00 2001 From: David Caseria Date: Thu, 3 Jul 2025 16:39:12 -0400 Subject: [PATCH 2/3] Fix get_active_mint_quotes logic --- crates/cdk/src/wallet/mint.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/cdk/src/wallet/mint.rs b/crates/cdk/src/wallet/mint.rs index 0ef94f29..033e8a02 100644 --- a/crates/cdk/src/wallet/mint.rs +++ b/crates/cdk/src/wallet/mint.rs @@ -142,12 +142,13 @@ impl Wallet { } /// Get active mint quotes - /// Mint quotes that are not expired and not paid will be returned (including those that are paid but not yet issued). + /// Returns mint quotes that are not expired and not yet issued. #[instrument(skip(self))] pub async fn get_active_mint_quotes(&self) -> Result, Error> { let mut mint_quotes = self.localstore.get_mint_quotes().await?; let unix_time = unix_time(); - mint_quotes.retain(|quote| quote.state != MintQuoteState::Paid && quote.expiry > unix_time); + mint_quotes + .retain(|quote| quote.state != MintQuoteState::Issued && quote.expiry > unix_time); Ok(mint_quotes) } From a3087023764768eb287a7cce0eded9448b1cf616 Mon Sep 17 00:00:00 2001 From: David Caseria Date: Thu, 10 Jul 2025 14:58:00 -0400 Subject: [PATCH 3/3] Filter active mint quotes for wallet --- crates/cdk/src/wallet/mint.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/cdk/src/wallet/mint.rs b/crates/cdk/src/wallet/mint.rs index 033e8a02..58ae07ce 100644 --- a/crates/cdk/src/wallet/mint.rs +++ b/crates/cdk/src/wallet/mint.rs @@ -147,8 +147,11 @@ impl Wallet { pub async fn get_active_mint_quotes(&self) -> Result, Error> { let mut mint_quotes = self.localstore.get_mint_quotes().await?; let unix_time = unix_time(); - mint_quotes - .retain(|quote| quote.state != MintQuoteState::Issued && quote.expiry > unix_time); + mint_quotes.retain(|quote| { + quote.mint_url == self.mint_url + && quote.state != MintQuoteState::Issued + && quote.expiry > unix_time + }); Ok(mint_quotes) }