zpay32: document first-wins for repeated n and h fields
What changed, and why it matters
This commit only changes code comments in the zpay32/decode.go file. It updates the explanation for why repeated 'n' and 'h' fields in BOLT 11 invoices are ignored after the first valid one. No actual code behavior was changed, so there is no security impact.
No action needed. This is a non-functional documentation-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies two comment blocks in zpay32/decode.go. Previously, comments said repeated fields were skipped because ‘we have already seen a supported one.’ The new comments clarify that BOLT 11 requires exactly one ‘p’ and one ‘s’ field, and the implementation deliberately keeps the first occurrence. The logic (continue on duplicate, keep first) is unchanged. The change is purely documentation.
Changed components
zpay32/decode.goInspect captured patch +6 / −4
### zpay32/decode.go
@@ -347,17 +347,19 @@ func parseTaggedFields(invoice *Invoice, fields []byte, net *chaincfg.Params) er
case fieldTypeN:
if invoice.Destination != nil {
- // We skip the field if we have already seen a
- // supported one.
+ // BOLT 11 only requires exactly one `p` and
+ // one `s` field, so for a repeated field we
+ // keep the first one we saw.
continue
}
invoice.Destination, err = parseDestination(base32Data)
case fieldTypeH:
if invoice.DescriptionHash != nil {
- // We skip the field if we have already seen a
- // supported one.
+ // BOLT 11 only requires exactly one `p` and
+ // one `s` field, so for a repeated field we
+ // keep the first one we saw.
continue
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.