## Settling the invoice/payment in lightning while the other party is unresponsive

0

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)


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)


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?

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 – 2020-10-26T19:23:45.517

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 – 2020-10-26T19:46:22.523

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 – 2020-10-26T20:25:54.140

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 – 2020-10-26T20:38:10.303

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 – 2020-10-30T00:37:33.540