Lightning Loop's architecture for orchestrating submarine swaps is based on a client/server concept.
The client has a swap execution daemon loopd
controlled by a CLI application
loop
which uses a gRPC API. The client daemon initiates swaps and handles
their progress through swap phases. To manage keys and the connection to the
LN/BTC network layers the client daemon connects to a local lnd wallet.
Client daemons communicate with the Loop server daemon, which is opaque but operates in a similar way. The server is not a trusted component in this architecture; the client daemon validates that the terms of the swap are acceptable and the server cannot access the swap funds unless the swap enters the "complete" phase.
Phases:
loop out 500
|
|
v
.-----------------------------.
| Loop CLI |
| ./cmd/loop |
| |
| |
| .-------------------. | .--------------. .---------------.
| | Loop Client (lib) | | | LND node | | Bitcoin node |
| | ./ |<-------------| |-------------------| |
| | | | | | on-chain | |
| | |------------->| | htlc | |
| | | | off-chain | | | |
| '-------------------' | htlc '--------------' '---------------'
'-----------------|-----------' | ^
| | |
| v |
| .--. .--.
| _ -( )- _ _ -( )- _
| .--,( ),--. .--,( ),--.
initiate| _.-( )-._ _.-( )-._
swap | ( LIGHTNING NETWORK ) ( BITCOIN NETWORK )
| '-._( )_.-' '-._( )_.-'
| '__,( ),__' '__,( ),__'
| - ._(__)_. - - ._(__)_. -
| | ^
| | |
v v |
.--------------------. off-chain .--------------. .---------------.
| Loop Server | htlc | LND node | | Bitcoin node |
| |<-------------| | | |
| | | | on-chain | |
| | | | htlc | |
| |--------------| |----------------->| |
| | | | | |
'--------------------' '--------------' '---------------'