Bitcoin Lightning -> Solana
Requirements
lightning invoice has to have a fixed amount
Parties
payee - recipient of the solana/spl token, using intermediary to do the swap
LP node - handling the swap, sends solana or spl token and receives lightning network payment
payer - the one paying on bitcoin lightning network
Process
Payee creates a secret S and payment hash P that is produced by hash of secret H(S)
Payee queries the LP node off-chain, with payment hash P and an amount he wishes the receive, LP node creates a bitcoin lightning invoice using payment hash P, with the amount specified and returns it to payee
Payee sends this lightning invoice to the payer
LP node receives an incoming lightning network payment from payer, but cannot settle it because LP node doesn't know secret S yet.
Payee queries the LP node off-chain to obtain a specific message Mi (initialize) signed by LP node allowing payee to create an HTLC on Solana with funds pulled from LP node's vault, an HTLC is constructed:
paying the funds to payee if he can supply a valid secret S, such that hash of secret H(S) is equal to payment hash P, but only until a specific time in the future - locktime T
refunding the payer, but only after locktime T
NOTE: locktime T is determined by LP node based on lightning invoice's min_cltv_delta - the minimal timeout delta for last lightning network HTLC in chain (last hop of the lightning network payment) as LP node needs to have a knowledge of secret S before then to successfully receive a payment
Successful payment
Upon confirmation of HTLC creation's transaction on Solana, payee submits a second transaction revealing the secret S and claiming the funds from HTLC
LP node observes this transaction on Solana and uses the revealed secret S to settle the lightning network payment.
Payee went offline
LP node waits till the expiry of locktime T and then refunds his funds back from the HTLC
Diagram
Last updated