Skip to content

Commit 560835c

Browse files
committed
Add check to validate amount_msats vs invoice_request
When an invoice with an amount_msats is different from the invoice_request's amount_msats it's rejected as invalid.
1 parent 9cb38d8 commit 560835c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lightning/src/offers/invoice.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,13 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
13741374
let invoice_request = InvoiceRequestContents::try_from(
13751375
(payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream)
13761376
)?;
1377+
1378+
if let Some(requested_amount_msats) = invoice_request.amount_msats() {
1379+
if amount_msats != requested_amount_msats {
1380+
return Err(Bolt12SemanticError::UnexpectedAmount);
1381+
}
1382+
}
1383+
13771384
Ok(InvoiceContents::ForOffer { invoice_request, fields })
13781385
}
13791386
}

0 commit comments

Comments
 (0)