mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-23 07:35:03 +01:00
feat: use expiry from created invoice
This commit is contained in:
@@ -84,7 +84,7 @@ pub async fn get_mint_bolt11_quote(
|
|||||||
create_invoice_response.request.to_string(),
|
create_invoice_response.request.to_string(),
|
||||||
payload.unit,
|
payload.unit,
|
||||||
payload.amount,
|
payload.amount,
|
||||||
quote_expiry,
|
create_invoice_response.expiry.unwrap_or(0),
|
||||||
create_invoice_response.request_lookup_id,
|
create_invoice_response.request_lookup_id,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -240,10 +240,16 @@ impl MintLightning for Cln {
|
|||||||
.map_err(Error::from)?;
|
.map_err(Error::from)?;
|
||||||
|
|
||||||
match cln_response {
|
match cln_response {
|
||||||
cln_rpc::Response::Invoice(invoice_res) => Ok(CreateInvoiceResponse {
|
cln_rpc::Response::Invoice(invoice_res) => {
|
||||||
request_lookup_id: label,
|
let request = Bolt11Invoice::from_str(&invoice_res.bolt11)?;
|
||||||
request: Bolt11Invoice::from_str(&invoice_res.bolt11)?,
|
let expiry = request.expires_at().map(|t| t.as_secs());
|
||||||
}),
|
|
||||||
|
Ok(CreateInvoiceResponse {
|
||||||
|
request_lookup_id: label,
|
||||||
|
request,
|
||||||
|
expiry,
|
||||||
|
})
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
tracing::warn!("CLN returned wrong response kind");
|
tracing::warn!("CLN returned wrong response kind");
|
||||||
Err(Error::WrongClnResponse.into())
|
Err(Error::WrongClnResponse.into())
|
||||||
|
|||||||
@@ -176,9 +176,12 @@ impl MintLightning for FakeWallet {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let expiry = invoice.expires_at().map(|t| t.as_secs());
|
||||||
|
|
||||||
Ok(CreateInvoiceResponse {
|
Ok(CreateInvoiceResponse {
|
||||||
request_lookup_id: label,
|
request_lookup_id: label,
|
||||||
request: invoice,
|
request: invoice,
|
||||||
|
expiry,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,9 +199,13 @@ impl MintLightning for Strike {
|
|||||||
.invoice_quote(&create_invoice_response.invoice_id)
|
.invoice_quote(&create_invoice_response.invoice_id)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let request: Bolt11Invoice = quote.ln_invoice.parse()?;
|
||||||
|
let expiry = request.expires_at().map(|t| t.as_secs());
|
||||||
|
|
||||||
Ok(CreateInvoiceResponse {
|
Ok(CreateInvoiceResponse {
|
||||||
request_lookup_id: create_invoice_response.invoice_id,
|
request_lookup_id: create_invoice_response.invoice_id,
|
||||||
request: quote.ln_invoice.parse()?,
|
request: quote.ln_invoice.parse()?,
|
||||||
|
expiry,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ pub struct CreateInvoiceResponse {
|
|||||||
pub request_lookup_id: String,
|
pub request_lookup_id: String,
|
||||||
/// Bolt11 payment request
|
/// Bolt11 payment request
|
||||||
pub request: Bolt11Invoice,
|
pub request: Bolt11Invoice,
|
||||||
|
/// Unix Expiry of Invoice
|
||||||
|
pub expiry: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pay invoice response
|
/// Pay invoice response
|
||||||
|
|||||||
Reference in New Issue
Block a user