Async Lightning payments protocol
Introduction
In order to make a payment transaction between two Lightning Network nodes, the two nodes need to be online.
This restriction presents a challenge when the two nodes are not always online, for instance in the case of mobile devices.
The proposed protocol is a way to circumvent this limitation by using LSPs which are always online and can intercept incoming/outgoing HTLCs and break the payment flow to an asynchronous flow (payer and the payee are don't have to be simultaneously online). LSPs have also the advantage of being able to send notifications to their users.
It's an attempt to formalize a solution proposed by Matt Corallo here.
Protocol
Definitions
A
: the payer which is not always online.B
: the payee which is not always online.LSP_a
(respLSP_b
): the LSP thatA
(respB
) is connected to.
Notifications
A
(respB
) can register itself using a platform dependantdeviceid_a
(respdevideid_b
) toLSP_a
(respLSP_b
).LSP_a
(respLSP_b
) can usedeviceid_a
(respdevideid_b
) to send a notification toA
(respB
) in order to askA
(respB
) to go online.- We assume here that
LSP_a
(respLSP_b
) sends a notification toA
(respB
) in the following case:- when an Onion Message needs to be forwarded to
A
(respB
). - when an preimage needs to be sent to
A
in order to settle a payment.
- when an Onion Message needs to be forwarded to
Payment Workflow
A
wants to pay amt
to B
using an invoice created by B
and with a payment_hash h
- this can be the result of an offer message. Naturally,A
is online, but B
may be offline.
A
generates a secret payment idpid
.A
sends a onion message toLSP_a
, asking it to intercept and block the HTLC for the payment with the payment_hashh
. This can be a list of payment_hashes when the payment usesMPP
.A
sends the payment with the payment_hashh
toB
.LSP_a
intercepts and blocks the HTLC(s).A
sends an onion message toB
, containingpid
.A
can go offline.LSP_b
notifiesB
.B
goes online.B
sends a message toA
with apid
value for the fieldpayment_unblock
in theencrypted_data_tlv
tlvstream forLSP_a
LSP_a
intercepts this message and unblocks the HTLC(s) which reachesB
.B
settles the payment and sends back the preimage corresponding toh
.- When the preimage reaches
LSP_a
, it notifiesA
, so whenA
is back online it finally settles the payment.