diff --git a/crates/cdk/src/mint/mod.rs b/crates/cdk/src/mint/mod.rs index 26ffa284..d583ef9e 100644 --- a/crates/cdk/src/mint/mod.rs +++ b/crates/cdk/src/mint/mod.rs @@ -148,11 +148,18 @@ impl Mint { let paid = quote.state == MintQuoteState::Paid; + // Since the pending state is not part of the NUT it should not be part of the response. + // In practice the wallet should not be checking the state of a quote while waiting for the mint response. + let state = match quote.state { + MintQuoteState::Pending => MintQuoteState::Paid, + s => s, + }; + Ok(MintQuoteBolt11Response { quote: quote.id, request: quote.request, paid: Some(paid), - state: quote.state, + state, expiry: Some(quote.expiry), }) } @@ -354,10 +361,18 @@ impl Mint { .await? .is_some() { - tracing::error!( + tracing::info!( "Output has already been signed: {}", blinded_message.blinded_secret ); + tracing::info!( + "Mint {} did not succeed returning quote to Paid state", + mint_request.quote + ); + + self.localstore + .update_mint_quote_state(&mint_request.quote, MintQuoteState::Paid) + .await?; return Err(Error::BlindedMessageAlreadySigned); } } diff --git a/crates/cdk/src/nuts/nut04.rs b/crates/cdk/src/nuts/nut04.rs index 3e880c2a..e59da978 100644 --- a/crates/cdk/src/nuts/nut04.rs +++ b/crates/cdk/src/nuts/nut04.rs @@ -40,6 +40,7 @@ pub enum QuoteState { /// Quote has been paid and wallet can mint Paid, /// Minting is in progress + /// **Note:** This state is to be used internally but is not part of the nut. Pending, /// ecash issued for quote Issued,