<p>In order for you to see these scripts you'll have to force the channel on-chain, along with the HTLC. Only then will the HTLC be swept using the script, otherwise you'll only see the P2WSH output for the HTLC being added and then removed if the payment succeeds or fails.</p>
<p>Under normal operation you wouldn't therefore see the HTLC. When testing c-lightning we do however force this case, to verify that it is being handled correctly. There are two ways to force on-chain settlement:</p>
<ul>
<li>Write a <a href="https://github.com/ElementsProject/lightning/blob/master/tests/plugins/hold_htlcs.py" rel="nofollow noreferrer">small plugin that simply holds on to the incoming HTLC</a> on either <code>l2</code> or <code>l3</code> depending on which channel you want to observe the script.</li>
<li>If you compiled with <code>DEVELOPER=1</code> you can also provide a file with instructions to disconnect if certain messages are seen. This is a bit more involved, but <a href="https://github.com/ElementsProject/lightning/blob/master/tests/test_misc.py#L325-L388" rel="nofollow noreferrer">here's a test</a> that shows how that works. It instrucs the <code>l1</code> to disconnect as soon as it gets a <code>WIRE_REVOKE_AND_ACK</code> message which completes the addition of the HTLC.</li>
</ul>
<p>Once the HTLC is stuck at some point you can generate a number of blocks until the HTLC timeout approaches, at which point the nodes will publish a unilateral close. Once the channel is closed, and the HTLC timeout expired, the nodes will sweep the HTLC output with the script you're looking for.</p>

CC BY-SA 4.0
2020-07-08T14:53:42.160Z
Thanks for reply. I already installed on my mac, i tried again `./configure --enable-developer` and then `make DEVELOPER=1`, but I get an error: `tools/mockup.sh: line 12: syntax error near unexpected token `;;'` I tried even with just `make` but I get the same error
monkeyUser
CC BY-SA 4.0
2020-07-09T19:09:59.360Z
That sounds a lot like the bash on Mac isn't really compatible with the script. Can you maybe file an issue and we can see how we can fix it.
cdecker
CC BY-SA 4.0
2020-07-07T17:56:16.317Z
2020-07-07T17:56:16.317Z
cdecker
<p>I have three nodes in regtest environment l1, l2, and l3</p>
<p>l1 create a channel with l2</p>
<p>l2 create a channel with l3</p>
<p>l3 create an invoice for l1.
l1 can pays it because use the route l1-<strong>l2</strong>-l3</p>
<p>I presume that here c-lightning use HTLC to accomplish it.</p>
<p>Where can I debug the script?
I'd like to see something like this</p>
<pre><code>IF
  # Payment if you have the secret R
  HASH160 &lt;H&gt; EQUALVERIFY
ELSE
# Refund after timeout.
&lt;locktime&gt; CHECKLOCKTIMEVERIFY DROP &lt;Payee Pubic Key&gt; CHECKSIG
ENDIF
</code></pre>

<lightning-network><core-lightning><hash-time-locked-contract>
Simulate HTLC in regtest c-lightning
monkeyUser
# Simulate HTLC in regtest c-lightning

(Asked by: username_0 on 2020-07-07)

I have three nodes in regtest environment l1, l2, and l3

l1 create a channel with l2

l2 create a channel with l3

l3 create an invoice for l1.
l1 can pays it because use the route l1-**l2**-l3

I presume that here c-lightning use HTLC to accomplish it.

Where can I debug the script?
I'd like to see something like this

```
IF
  # Payment if you have the secret R
  HASH160 <H> EQUALVERIFY
ELSE
# Refund after timeout.
<locktime> CHECKLOCKTIMEVERIFY DROP <Payee Pubic Key> CHECKSIG
ENDIF

```

**Tags:** lightning-network, core-lightning, hash-time-locked-contract


---

## 1 answers

### Answer by username_1 on 2020-07-07. Score: 2

In order for you to see these scripts you'll have to force the channel on-chain, along with the HTLC. Only then will the HTLC be swept using the script, otherwise you'll only see the P2WSH output for the HTLC being added and then removed if the payment succeeds or fails.

Under normal operation you wouldn't therefore see the HTLC. When testing c-lightning we do however force this case, to verify that it is being handled correctly. There are two ways to force on-chain settlement:

* Write a [small plugin that simply holds on to the incoming HTLC](https://github.com/ElementsProject/lightning/blob/master/tests/plugins/hold_htlcs.py) on either `l2` or `l3` depending on which channel you want to observe the script.
* If you compiled with `DEVELOPER=1` you can also provide a file with instructions to disconnect if certain messages are seen. This is a bit more involved, but [here's a test](https://github.com/ElementsProject/lightning/blob/master/tests/test_misc.py#L325-L388) that shows how that works. It instrucs the `l1` to disconnect as soon as it gets a `WIRE_REVOKE_AND_ACK` message which completes the addition of the HTLC.

Once the HTLC is stuck at some point you can generate a number of blocks until the HTLC timeout approaches, at which point the nodes will publish a unilateral close. Once the channel is closed, and the HTLC timeout expired, the nodes will sweep the HTLC output with the script you're looking for.

> **Comments:**
> **username_0**: Thanks for reply. I already installed on my mac, i tried again `./configure --enable-developer` and then `make DEVELOPER=1`, but I get an error: `tools/mockup.sh: line 12: syntax error near unexpected token `;;'` I tried even with just `make` but I get the same error  
> **username_1**: That sounds a lot like the bash on Mac isn't really compatible with the script. Can you maybe file an issue and we can see how we can fix it.  

---

