Skip to content

Commit

Permalink
Merge pull request #1061 from breez/validate-invoice-expiration
Browse files Browse the repository at this point in the history
Validate invoice expiration
  • Loading branch information
roeierez authored Aug 6, 2024
2 parents 45b9903 + eaa86fb commit e4ea881
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libs/sdk-core/src/breez_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ impl BreezServices {
) -> Result<SendPaymentResponse, SendPaymentError> {
self.start_node().await?;
let parsed_invoice = parse_invoice(req.bolt11.as_str())?;
let invoice_expiration = parsed_invoice.timestamp + parsed_invoice.expiry;
let current_time = SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs();
if invoice_expiration < current_time {
return Err(SendPaymentError::InvoiceExpired {
err: format!("Invoice expired at {}", invoice_expiration),
});
}
let invoice_amount_msat = parsed_invoice.amount_msat.unwrap_or_default();
let provided_amount_msat = req.amount_msat.unwrap_or_default();

Expand Down

0 comments on commit e4ea881

Please sign in to comment.