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(),
|
||||
payload.unit,
|
||||
payload.amount,
|
||||
quote_expiry,
|
||||
create_invoice_response.expiry.unwrap_or(0),
|
||||
create_invoice_response.request_lookup_id,
|
||||
)
|
||||
.await
|
||||
|
||||
@@ -240,10 +240,16 @@ impl MintLightning for Cln {
|
||||
.map_err(Error::from)?;
|
||||
|
||||
match cln_response {
|
||||
cln_rpc::Response::Invoice(invoice_res) => Ok(CreateInvoiceResponse {
|
||||
request_lookup_id: label,
|
||||
request: Bolt11Invoice::from_str(&invoice_res.bolt11)?,
|
||||
}),
|
||||
cln_rpc::Response::Invoice(invoice_res) => {
|
||||
let 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");
|
||||
Err(Error::WrongClnResponse.into())
|
||||
|
||||
@@ -176,9 +176,12 @@ impl MintLightning for FakeWallet {
|
||||
}
|
||||
});
|
||||
|
||||
let expiry = invoice.expires_at().map(|t| t.as_secs());
|
||||
|
||||
Ok(CreateInvoiceResponse {
|
||||
request_lookup_id: label,
|
||||
request: invoice,
|
||||
expiry,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -199,9 +199,13 @@ impl MintLightning for Strike {
|
||||
.invoice_quote(&create_invoice_response.invoice_id)
|
||||
.await?;
|
||||
|
||||
let request: Bolt11Invoice = quote.ln_invoice.parse()?;
|
||||
let expiry = request.expires_at().map(|t| t.as_secs());
|
||||
|
||||
Ok(CreateInvoiceResponse {
|
||||
request_lookup_id: create_invoice_response.invoice_id,
|
||||
request: quote.ln_invoice.parse()?,
|
||||
expiry,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,8 @@ pub struct CreateInvoiceResponse {
|
||||
pub request_lookup_id: String,
|
||||
/// Bolt11 payment request
|
||||
pub request: Bolt11Invoice,
|
||||
/// Unix Expiry of Invoice
|
||||
pub expiry: Option<u64>,
|
||||
}
|
||||
|
||||
/// Pay invoice response
|
||||
|
||||
Reference in New Issue
Block a user