mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-02 11:45:51 +01:00
Read the latest mint quote status in a transaction to avoid race conditions (#1166)
* Read the latest mint quote status in a transaction to avoid race conditions Fixes #1162 * Reload quote for all cases * Exit on paid invoices only for bolt11
This commit is contained in:
@@ -45,6 +45,20 @@ impl Mint {
|
||||
|
||||
let mut tx = self.localstore.begin_transaction().await?;
|
||||
|
||||
// reload the quote, as it state may have changed
|
||||
*quote = tx
|
||||
.get_mint_quote("e.id)
|
||||
.await?
|
||||
.ok_or(Error::UnknownQuote)?;
|
||||
|
||||
let current_state = quote.state();
|
||||
|
||||
if quote.payment_method == PaymentMethod::Bolt11
|
||||
&& (current_state == MintQuoteState::Issued || current_state == MintQuoteState::Paid)
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
for payment in ln_status {
|
||||
if !quote.payment_ids().contains(&&payment.payment_id)
|
||||
&& payment.payment_amount > Amount::ZERO
|
||||
|
||||
Reference in New Issue
Block a user