feat: use expiry from created invoice

This commit is contained in:
thesimplekid
2024-08-13 12:35:27 +01:00
parent 24647a0c7e
commit bbd214899f
5 changed files with 20 additions and 5 deletions

View File

@@ -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

View File

@@ -240,10 +240,16 @@ impl MintLightning for Cln {
.map_err(Error::from)?;
match cln_response {
cln_rpc::Response::Invoice(invoice_res) => Ok(CreateInvoiceResponse {
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: Bolt11Invoice::from_str(&invoice_res.bolt11)?,
}),
request,
expiry,
})
}
_ => {
tracing::warn!("CLN returned wrong response kind");
Err(Error::WrongClnResponse.into())

View File

@@ -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,
})
}

View File

@@ -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,
})
}

View File

@@ -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