Skip to content

Commit c9549cc

Browse files
authored
Merge pull request #15 from alexbosworth/architecture-diagram
docs: move out architecture diagram
2 parents 211f7b1 + 974da15 commit c9549cc

File tree

2 files changed

+74
-50
lines changed

2 files changed

+74
-50
lines changed

README.md

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -43,56 +43,13 @@ problems. Community support is also available in the
4343
[LND Slack](https://join.slack.com/t/lightningcommunity/shared_invite/enQtMzQ0OTQyNjE5NjU1LWRiMGNmOTZiNzU0MTVmYzc1ZGFkZTUyNzUwOGJjMjYwNWRkNWQzZWE3MTkwZjdjZGE5ZGNiNGVkMzI2MDU4ZTE)
4444
.
4545

46-
## Loop Out Swap (off -> on-chain)
47-
48-
```
49-
loop out 500
50-
|
51-
|
52-
v
53-
.-----------------------------.
54-
| Loop CLI |
55-
| ./cmd/loop |
56-
| |
57-
| |
58-
| .-------------------. | .--------------. .---------------.
59-
| | Loop Client (lib) | | | LND node | | Bitcoin node |
60-
| | ./ |<-------------| |-------------------| |
61-
| | | | | | on-chain | |
62-
| | |------------->| | htlc | |
63-
| | | | off-chain | | | |
64-
| '-------------------' | htlc '--------------' '---------------'
65-
'-----------------|-----------' | ^
66-
| | |
67-
| v |
68-
| .--. .--.
69-
| _ -( )- _ _ -( )- _
70-
| .--,( ),--. .--,( ),--.
71-
initiate| _.-( )-._ _.-( )-._
72-
swap | ( LIGHTNING NETWORK ) ( BITCOIN NETWORK )
73-
| '-._( )_.-' '-._( )_.-'
74-
| '__,( ),__' '__,( ),__'
75-
| - ._(__)_. - - ._(__)_. -
76-
| | ^
77-
| | |
78-
v v |
79-
.--------------------. off-chain .--------------. .---------------.
80-
| Loop Server | htlc | LND node | | Bitcoin node |
81-
| |<-------------| | | |
82-
| | | | on-chain | |
83-
| | | | htlc | |
84-
| |--------------| |----------------->| |
85-
| | | | | |
86-
'--------------------' '--------------' '---------------'
87-
88-
```
89-
90-
## Setup
91-
92-
LND and the swaplet are using go modules. Make sure that the `GO111MODULE` env
93-
variable is set to `on`.
94-
95-
In order to execute a swap, LND needs to be rebuilt with sub servers enabled.
46+
## Setup and Install
47+
48+
LND and the loop client are using Go modules. Make sure that the `GO111MODULE`
49+
env variable is set to `on`.
50+
51+
In order to execute a swap, LND will need to be rebuilt with sub servers
52+
enabled.
9653

9754
### LND
9855

docs/architecture.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Loop Architecture
2+
3+
Lightning Loop's architecture for orchestrating submarine swaps is based on a
4+
client/server concept.
5+
6+
The client has a swap execution daemon `loopd` controlled by a CLI application
7+
`loop` which uses a gRPC API. The client daemon initiates swaps and handles
8+
their progress through swap phases. To manage keys and the connection to the
9+
LN/BTC network layers the client daemon connects to a local lnd wallet.
10+
11+
Client daemons communicate with the Loop server daemon, which is opaque but
12+
operates in a similar way. The server is not a trusted component in this
13+
architecture; the client daemon validates that the terms of the swap are
14+
acceptable and the server cannot access the swap funds unless the swap enters
15+
the "complete" phase.
16+
17+
## Loop Out Swap (off -> on-chain)
18+
19+
Phases:
20+
21+
1. Initiation: Client queries for terms of a swap
22+
2. Fee: Client sends a small fee HTLC that is unrestricted
23+
3. Funding: Client sends a funding HTLC locked to a preimage they generate
24+
4. Payment: Server sends the funds on-chain locked to the funding preimage hash
25+
5. Complete: Client uses the preimage to take the on-chain funds.
26+
6. Final: The server uses the on-chain-revealed preimage to claim funding HTLC
27+
28+
```
29+
loop out 500
30+
|
31+
|
32+
v
33+
.-----------------------------.
34+
| Loop CLI |
35+
| ./cmd/loop |
36+
| |
37+
| |
38+
| .-------------------. | .--------------. .---------------.
39+
| | Loop Client (lib) | | | LND node | | Bitcoin node |
40+
| | ./ |<-------------| |-------------------| |
41+
| | | | | | on-chain | |
42+
| | |------------->| | htlc | |
43+
| | | | off-chain | | | |
44+
| '-------------------' | htlc '--------------' '---------------'
45+
'-----------------|-----------' | ^
46+
| | |
47+
| v |
48+
| .--. .--.
49+
| _ -( )- _ _ -( )- _
50+
| .--,( ),--. .--,( ),--.
51+
initiate| _.-( )-._ _.-( )-._
52+
swap | ( LIGHTNING NETWORK ) ( BITCOIN NETWORK )
53+
| '-._( )_.-' '-._( )_.-'
54+
| '__,( ),__' '__,( ),__'
55+
| - ._(__)_. - - ._(__)_. -
56+
| | ^
57+
| | |
58+
v v |
59+
.--------------------. off-chain .--------------. .---------------.
60+
| Loop Server | htlc | LND node | | Bitcoin node |
61+
| |<-------------| | | |
62+
| | | | on-chain | |
63+
| | | | htlc | |
64+
| |--------------| |----------------->| |
65+
| | | | | |
66+
'--------------------' '--------------' '---------------'
67+
```

0 commit comments

Comments
 (0)