ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.86k stars 906 forks source link

funds getting committed to wrong address after inactive close #5748

Closed seaweedghost closed 1 year ago

seaweedghost commented 1 year ago

Issue and Steps to Reproduce

-We have a CLightning node running on TOR. -We opened a channel with another node(with all the funds being on our side). The channel was in state "inactive" after 24 hours. We closed the channel because of this. The closing took a while and we left it for a few days. -The funds have now been committed on chain. However our balance was not updated. On further investigation, the bitcoin address that is was committed to is not in our list of bitcoin addresses we see in listoffunds!

How can this have happened? I thought it had to be committed to an address that the clightning node had ownership of? How can we recover these funds, and how was this address chosen as the onchain address?

whitslack commented 1 year ago

What address type are the funds at now? If they're at a P2WSH address, then the closing hasn't completed yet. (You would need to wait for the time lock to expire, and then your node will reclaim the funds to a P2WPKH address in the wallet.)

seaweedghost commented 1 year ago

Hi Whitslack. Thanks for the reply. Yes it is!. I did not know this was possible. I thought once the transaction gets committed to the blockchain, it is done forever. Does this only happen for inactive closures? I have never encountered this with the lightning network before.

Do you know the default time lock to expire is? I have waited 2 days now and its still there.

whitslack commented 1 year ago

The time depends on what your peer configured. Check the output of the listpeers command. It should say something like "1 output unresolved; will spend DELAYED_RETURN_TO_WALLET in 999 blocks." That number is how long you still need to wait.

And yes, a unilateral closure is a two-phase operation. The waiting period gives your peer time to notice that you dumped a channel state to the blockchain and to punish you if you broadcasted an outdated state.

seaweedghost commented 1 year ago

thank you so much! I owe you a beer or two. Been stressing about this for 2 days now.