-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
With the current implementation there are two ways to send a payment to a remote node:
- Receive an invoice from them, and fulfill that invoice using the
SendPaymentRPC. - Both the sender and receiver have been started with the
--debug_htlcflag, 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
routingmodule to accept an additional attribute torouting.LightningPaymentrequest struct which toggles if asphinx_sendshould 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
peerstruct'shtlcManagergoroutine, when an incoming HTLC arrives and we're the exit node but we can't find the preimage within theinvoiceManager, 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
SendPaymentRequeststruct should also be modified to addsphinx_sendbool. On the server side, this bool should be passed intorouting.LightningPaymentrequest struct. -
Finally, the additional argument should be added to the
lnclitool. -
A set of bits in the
global_featuresshould be allocated to signal knowledge of this new feature. If a user attempts to trigger asphinx_sendto 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.