ACINQ / eclair-mobile

An Android wallet for the Lightning Network
Apache License 2.0
258 stars 44 forks source link

Channel stuck at "WAIT_FOR_FUNDING_CONFIRMED" when transaction was not broadcasted. #86

Open ulfmartin opened 6 years ago

ulfmartin commented 6 years ago

The Electrum server was offline when I tried to open a channel. The other node was cooperative in opening the channel, but the signed smart contract was eventually never sent to the bitcoin network, so it never arrived in the mempool. Now the channel is stuck in WAIT_FOR_FUNDING_CONFIRMED forever.

The only thing you can do is force-closing it. There should be a re-broadcast feature for the transaction to open the channel. That could be automated, but a manual option would be sufficient as a quick fix here.

sstone commented 6 years ago

What makes you think that the tx was never sent to the bitcoin network ? Do you see it in the Transaction History tab ?

Eclair normally does not let you open a channel if it is not connected to an electrum server, and does not transition to WAIT_FOR_FUNDING_CONFIRMED if there was en error when it tried to publish the funding tx. So here, the only option that is really safe is to wait and see if it will eventually be confirmed.

ulfmartin commented 6 years ago

What made me believe that something went wrong on broadcasting the funding tx is that I opened the channel details, scrolled all the way down to the Transaction ID and tapped on "Open in Explorer". The blockchain explorer would tell me that the transaction was not found; even after several hours now. The transaction hash is: e9a4259f7e0f8ca390b4999f25ce7c7802f138a56b68872d7607329841ad73a4

The connection to the Electrum Server seemed unstable. The app would occasionally mention that the server was unavailable, so I would restart the app.

Is there any check if the tx is picked up by the electrum server before transitioning to WAIT_FOR_FUNDING_CONFIRMED?

sstone commented 6 years ago

Do you see it in your transaction list ? Did you see an error message when you opened the channel ?

ulfmartin commented 6 years ago

No, I don't see the tx in the transaction history.

sstone commented 6 years ago

You mean it is not there ? In the transaction history you should see both regular onchain transactions and LN transactions, and your funding tx should be there, with a negative amount in red, and "0 conf" written just below.

ulfmartin commented 6 years ago

I just opened two more payment channels to check; and indeed, they would show up as on-chain tx with 0 confirmations. But the tx in question did not show up there. Since I got the feeling the channel would never open, I decided to force-close it. Now it's waiting to close (uncooperative). I wonder how that works when it cannot address the original smart contract.

sstone commented 6 years ago

I wonder how that works when it cannot address the original smart contract.

If the funding tx is never confirmed then your commit tx will also never confirm and the channel will remain this way.

If the funding tx was never published then it won't show in your onchain balance (displayed with a small bitcoin icon). But we must be sure that it will never be published (we may have a bug somewhere, but we should assume that it did reach the bitcoin network and was not relayed, which does not mean that it will never be. Onchain fees have gone up a lot recently and it may explain why your tx does not show).

ulfmartin commented 6 years ago

I believe that this is not an issue about the tx fees. If the fees were too low, than it would at least land in the mempool and the blockexplorer would report "blockheight: -1" for the transaction hash. However, the transaction hash seems to be unknown to the two block explorer that I checked. So, if the transaction was actually sent out, it never actually reached the mempool of the miners. I suspect that the Electrum Server was maybe rebooting when my client sent the funding tx. If that was the case, then this issue can be fixed by checking if the tx hash is known to a blockexplorer, and if not, then the tx gets re-broadcasted. Afaik, nothing can go wrong with that approach.

sstone commented 6 years ago

Yes but afaict the tx was sent to an electrum server which did replied that it was broadcast without errors. What I don't understand yet is why it does not show in your list, which would mean that our electrum server does not know about it ??
But you're right, even if it's a corner case we need to find a way to address it, and allowing users to rebroadcast the tx is a potential solution.

ulfmartin commented 6 years ago

Well, the only thing I can add here is that I noticed that my app seemed to have problems with the connection to the electrum server and eventually connected to another one. Somewhere in between the funding tx was not properly handled.

I notice that it hops between the servers testnet.hsmiths.com and testnet1.bauerj.eu.

sstone commented 6 years ago

We try to keep a pool of at least 3 electrumx connections, one of them our master, and switch when it falls behind or is disconnected. You may be right: your master server failed, and we switched to another one that never saw the funding tx. What is really bad here is that before it failed it told us that the tx was broadcasted without errors and it was not. Unfortunately electrumx servers are much less reliable on testnet that on mainnet, and there are less of them (testnet is also "harder" : huge reorgs, unpredictable intervals between blocks, spikes in fee rates, ... which is good for testing).

kozo-cz commented 6 years ago

I have the same problem on the mainnet. Channel is stuck in WAIT_FOR_FUNDING_CONFIRMED state forever, the funding transaction never made it to the mempool. The transaction is not shown in the Transaction history tab. The wallet shows wrong total balance 4,9mBTC, but I only sent 2,5mBTC to Eclair. It shows the bitcoin in both the on-chain balance and the lightning balance. One more info, I initialized the wallet with an existing 12 words seed.

yuyaogawa commented 6 years ago

@sstone I have the same problem on the mainnet and here is another same issue #43. I believe this is a serious issue because our funds are tied up and it seems to never get back unless this issue is fixed. If eclair-wallet stores the raw funding transaction, we could manually rebroadcast it to network.

kozo-cz commented 6 years ago

After I chose to close the failed channel the funds were released and I successfully opened another channel. No loss of btc occurred. The failed channel is stuck in CLOSING (uncooperative) state forever.

yuyaogawa commented 6 years ago

@kozo-cz In this issue #43 , it cannot close channel because funding transaction was never broadcast, AND the funds in funding transaction has not been released. How were the funds released even if the failed channel is stuck in CLOSING state?

kozo-cz commented 6 years ago

My funding tx was not broadcast either. I noticed that the failed channel didn't deduct btc from the on-chain balance. So the funds were not locked probably. Do you see the Close option for the failed channel? What is your on-chain balance?

yuyaogawa commented 6 years ago

@kozo-cz Yes, I know what you mean. When I looked into the outpoint where the funding tx tried to spend, the output is still spendable. However, the channel is stuck in CLOSING state, so that amount of BTC that I tried to open a channel with doesn't go to neither off-chain nor on-chain in eclair wallet. This is the problem here.

Victorsueca commented 6 years ago

I think I'm having a similar issue. I have a channel that's been stuck on "CLOSING" for 1 day already. The funding transaction was never broadcasted and the UTXO that was meant to fund it was later spent into succesfully opening another channel, but it's still trying to close the first one. I'm using ECLAIR 0.2-beta8 and it's kind of annoying to have that stale channel in my channels list.

pm47 commented 6 years ago

This is addressed by https://github.com/ACINQ/eclair/pull/714

However, the channel is stuck in CLOSING state, so that amount of BTC that I tried to open a channel with doesn't go to neither off-chain nor on-chain in eclair wallet. This is the problem here.

No, this doesn't affect the funds, they can still be spent on an other on-chain transaction or channel opening. This is only visually annoying, there is no other consequence to the best of our knowledge.