<p>Given that Alice wants to pay Bob in the lightning network, Bob first creates an invoice (using the python api) for A as follows:</p>
<pre><code>request = invoicesrpc.AddHoldInvoiceRequest(hash=r_hash, value=30000)
response_hold_B_to_A = stub.AddHoldInvoice(request, metadata=[('macaroon', macaroon)])
</code></pre>
<p>and sent the payment request in response_hold_B_to_A to Alice.</p>
<p>Next, Alice sends the payment to Bob as follows:</p>
<pre><code>request = routerrpc.SendPaymentRequest(payment_request=&quot;&lt;bob_invoice&gt;&quot;, timeout_seconds=10000)
for resp in stub.SendPaymentV2(request, metadata=[('macaroon', macaroon)]): print(resp) 
</code></pre>
<p>Let say after Alice sends the payment it will go offline, and Bob before the payment time expires releases its preimage of the invoice as follow:</p>
<pre><code>request = invoicesrpc.SettleInvoiceMsg(preimage=r_preimage)
response = stub.SettleInvoice(request, metadata=[('macaroon', macaroon)])
</code></pre>
<p>At this point, if Bob checks its channels by executing <code>request = lnrpc.ListChannelsRequest()</code> then the htlc is gone and the channel is inactive and the channel balance is NOT updated; However, if Bob checks the status of the invoice by executing:</p>
<pre><code>request = invoicesrpc.SubscribeSingleInvoiceRequest(r_hash=r_hash) 
for response in stub.SubscribeSingleInvoice(request, metadata=[('macaroon', macaroon)])
</code></pre>
<p>it shows that state of the payment is SETTLED.</p>
<p>Now if Bob closes the channel (forcefully) then the balance still not reflected.</p>
<p>In summary Bob's channel balance does not change even though he has done everything right.
Can someone please explain what is happening here? and how can Bob get paid in this situation? Should he go on the blockchain with its preimage and if so how would it do it?</p>

CC BY-SA 4.0
2020-10-26T19:23:45.517Z
Do you assume a direct channel between Alice an Bob? Technically it would not make a difference but just to be precise. Also already saying the result of what you have described should never be possible. Did you experience exactly that or id that an edge case that you tinker about?
Rene Pickhardt
CC BY-SA 4.0
2020-10-26T19:46:22.523Z
Yes, a direct channel between Alice and Bob was created.
We tested the explained steps in the simnet network and we indeed found a mismatch between the output of SubscribeSingleInvoice which said SETTLED and the channel being inactive and no htlcs in the ListChannels command (and no balance update).
So if one party goes offline, what happens to a pending htlc payment that awaits for SettleInvoice (release of the preimage)?
Mohsen
CC BY-SA 4.0
2020-10-26T20:25:54.140Z
have you looked at the logfiles to see if `commitment_signed` messages were sent and the state was moved forward? before the node went down?
Rene Pickhardt
CC BY-SA 4.0
2020-10-26T20:38:10.303Z
Also one more thing. Can you try to generate enough blocks so that the HTLC timelock is passed. The reason why your wallet might not see the balance after the force close is because you did not generate more blocks in simnet and did not collect the HTLC onchain.
Rene Pickhardt
CC BY-SA 4.0
2020-10-30T00:37:33.540Z
I tried it again and the same happened. In fact, after mining many blocks the funds came back to Alice's wallet, even though Bob had settled the invoice using the `stub.SettleInvoice` python api. 
Tried to look into the code to see what the flow is but kind of got lost. I see that the go code is calling the `SettleInvoice` function but cannot find where the implementation of it is. Can you point to the file where SettleInvoice is?
I think the channel arbitrator cannot extract the preimage from the DB to settle the payment on Bob's side.
Mohsen
<lightning-network><payment><invoices>
Settling the invoice/payment in lightning while the other party is unresponsive
Mohsen
# Settling the invoice/payment in lightning while the other party is unresponsive

(Asked by: username_0 on 2020-10-26)

Given that Alice wants to pay Bob in the lightning network, Bob first creates an invoice (using the python api) for A as follows:

```
request = invoicesrpc.AddHoldInvoiceRequest(hash=r_hash, value=30000)
response_hold_B_to_A = stub.AddHoldInvoice(request, metadata=[('macaroon', macaroon)])

```

and sent the payment request in response\_hold\_B\_to\_A to Alice.

Next, Alice sends the payment to Bob as follows:

```
request = routerrpc.SendPaymentRequest(payment_request="<bob_invoice>", timeout_seconds=10000)
for resp in stub.SendPaymentV2(request, metadata=[('macaroon', macaroon)]): print(resp) 

```

Let say after Alice sends the payment it will go offline, and Bob before the payment time expires releases its preimage of the invoice as follow:

```
request = invoicesrpc.SettleInvoiceMsg(preimage=r_preimage)
response = stub.SettleInvoice(request, metadata=[('macaroon', macaroon)])

```

At this point, if Bob checks its channels by executing `request = lnrpc.ListChannelsRequest()` then the htlc is gone and the channel is inactive and the channel balance is NOT updated; However, if Bob checks the status of the invoice by executing:

```
request = invoicesrpc.SubscribeSingleInvoiceRequest(r_hash=r_hash) 
for response in stub.SubscribeSingleInvoice(request, metadata=[('macaroon', macaroon)])

```

it shows that state of the payment is SETTLED.

Now if Bob closes the channel (forcefully) then the balance still not reflected.

In summary Bob's channel balance does not change even though he has done everything right.
Can someone please explain what is happening here? and how can Bob get paid in this situation? Should he go on the blockchain with its preimage and if so how would it do it?

**Tags:** lightning-network, payment, invoices

> **Comments:**
> **username_1**: Do you assume a direct channel between Alice an Bob? Technically it would not make a difference but just to be precise. Also already saying the result of what you have described should never be possible. Did you experience exactly that or id that an edge case that you tinker about?  
> **username_0**: Yes, a direct channel between Alice and Bob was created. We tested the explained steps in the simnet network and we indeed found a mismatch between the output of SubscribeSingleInvoice which said SETTLED and the channel being inactive and no htlcs in the ListChannels command (and no balance update). So if one party goes offline, what happens to a pending htlc payment that awaits for SettleInvoice (release of the preimage)?  
> **username_1**: have you looked at the logfiles to see if `commitment_signed` messages were sent and the state was moved forward? before the node went down?  
> **username_1**: Also one more thing. Can you try to generate enough blocks so that the HTLC timelock is passed. The reason why your wallet might not see the balance after the force close is because you did not generate more blocks in simnet and did not collect the HTLC onchain.  
> **username_0**: I tried it again and the same happened. In fact, after mining many blocks the funds came back to Alice's wallet, even though Bob had settled the invoice using the `stub.SettleInvoice` python api.  Tried to look into the code to see what the flow is but kind of got lost. I see that the go code is calling the `SettleInvoice` function but cannot find where the implementation of it is. Can you point to the file where SettleInvoice is? I think the channel arbitrator cannot extract the preimage from the DB to settle the payment on Bob's side.  

---

## 0 answers

