Skip to content

Implement non-interactive payments by including the preimage in the Sphinx e2e payload #132

@Roasbeef

Description

@Roasbeef

With the current implementation there are two ways to send a payment to a remote node:

  1. Receive an invoice from them, and fulfill that invoice using the SendPayment RPC.
  2. Both the sender and receiver have been started with the --debug_htlc flag, and the sender sends a payment using the hard-coded "debug" preimage value within the HTLC.

A third mode is possible which is similar to the second payment route, but can be used in a "production" network as it'll properly generate a brand new preimage with each payment. This third mode is what I've been calling "sphinx send" (or "onion send", dunno). In this mode the sender generates the preimage for a targeted payment, and includes the pre-image either in the e2e payload, or the per-hop payload within the Sphinx packet embedded within the outgoing HTLC.

It is important to note, that this mode should not be used for retail or b2c payments. This is due to the fact that one is unable to properly obtain assigned proof-of-payment receipt as the sender generates the pre-image instead of the receiver int his mode. However, for paying a friend of LN, or other cases which don't require a verifiable proof-of-payment, then this mode allows for non-interactive payments. If a remote node accepts such payments (which should be denoted it it's global_features vector), then the node can simply advertise it's public key and that is all that's needed for other modes to send them payments.

Steps To Completion

  • Modify the logic in the routing module to accept an additional attribute to routing.LightningPayment request struct which toggles if a sphinx_send should be attempted or not. If so, then the last per-hop-payload should be modified to include a preimage generated by the sending node.

  • Within the peer struct's htlcManager goroutine, when an incoming HTLC arrives and we're the exit node but we can't find the preimage within the invoiceManager, then the per-hop-payload should be checked for a valid pre-image. If one matches, then that should be used to settle the HTLC, and all logic should proceed as normal.

  • The SendPaymentRequest struct should also be modified to add sphinx_send bool. On the server side, this bool should be passed into routing.LightningPayment request struct.

  • Finally, the additional argument should be added to the lncli tool.

  • A set of bits in the global_features should be allocated to signal knowledge of this new feature. If a user attempts to trigger a sphinx_send to a node that doesn't have these bits advertised, then the payment should fail.

A set of integration tests should be added to ensure the proper propagation and handling of sphinx_send payments within the network.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4low prioenhancementImprovements to existing features / behaviourintermediateIssues suitable for developers moderately familiar with the codebase and LNonion routingp2pCode related to the peer-to-peer behaviour

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions