Skip to content

Commit 64b1aed

Browse files
committed
regtest: add static loop-in to README.md
1 parent 3083297 commit 64b1aed

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

regtest/README.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,152 @@ $ ./regtest.sh mine 1
145145
2021-03-19T17:19:21Z LOOP_IN SUCCESS 0.005 BTC - P2WSH: bcrt1q4p0pead4tfepm683fff8fl8g3kpx8spjztuquu2sctfzed9rufls2z0g2f (cost: server 71, onchain 7650, offchain 0)
146146
```
147147

148+
# Static Address Loop In
149+
150+
Static Address Loop In is a new loop-in mode that, like Loop In, allows you to
151+
swap your on-chain balance for off-chain (channel) balance, but in contrast to
152+
the legacy loop-in, you can receive the off-chain balance instantly (after funds
153+
were deposited to a static address).
154+
To do so a two-step process is required, the setup and the swap phase.
155+
156+
To setup a static address and deposit funds to it, do the following:
157+
158+
```shell
159+
./regtest.sh loop static new  ✔  11:59:12
160+
161+
WARNING: Be aware that loosing your l402.token file in .loop under your home directory will take your ability to spend funds sent to the static address via loop-ins or withdrawals. You will have to wait until the deposit expires and your loop client sweeps the funds back to your lnd wallet. The deposit expiry could be months in the future.
162+
163+
CONTINUE WITH NEW ADDRESS? (y/n): y
164+
Received a new static loop-in address from the server: bcrt1pzgdmxftg3t6wghl2t72ewqyf3jvy2t85ud6pqsagx0zm9mj8f3aq23v3t4
165+
```
166+
A static address has been created. You can send funds to it across different
167+
transactions. Each transaction output to this address is considered a deposit
168+
that can be used individually or in combination with other deposits to be
169+
swapped for an off-chain payment. Let's create a few deposits and confirm them:
170+
```shell
171+
./regtest.sh lndclient sendcoins --addr bcrt1pzgdmxftg3t6wghl2t72ewqyf3jvy2t85ud6pqsagx0zm9mj8f3aq23v3t4 --amt 250000 --min_confs 0 -f
172+
{
173+
"txid": "86ccc85449957c3472a259e447a9180aff49848f0b957a85c24819a5f432eda7"
174+
}
175+
./regtest.sh lndclient sendcoins --addr bcrt1pzgdmxftg3t6wghl2t72ewqyf3jvy2t85ud6pqsagx0zm9mj8f3aq23v3t4 --amt 250000 --min_confs 0 -f
176+
{
177+
"txid": "09d72c89b2346dc068bb57621463e53637f3c0cca3ba8ebb7fcb2773d7f32ae3"
178+
}
179+
./regtest.sh lndclient sendcoins --addr bcrt1pzgdmxftg3t6wghl2t72ewqyf3jvy2t85ud6pqsagx0zm9mj8f3aq23v3t4 --amt 250000 --min_confs 0 -f
180+
{
181+
"txid": "5405e5cae38f9e4e193f7b5442dd005273e2e1fab8687c42a505c1a333e8884f"
182+
}
183+
184+
./regtest.sh mine 6
185+
```
186+
The loop client logs should show the deposits being confirmed:
187+
```shell
188+
[DBG] SADDR: Received deposit: 5405e5cae38f9e4e193f7b5442dd005273e2e1fab8687c42a505c1a333e8884f:0
189+
[DBG] SADDR: Deposit 5405e5cae38f9e4e193f7b5442dd005273e2e1fab8687c42a505c1a333e8884f:0: NextState: Deposited, PreviousState: , Event: OnStart
190+
[DBG] SADDR: Received deposit: 86ccc85449957c3472a259e447a9180aff49848f0b957a85c24819a5f432eda7:1
191+
[DBG] SADDR: Deposit 86ccc85449957c3472a259e447a9180aff49848f0b957a85c24819a5f432eda7:1: NextState: Deposited, PreviousState: , Event: OnStart
192+
[DBG] SADDR: Received deposit: 09d72c89b2346dc068bb57621463e53637f3c0cca3ba8ebb7fcb2773d7f32ae3:1
193+
[DBG] SADDR: Deposit 09d72c89b2346dc068bb57621463e53637f3c0cca3ba8ebb7fcb2773d7f32ae3:1: NextState: Deposited, PreviousState: , Event: OnStart
194+
```
195+
Let's list the deposits in the loop client:
196+
```shell
197+
./regtest.sh loop static listdeposits --filter deposited  ✔  12:03:37
198+
{
199+
"filtered_deposits": [
200+
{
201+
"id": "5afc81a72464881e66aa6a5d7476b75cae26ea4c74c70424e4a68e63b9708e0c",
202+
"state": "DEPOSITED",
203+
"outpoint": "5405e5cae38f9e4e193f7b5442dd005273e2e1fab8687c42a505c1a333e8884f:0",
204+
"value": "250000",
205+
"confirmation_height": "126",
206+
"blocks_until_expiry": "715"
207+
},
208+
{
209+
"id": "0bf419bb047922afc186021fc186970b0b71db83444b39b0dcad4550014e0ba3",
210+
"state": "DEPOSITED",
211+
"outpoint": "86ccc85449957c3472a259e447a9180aff49848f0b957a85c24819a5f432eda7:1",
212+
"value": "250000",
213+
"confirmation_height": "126",
214+
"blocks_until_expiry": "715"
215+
},
216+
{
217+
"id": "ea969e2ca53b608d4cf9ca8def249d77ee1db444bd3384ae1150ea03bb03dbbd",
218+
"state": "DEPOSITED",
219+
"outpoint": "09d72c89b2346dc068bb57621463e53637f3c0cca3ba8ebb7fcb2773d7f32ae3:1",
220+
"value": "250000",
221+
"confirmation_height": "126",
222+
"blocks_until_expiry": "715"
223+
}
224+
]
225+
}
226+
```
227+
These deposits can now be instantly swapped. Let's use the first one:
228+
```shell
229+
./regtest.sh loop static in --utxo 5405e5cae38f9e4e193f7b5442dd005273e2e1fab8687c42a505c1a333e8884f:0
230+
On-chain fees for static address loop-ins are not included.
231+
They were already paid when the deposits were created.
232+
233+
Previously deposited on-chain: 250000 sat
234+
Receive off-chain: 249614 sat
235+
Estimated total fee: 386 sat
236+
237+
CONTINUE SWAP? (y/n): y
238+
{
239+
"swap_hash": "43ed16958d5a5bf0e6cb9a36eefb1493f39741238f06d6c7b5365c1c5c22d29e",
240+
"state": "SignHtlcTx",
241+
"amount": "250000",
242+
"htlc_cltv": 431,
243+
"quoted_swap_fee_satoshis": "386",
244+
"max_swap_fee_satoshis": "386",
245+
"initiation_height": 131,
246+
"protocol_version": "V0",
247+
"label": "",
248+
"initiator": "loop-cli",
249+
"payment_timeout_seconds": 60
250+
}
251+
```
252+
We see in the client log that the swap instantly succeeds:
253+
```shell
254+
[INF] LOOPD: Loop in quote request received
255+
[INF] LOOPD: Static loop-in request received
256+
[INF] SADDR: StaticAddr loop-in 0000000000000000000000000000000000000000000000000000000000000000: Current: InitHtlcTx
257+
[DBG] SADDR: Deposit 5405e5cae38f9e4e193f7b5442dd005273e2e1fab8687c42a505c1a333e8884f:0: NextState: LoopingIn, PreviousState: Deposited, Event: OnLoopInInitiated
258+
[INF] SADDR: StaticAddr loop-in 43ed16958d5a5bf0e6cb9a36eefb1493f39741238f06d6c7b5365c1c5c22d29e: Current: SignHtlcTx
259+
[INF] SADDR: StaticAddr loop-in 43ed16958d5a5bf0e6cb9a36eefb1493f39741238f06d6c7b5365c1c5c22d29e: Current: MonitorInvoiceAndHtlcTx
260+
[DBG] SADDR: StaticAddr loop-in 43ed16958d5a5bf0e6cb9a36eefb1493f39741238f06d6c7b5365c1c5c22d29e: received off-chain payment update Settled
261+
[INF] SADDR: StaticAddr loop-in 43ed16958d5a5bf0e6cb9a36eefb1493f39741238f06d6c7b5365c1c5c22d29e: Current: PaymentReceived
262+
[DBG] SADDR: Deposit 5405e5cae38f9e4e193f7b5442dd005273e2e1fab8687c42a505c1a333e8884f:0: NextState: LoopedIn, PreviousState: LoopingIn, Event: OnLoopedIn
263+
[INF] SADDR: StaticAddr loop-in 43ed16958d5a5bf0e6cb9a36eefb1493f39741238f06d6c7b5365c1c5c22d29e: Current: Succeeded
264+
```
265+
We can combine the remaining two deposits in another instant swap by specifying
266+
the `--all` flag:
267+
```shell
268+
./regtest.sh loop static in --all  ✔  12:07:28
269+
On-chain fees for static address loop-ins are not included.
270+
They were already paid when the deposits were created.
271+
272+
Previously deposited on-chain: 500000 sat
273+
Receive off-chain: 499302 sat
274+
Estimated total fee: 698 sat
275+
276+
CONTINUE SWAP? (y/n): y
277+
{
278+
"swap_hash": "950a4c0017831dc9934e93faacde1819ed5801d1c7abf6b555dc36908a3b3ca8",
279+
"state": "SignHtlcTx",
280+
"amount": "500000",
281+
"htlc_cltv": 431,
282+
"quoted_swap_fee_satoshis": "698",
283+
"max_swap_fee_satoshis": "698",
284+
"initiation_height": 131,
285+
"protocol_version": "V0",
286+
"label": "",
287+
"initiator": "loop-cli",
288+
"payment_timeout_seconds": 60
289+
}
290+
```
291+
For more information on the static address loop-in feature, see the
292+
https://docs.lightning.engineering/lightning-network-tools/loop/static-loop-in-addresses
293+
148294
# Using the Loop server in an existing setup
149295
150296
This `docker-compose` is only meant as a demo and quick start help. You can of

0 commit comments

Comments
 (0)