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

Support paying static invoices #3140

Merged

Commits on Sep 12, 2024

  1. Configuration menu
    Copy the full SHA
    732ee14 View commit details
    Browse the repository at this point in the history
  2. Add MessageContext for async payments.

    This context will be used in reply paths for outbound held_htlc_available
    messages, so we can authenticate the corresponding release_held_htlc messages.
    valentinewallace committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    a3216ac View commit details
    Browse the repository at this point in the history
  3. Pass context into held_htlc_available message handling.

    Useful for using the payment_id within to look up the corresponding outbound
    async payment so we know we can safely release the HTLCs to the now-onlinen
    recipient.
    valentinewallace committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    e162278 View commit details
    Browse the repository at this point in the history
  4. Store AsyncPaymentsMessages for later sending

    Upcoming commits will support sending and receiving held_htlc_available and
    release_held_htlc messages. These messages need to be enqueued so that they can
    be released in ChannelManager's implementation of AsyncPaymentsMessageHandler
    to OnionMessenger for sending.
    valentinewallace committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    3d5d64a View commit details
    Browse the repository at this point in the history

Commits on Sep 13, 2024

  1. Support checking that a static invoice matches an outbound invreq.

    Useful for ensuring that an inbound static invoice matches one of our outbound
    invreqs, otherwise it is an unexpected invoice and should be ignored and not
    paid.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    cff6e34 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ad63a70 View commit details
    Browse the repository at this point in the history
  3. Store async payment data in PendingOutboundPayment.

    Adds a pending outbound payment variant for async payments, which indicates
    that we have received a static invoice to pay and have generated a keysend preimage
    for the eventual payment. When the recipient comes back online, we'll
    transition from this new state to Retryable and actually forward the HTLCs.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    c3ed4a2 View commit details
    Browse the repository at this point in the history
  4. Pass full message context into ChanMan blinded path util.

    Allows us to repurpose this util to create blinded paths in an async payments
    message context while maintaining support for the offers context.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    7fb16ea View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    c976e4c View commit details
    Browse the repository at this point in the history
  6. Support initiating an async payment to a static invoice.

    Supported when the sender is an always-online node. Here we send the initial
    held_htlc_available onion message upon receipt of a static invoice, next we'll
    need to actually send HTLCs upon getting a response to said OM.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    b6f4479 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    28269a7 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    e4d7681 View commit details
    Browse the repository at this point in the history
  9. Set max path len on receipt of static invoice.

    Because we may receive a static invoice to pay days before the recipient
    actually comes back online to receive the payment, it's good to do as many
    checks as we can up-front. Here we ensure that the blinded paths provided
    in the invoice won't cause us to exceed the maximum onion packet size.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    8569830 View commit details
    Browse the repository at this point in the history
  10. Split off send_payment_for_bolt12_invoice_internal util.

    This new util will be able to send to both static and non-static BOLT 12
    invoices.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    69356e7 View commit details
    Browse the repository at this point in the history
  11. Support sending async payments as an always-online sender.

    Async receive is not yet supported.
    
    Here we process inbound release_htlc onion messages, check that they actually
    correspond to one of our outbound payments, and actually forward the HTLCs.
    Valid release_htlc receipt indicates that the recipient has now come online to
    receive.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    0297a1e View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    985e6ac View commit details
    Browse the repository at this point in the history
  13. Support abandoning pending outbound async payments.

    Async payments may have very high expires because we may be waiting for days
    for the recipient to come online, so it's important that users be able to
    abandon these payments early if needed.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    6d415b1 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    7dd1787 View commit details
    Browse the repository at this point in the history
  15. Don't trigger manager persistence on unexpected release_htlc message.

    If someone sends us an unexpected or duplicate release_held_htlc onion message,
    we should simply ignore it and not persist the entire ChannelManager in
    response.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    c4f3e25 View commit details
    Browse the repository at this point in the history
  16. Rename Payment{Hash,Id} hmac creation/verification methods for offers.

    We want to specify that these methods are only to be used in an outbound offers
    payment context, because we'll be adding similar methods for the outbound async
    payments context in upcoming commits.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    5a7f523 View commit details
    Browse the repository at this point in the history
  17. Verify inbound ReleaseHeldHtlc messages via hmac.

    See AsyncPaymentsContext::hmac, but this prevents the recipient from
    deanonymizing us. Without this, if they are able to guess the correct payment
    id, then they could create a blinded path to us and confirm our identity.
    
    We also move the PAYMENT_HASH_HMAC_INPUT const to use &[7; 16], which is safe
    because this const was added since the last release. This ordering reads more
    smoothly.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    615eefb View commit details
    Browse the repository at this point in the history
  18. Add new Bolt12PaymentError for failed blinded path creation.

    Currently used when initiating an async payment via held_htlc_available OM. This
    OM needs a reply path back to us, so use this error for our invoice_error OM if
    we fail to create said reply path.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    26d1582 View commit details
    Browse the repository at this point in the history
  19. Document PendingOutboundPayment::{Static}InvoiceReceived semantics.

    While these variants may sound similar, they are very different. One is so
    temporary it's never even persisted to disk, the other is a state we will stay
    in for hours or days. See added docs for more info.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    4bcf53e View commit details
    Browse the repository at this point in the history
  20. Remove payment_release_secret from async payments messages.

    This field isn't necessary because we already authenticate the messages via the
    blinded reply paths payment_id, nonce and HMAC.
    valentinewallace committed Sep 13, 2024
    Configuration menu
    Copy the full SHA
    6e27aec View commit details
    Browse the repository at this point in the history