mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-23 23:55:01 +01:00
feat: check if invoice already paid on melt
feat: check if internal invoice already settled
This commit is contained in:
@@ -213,6 +213,12 @@ pub async fn post_melt_bolt11(
|
||||
|
||||
let (preimage, amount_spent_quote_unit) = match mint_quote {
|
||||
Some(mint_quote) => {
|
||||
if mint_quote.state == MintQuoteState::Issued
|
||||
|| mint_quote.state == MintQuoteState::Paid
|
||||
{
|
||||
return Err(into_response(Error::RequestAlreadyPaid));
|
||||
}
|
||||
|
||||
let mut mint_quote = mint_quote;
|
||||
|
||||
if mint_quote.amount > inputs_amount_quote_unit {
|
||||
@@ -320,7 +326,12 @@ pub async fn post_melt_bolt11(
|
||||
tracing::error!("Could not reset melt quote state: {}", err);
|
||||
}
|
||||
|
||||
return Err(into_response(Error::PaymentFailed));
|
||||
let err = match err {
|
||||
cdk::cdk_lightning::Error::InvoiceAlreadyPaid => Error::RequestAlreadyPaid,
|
||||
_ => Error::PaymentFailed,
|
||||
};
|
||||
|
||||
return Err(into_response(err));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user