Skip to content

Commit 21478d1

Browse files
authored
update documentation
1 parent 39e4aec commit 21478d1

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

docs/loop/architecture.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,49 @@ Phases:
6565
| | | | | |
6666
'--------------------' '--------------' '---------------'
6767
```
68+
69+
### Standard Loop-In (on -> off-chain)
70+
71+
The reverse of a Loop-Out. The client sends funds to an on-chain HTLC with a
72+
2-of-2 MuSig2 keyspend path. Once the server detects that the HTLC transaction
73+
is confirmed, it pays the Lightning invoice provided by the client to "loop in"
74+
the funds to their node's channels and sweeps the HTLC. The client cooperates
75+
with the server to cosign the sweep transaction to save on onchain fees.
76+
77+
### Instant Loop-Out
78+
79+
A faster, more efficient Loop-Out that prioritizes a cooperative path, built on
80+
**Reservations** (on-chain UTXOs controlled by a 2-of-2 MuSig2 key between the
81+
client and server).
82+
83+
1. **Cooperative Path ("Sweepless Sweep"):** After the client pays the
84+
off-chain swap invoice, the client and server cooperatively sign a
85+
transaction that spends the reservation UTXO directly to the client's final
86+
destination address. This avoids publishing an HTLC, saving fees and chain
87+
space.
88+
89+
2. **Fallback Path:** If the cooperative path fails, the system falls back to
90+
creating a standard on-chain HTLC from the reservation UTXO, which is then
91+
swept by the client. This ensures the swap remains non-custodial.
92+
93+
### Static Address (for Loop-In)
94+
95+
Provides a permanent, reusable on-chain address for receiving funds that can
96+
then be swapped for an off-chain Lightning payment.
97+
98+
- **Address Type:** The address is a P2TR (Taproot) output with two spending
99+
paths:
100+
1. **Keyspend Path (Cooperative):** The internal key is a 2-of-2 MuSig2
101+
aggregate key held by the client and server. This path is used to
102+
cooperatively sign transactions for performing a Loop-In or withdrawing
103+
funds.
104+
2. **Scriptspend Path (Timeout):** A tapleaf contains a script that allows
105+
the client to unilaterally sweep their funds after a CSV timeout. This
106+
is a safety mechanism ensuring the client never loses access to their
107+
deposits.
108+
109+
- **Loop-In Flow:** When a user wants to loop in funds from this address, the
110+
client and server use the cooperative keyspend path to create and sign an
111+
HTLC transaction, which then follows a standard Loop-In flow. When the
112+
client gets the LN payment, they cooperate with the server to sweep the
113+
deposit directly to the server's wallet instead of publishing the HTLC tx.

0 commit comments

Comments
 (0)