Skip to content

Commit 28c722d

Browse files
committed
multi: make payment address mandatory
Make the payment secret field ('s') mandatory for BOLT11 payment requests, implementing the requirement specified in BOLT11 spec PR lightning/bolts#1242. This enhances privacy by preventing intermediate nodes from probing the destination using payment onions. This commit implements the following changes: - Adds validation in `zpay32` to fail decoding if the 's' field is missing when no blinded path is provided. - Adds a test vector for an invoice missing the 's' field. - Updates existing tests to accommodate the mandatory payment address requirement.
1 parent 867d27d commit 28c722d

File tree

2 files changed

+72
-35
lines changed

2 files changed

+72
-35
lines changed

zpay32/invoice.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,16 @@ func validateInvoice(invoice *Invoice) error {
376376
return fmt.Errorf("net params not set")
377377
}
378378

379-
// The invoice must contain a payment hash.
380-
if invoice.PaymentHash == nil {
379+
// The invoice must contain a payment hash if it does not contain blinded paths.
380+
if len(invoice.BlindedPaymentPaths) == 0 && invoice.PaymentHash == nil {
381381
return fmt.Errorf("no payment hash found")
382382
}
383383

384+
// The invoice must contain a payment address (payment secret).
385+
if invoice.PaymentAddr.IsNone() {
386+
return fmt.Errorf("no payment address found")
387+
}
388+
384389
if len(invoice.RouteHints) != 0 &&
385390
len(invoice.BlindedPaymentPaths) != 0 {
386391

0 commit comments

Comments
 (0)