Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepayment failing with Failed prepayment: UnknownPaymentHash causes problems #54

Open
OpinionatedGeek opened this issue May 13, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@OpinionatedGeek
Copy link
Contributor

commented May 13, 2019

I tried to do a Loop Out:

2019-05-11 12:48:08 loop out --channel 632050960802447360 --amt 500000

Here's what appeared in the Loop logs:

2019-05-11 12:48:08.872 [INF] CLIENT: Offchain swap destination: 03fb2a0ca79c005f493f1faa83071d3a937cf220d4051dc48b8fe3a087879cf14a
2019-05-11 12:48:12.485 [INF] LOOPD: Loop out request received
2019-05-11 12:48:12.489 [INF] CLIENT: LoopOut 0.005 BTC to bc1qyryv9rnvf7p994xjc69dlyp2vlsdxez8yv2rdh (channel: 0xc00050b4d0)
2019-05-11 12:48:12.494 [INF] CLIENT: Initiating swap request at height 575535
2019-05-11 12:48:12.742 [INF] CLIENT: 8f60fe Htlc address: bc1qdph5mvhpsnra73mnjzvvayhxzuzf8a5f9tzy0eggcz2judrel54qgl2xhm
2019-05-11 12:48:12.751 [INF] CLIENT: 8f60fe state Initiated
2019-05-11 12:48:12.751 [INF] CLIENT: 8f60fe Sending swap payment lnbc4857070n...
2019-05-11 12:48:12.751 [INF] CLIENT: 8f60fe Sending prepayment lnbc279140n1...
2019-05-11 12:48:12.752 [INF] CLIENT: 8f60fe Register conf ntfn for swap script on chain (hh=575535)
2019-05-11 12:48:12.757 [INF] CLIENT: 8f60fe Checking preimage reveal height 575565 exceeded (height 575535)
2019-05-11 12:48:12.757 [INF] CLIENT: 8f60fe Waiting for either htlc on-chain confirmation or  off-chain payment failure
2019-05-11 12:48:24.358 [INF] CLIENT: Received block 575536
2019-05-11 12:48:24.359 [INF] CLIENT: 8f60fe Checking preimage reveal height 575565 exceeded (height 575536)
2019-05-11 12:49:09.866 [WRN] LNDCLIENT: Payment 13bad864df40a754521115300dbe9a826e214e9353982fc7415892c28c8f65a9 failed: UnknownPaymentHash(amt=27914000 mSAT)
2019-05-11 12:49:09.866 [INF] CLIENT: 8f60fe Failed prepayment: UnknownPaymentHash(amt=27914000 mSAT)
2019-05-11 12:49:09.866 [INF] CLIENT: 8f60fe Wait for server pulling off-chain payment(s)

The prepayment failed quickly with Failed prepayment: UnknownPaymentHash, but monitor showed it stuck at 'INITIATED' for days:

2019-05-11T12:48:12Z LOOP_OUT INITIATED 0.005 BTC - bc1qdph5mvhpsnra73mnjzvvayhxzuzf8a5f9tzy0eggcz2judrel54qgl2xhm

Today I restarted my Loop server, and it updated to 'FAILED'.

2019-05-13T10:46:09Z LOOP_OUT FAILED 0.005 BTC - bc1qdph5mvhpsnra73mnjzvvayhxzuzf8a5f9tzy0eggcz2judrel54qgl2xhm

The payments sent out were for: 485,707 sats and 27,914 sats, for a total of: 513,621 sats
Now that channel is being force-closed, and I don't know why. It shows a balance of 489,395sats where before it had a balance of 983,380 sats.

So far it looks like:

  • The payment for 485,707 sats went out
  • The payment for 27,914 sats failed (quickly) with UnknownPaymentHash
  • The Loop server didn't fail the Loop Out when the second payment failed
  • Restarting the Loop server kicked it in to failing the Loop Out
  • Nothing has appeared in my wallet using address: bc1qdph5mvhpsnra73mnjzvvayhxzuzf8a5f9tzy0eggcz2judrel54qgl2xhm
  • Something is force-closing that channel

My main question is: what has happened to the 485,707 sats payment that went out? Will it time out or come back? Or is it gone forever? If it times out, how will it come back to a channel that's forced-closing or forced-closed?

My second question is: did Loop cause the force-closing of the channel?

My third question: can we get Loop to handle the initial 'Failed prepayment: UnknownPaymentHash' better?

This has happened several times (including the force-close) but I've just used the logs for one instance. I can provide others if it'll help.

I wish I was better at tracing what has happened. I have tried. If you've any tips or advice that can show me how to trace what has happened, please do let me know.

@alexbosworth

This comment has been minimized.

Copy link
Member

commented May 13, 2019

The UnknownPaymentHash error is a known issue that can happen if blocks are mined too quickly during the period where a payment is making its way to the service. As a workaround you can try initiating another swap.

If you consider payments off-chain, they are regular off-chain payments and can have a timeout length depending on the route your node chose. Since they are regular off-chain payments, there is nothing different about them with regard to force closes, other than the fact that they may be pending longer than usual.

Potentially we should allow directing a maximum value for this in the swap command. In a future Loop release we can also reduce the pending time of the swap.

@OpinionatedGeek

This comment has been minimized.

Copy link
Contributor Author

commented May 13, 2019

The UnknownPaymentHash error is a known issue that can happen if blocks are mined too quickly during the period where a payment is making its way to the service. As a workaround you can try initiating another swap.

Thanks. Is this after the UnknownPaymentHash error but before the Loop server recognises it as 'FAILED'? Or is it possible to use this to fix up the current situation with the force-closed channels?

If you consider payments off-chain, they are regular off-chain payments and can have a timeout length depending on the route your node chose. Since they are regular off-chain payments, there is nothing different about them with regard to force closes, other than the fact that they may be pending longer than usual.

I don't think I follow this. If a payment went out but is still unsettled, it will time out. I get that. But I'm lost when it comes to how that would time out when the channel is force-closing. In a regular situation the funds are locked from the channel while the payment is in-flight (I think), and if the payment times out those funds are unlocked. But where do the funds come back to in the force-closed situation? Should I expect the channel closure to return the full balance to my wallet (including the timed-out payment)?

Also - how can I inspect these in-flight payments? They don't appear in listpayments. I'd like to find out when I can expect them to time out.

Many thanks,

Geoff

@OpinionatedGeek

This comment has been minimized.

Copy link
Contributor Author

commented May 15, 2019

Some further information on the force close now that it has completed. Here are the close details from RTL:

Close Type: LOCAL_FORCE_CLOSE 
Channel Point: 489d2ef2b904ec0b0687517ad52451f868987f13b2073b5cc1b807c3f0d61c95:0 
Chan Id: 632050960802447360 
Closing Tx Hash: 2560a2338ca07f12d74bdf31c37aa5ca357892051a61f50266fac21e891e89b4 
Remote Pubkey: 03bb88ccc444534da7b5b64b4f7b15e1eccb18e102db0e400d4b9cfe93763aa26d 
Capacity: 1,000,000
Close Height: 575,820
Settled Balance: 489,395
Time Locked Balance: 956,686

Here's a link to the closing transaction

It looks like the 'swap payment' is still in-flight - how can I check when it will time out, since it doesn't appear in listpayments? And what will happen when it times out and the channel is closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.