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.
Lightning Rod protocol is a way to circumvent this limitation by using an intermediate node which is always online and can securely forward the payment without needing that the payer and the payee are simultaneously online.
See https://medium.com/breez-technology/introducing-lightning-rod-2e0a40d3e44a for a more detailed introduction
A
: the payerpub_a
: the public id ofA
device_id_a
: the device id ofA
used to receive notifications
B
: the payeepub_b
: the public id ofB
device_id_b
: the device id ofB
used to receive notifications
S_A_1
, ..,S_A_i
, ..,S_A_n
(n >= 1
): an ordered list of Lightning Rod service providers chosen byA
.A
pays toS_A_1
, then eachS_A_i
pays toS_A_(i+1)
untiln
is reached.S_B_1
, ..,S_B_j
, ..S_B_m
(m >= 1
): an ordered list of Lightning Rod service providers chosen byB
in addition the the list chosen byA
.S_1
, ..,S_p
is the final list of Lightning Rod service providers:S_A_1
, ..,S_A_n
,S_B_1
, ..,S_B_m
(p = n + m
) renamed in order to simplify the notation.
amt
: the amount thatA
wants to pay toB
. More specifically the amount thatS_A_n
will send toS_B_1
.fee_i
: The feeS_i
will receive to participate to the workflow.amt_i
: the amountS_i
will receive. We haveS_B_1 = amt
andS_(i+1) = S_i - fee_i
.
H
: a cryptographic hash function (sha256)Sign(message)->signature
the node signature function using its private key.Verify(message, signature)->(Ok|Error, pubkey)
verify signature function which returns the public key of the signer if the signature is valid.
This is a service which can notify mobile device users by sending them messages. It's optional.
The Notification service NS
has two endpoints:
register_notification(transaction_id, event_name, device_id)
: this is a way for a device to register itself to receive notifications for a specific event in a transaction.notify_device(transaction_id, event_name)
: tellNS
to send a message to all registered devices for corresponding transaction and event.
A
wants to pay amt
to B
:
A
is online. B
can be offline
A
generates a secret payment idpid
A
sends an asynchronous message toB
using a secure messaging app with the content: "I want to pay youamt
using the secret payment idpid
usingS_A_1
, ..,S_A_n
services"A
callsNS::register_notification(H(pid), "InitiatePayment", device_id_a)
A
can go offline
B
comes online
B
generates a preimagep
and it's hashh = H(p)
and a random secretr
B
calculatesb_proof = H(h || pid || pub_b)
and sign itb_sign = Sign(b_proof)
B
asksS_B_1
what is the fee to forward a payment when receivingamt
, then eachS_B_i
wheni
increases.B
asksS_A_n
what is the fee it needs to receive in order to payamt
, then eachS_A_i
wheni
decreases.B
asksS_i (2<=i<=p)
an invoice for the amountamt
and send it toS_(i-1)
.B
sends an invoice usingh
and the amountamt_p - fee_p
toS_p
. It also sendsH(pid||r)
toS_p
B
sendsH(pid)
,h
,b_proof
andb_sign
toS_1
B
callsNS::register_notification(H(pid||r), "ReceivePayment", device_id_b)
B
can go offline
S_1
calls NS:notify_device(H(pid), "InitiatePayment")
in order to notify A
A
comes online
A
sendsH(pid)
toS_1
.S_1
returns a "hold" invoice with hash:h
and amount:amt_1
.S_1
returns alsob_proof
andb_sign
.A
verifies thatb_sign
is indeed a signature ofb_proof
, and obtainpub_b
fromVerify
.A
verifies thatb_proof = H(h || pid || pub_b)
A
initiates the payment toS_1
A
callsNS::register_notification(H(pid), "SettlePayment", device_id_a)
A
can go offline
- After receiving the payment from
A
,S_1
pays toS_2
the invoice it received fromB
, thenS_i (2<=i<=p)
will do the same. - After receiving the payment from
S_(p-1)
,S_p
callsNS:notify_device(H(pid||r), "ReceivePayment")
B
comes online
B
sends toS
an invoice with hash:h
and amount:amt
S_p
pays the invoice toB
and receivesp
as proof of payment
B
can go offline
S_i (1<=i<=p)
can settle the payment it received using p
.
As soon as S_1
receives p
, it calls NS:notify_device(H(pid), "SettlePayment")
A
comes online
S_1
settle the transaction from A
using p
in order to definitely receive amt_1
from A