Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include a PaymentContext in PaymentPurpose #2970

Merged
merged 17 commits into from
Apr 18, 2024

Commits on Apr 15, 2024

  1. Refactor handling of InvoiceRequest

    In order to generate and InvoiceSent event, it would be cleaner to have
    one location where a Bolt12Invoice is successfully generated. Refactor
    the handling code to this end and clean-up line length by making some of
    the type conversions more streamlined.
    jkczyz committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    7e085c5 View commit details
    Browse the repository at this point in the history
  2. Refactor handling of Bolt12Invoice

    In order to provide an InvoiceGenerated event, it would be cleaner to
    have one location where a Bolt12Invoice is successfully created.
    Refactor the handling code to this end and clean-up line length by
    making some of the type conversions more streamlined.
    jkczyz committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    e239c92 View commit details
    Browse the repository at this point in the history
  3. Implement Eq and Hash for Bolt12Invoice

    Bolt12Invoice will be added to a new Event::InvoiceGenerated variant.
    These traits along with PartialEq are required to be implemented for any
    type used in an Event.
    jkczyz committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    01814dc View commit details
    Browse the repository at this point in the history

Commits on Apr 18, 2024

  1. Return the invoice when requesting a refund

    When sending an invoice for a refund, information from the invoice may
    be useful for caller. For instance, the payment_hash can be used to
    track whether the refund was paid. Return the invoice to facilitate this
    use case.
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    12c3a24 View commit details
    Browse the repository at this point in the history
  2. Add PaymentContext to payment::ReceiveTlvs

    Providing LDK-specific data in a BlindedPath allows for the data to be
    received with the corresponding payment. This is useful as it can then
    be surfaced in PaymentClaimable events where the user may correlated
    with an Offer, for instance. Define a PaymentContext enum for including
    various context (e.g., offer, refund, static invoice).
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    c881538 View commit details
    Browse the repository at this point in the history
  3. Pass PaymentContext through HTLC processing

    PendingInboundPayment::BlindedReceive includes a PaymentContext, which
    the recipient includes in each blinded path. Included this when
    processing HTLCs in ChannelManager, first into PendingHTLCRouting and
    then to OnionPayload. Later, this will be included in the PaymentPurpose
    when surfaced to user in PaymentClaimable and PaymentClaimed events.
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    9be364f View commit details
    Browse the repository at this point in the history
  4. Define an OfferId for BOLT 12 Offers

    Use a merkle root hash of the offer TLV records to define an offer id.
    Will be included in a BOLT 12 invoice's blinded payment paths in order
    for the recipient to identify which offer the payment is for.
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    b9970ff View commit details
    Browse the repository at this point in the history
  5. Include OfferId in VerifiedInvoiceRequest

    Extract the OfferId from the offer metadata sent back in the
    InvoiceRequest and include it in VerifiedInvoiceRequest. This can be
    used to correspond the eventual payment for the invoice response by
    including it in the invoice's blinded payment paths.
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    ac6d4cb View commit details
    Browse the repository at this point in the history
  6. Include Offer context in blinded payment paths

    When constructing blinded payment paths for a Bolt12Invoice response,
    include the OfferId so that the eventual payment can be correlated with
    the Offer.
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    48d9245 View commit details
    Browse the repository at this point in the history
  7. Include Refund context in blinded payment paths

    When requesting a payment for a refund, include a context in the
    Bolt12Invoice's blinded payment paths indicated it is for such. When the
    eventual payment is received, the user can use the payment hash to
    correlate it with the corresponding Refund.
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    09ce1b5 View commit details
    Browse the repository at this point in the history
  8. Rename InvoicePayment to Bolt11InvoicePayment

    PaymentPurpose will be expanded to include BOLT 12 payment context.
    Rename the InvoicePayment variant accordinly before new variants are
    added.
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    e74f243 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    ef3ec8f View commit details
    Browse the repository at this point in the history
  10. BOLT 12 variants of PaymentPurpose

    In order to provide more context in PaymentClaimable and PaymentClaimed
    events, introduce new variants of PaymentPurpose for use with BOLT 12
    payments. Separate variants are used for offers and refunds. An unknown
    variant is used for backwards compatibility and ease of testing, but is
    otherwise not publicly constructable.
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    54ca54d View commit details
    Browse the repository at this point in the history
  11. Use BOLT 12 PaymentPurpose variants

    When constructing a PaymentPurpose in ChannelManager, use the
    PaymentContext from OnionPayload to determine which variant to
    construct, including those for BOLT 12 payments.
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    0c52ea2 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    b06b2c7 View commit details
    Browse the repository at this point in the history
  13. Include InvoiceRequest fields in PaymentContext

    When receiving a payment, it's useful to know information about the
    InvoiceRequest. Include this data in PaymentContext::Bolt12Offer so
    users can display information about an inbound payment (e.g., the payer
    note).
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    8367e02 View commit details
    Browse the repository at this point in the history
  14. Update PaymentPurpose's payment_preimage docs

    Clarify that payment_preimage should only be used to claim a payment
    when handling Event::PaymentClaimable, not Event::PaymentClaimed.
    jkczyz committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    478911d View commit details
    Browse the repository at this point in the history