Skip to content

Support LUD-12 comments (commentAllowed) #27

Description

@Chemaclass

Context

The LNURL-pay params response hard-codes commentAllowed => false and the invoice callback ignores any comment query parameter.

  • src/Invoice/Application/CallbackUrl.php — returns 'commentAllowed' => false with a // TODO: Not implemented yet.
  • src/Invoice/Application/InvoiceGenerator.phpgenerateInvoice() builds the invoice; no comment handling.
  • src/Invoice/Infrastructure/Controller/InvoiceController.php — reads only amount from the request.
  • src/Invoice/InvoiceConfig.php / src/Config/LightningConfig.php — config reader/writer.

Goal

Implement LUD-12 comments: advertise a max comment length in the pay params, accept a comment on the callback, and attach it to the invoice.

Scope / Tasks

  • Add a config setting for the max comment length (e.g. LightningConfig::setCommentAllowed(int $chars), default 0 = disabled) with a matching InvoiceConfig::getCommentAllowed(): int. Wire it through ConfigKey.
  • CallbackUrl::getCallbackUrl() returns commentAllowed => <int> from config instead of the hard-coded false.
  • InvoiceController reads the comment query param and passes it into generateInvoice().
  • InvoiceGenerator validates the comment length against commentAllowed (reject over-length with the LNURL {status:ERROR, reason} shape) and uses the comment as/within the invoice memo.
  • Update the facade/generator return-shape docblocks and the README HTTP API section.

Implementation notes

  • Per LUD-12, commentAllowed is the number of characters accepted (0/absent = not allowed). Enforce the limit server-side.
  • Follow the existing config pattern: private field + fluent setter + jsonSerialize() entry in LightningConfig, get(ConfigKey::…) in InvoiceConfig, both keyed via ConfigKey.
  • Error responses already use {status:ERROR, reason:…} — reuse.

Acceptance criteria

  • With commentAllowed unset, behavior is unchanged (commentAllowed => 0, comment ignored).
  • With it set to N, pay params advertise commentAllowed => N; a ?comment= up to N chars is attached to the invoice; over-length is rejected with an LNURL error.
  • Unit tests cover: advertised value, accepted comment, over-length rejection.
  • composer test-all green.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions