1

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?

5
  • 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? Oct 26, 2020 at 19:23
  • 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
    Oct 26, 2020 at 19:46
  • 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? Oct 26, 2020 at 20:25
  • 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. Oct 26, 2020 at 20:38
  • 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
    Oct 30, 2020 at 0:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.