lnd icon indicating copy to clipboard operation
lnd copied to clipboard

Handling non-confirmed funding transactions

Open halseth opened this issue 7 years ago • 17 comments

Issue

During the current funding workflow, the responder should forget the channel if the funding transaction is not confirmed within a reasonable timeout. For lnd this timeout is currently set to 288 blocks.

The funder (initiator) of the channel cannot forget about the channel if the funding transaction is broadcast, since he has funded the transaction with coins. Therefore, we should make sure the money is returned to the funder's wallet.

Steps to completion:

  • [x] Prevent the funder from forgetting about the channel if the fundingManager gets restarted while waiting for the funding transaction to confirm. Currently, on restart it will launch a goroutine that will timeout after 288 blocks, but this should only be done for the channel responder.

  • [ ] Determine how to reclaim the funds. We can either double spend the input to the funding transaction back into our wallet, or broadcast the commitment transaction and sweep the funds using CPFP.

Extra credits: We might also be able to bump the fee of the funding transaction to get it confirmed, but this would possibly need some more advanced scripting features, due to changing the amounts int the funding tx changes the txid, which the commitment tx relies on.

halseth avatar Oct 20 '17 20:10 halseth

I'll try to resolve this issue.

ghost avatar Oct 31 '17 17:10 ghost

I've done the first part #514

johng avatar Dec 23 '17 23:12 johng

It would be really neat to also be able to "cancel" the opening of a channel and reclaim the funds while the funding transaction is unconfirmed, even if the timout hasn't expired. This way you could avoid having to wait for the timeout.

jemilsson avatar Jan 28 '18 12:01 jemilsson

First portion fixed by #514.

Roasbeef avatar Feb 27 '18 00:02 Roasbeef

Hi if nobody is working on this, I'd like to take it

Crypt-iQ avatar Jun 21 '18 00:06 Crypt-iQ

Since I haven't gotten a reply I'll assume nobody is working on this and work on it myself

Crypt-iQ avatar Jul 11 '18 14:07 Crypt-iQ

I believe @wpaulino has started on this one.

On Wed, Jul 11, 2018 at 4:47pm, Eugene < [email protected] [[email protected]] > wrote: Since I haven't gotten a reply I'll assume nobody is working on this and work on it myself

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub [https://github.com/lightningnetwork/lnd/issues/386#issuecomment-404196823] , or mute the thread [https://github.com/notifications/unsubscribe-auth/ADl15MEKau2-xao1LRCKVajwy9gAuqfyks5uFhAYgaJpZM4QBLco] .

halseth avatar Jul 11 '18 15:07 halseth

Ah ok I'll find a diff issue then

Crypt-iQ avatar Jul 11 '18 15:07 Crypt-iQ

I'm really sorry I didn't give any news. I no longer work on this problem indeed.

ghost avatar Jul 14 '18 11:07 ghost

currently working on this

johng avatar May 27 '19 21:05 johng

From #3149:

After discussing this a bit we have come to the conclusion we do not want to introduce more persistent state during the funding process. Instead we should let the fundingmanager

  1. unlock the coins after a timeout, making them spendable in other transactions.
  2. In combination with something like #1755 this should allow it to gracefully fail the channel.

To bump the fee on an unconfirmed channel manually, the current bump fee logic can be used.

halseth avatar Nov 05 '19 10:11 halseth

Another suggestion here is to allow the cancellation of the funding transaction by doublespending it back to the chain wallet. This can be useful in the scenario I just went through where I set low-ish fees, and then the China outage happened, causing the funding tx to confirm after the two week window. I knew it was going to take a while and would have liked to double spend back to self in order to avoid having to pay 3x chain for [fund,force close,sweep].

ProofOfKeags avatar May 04 '21 00:05 ProofOfKeags

Note that double-spending is currently not detected be neither funder nor receiver. This is a massive pain in loptos as PayJoin occasionally fails and fallback transaction double spends the inputs.

Kixunil avatar Jul 19 '21 16:07 Kixunil

I'm having a look at bringing https://github.com/lightningnetwork/lnd/pull/1755 up to date. I'm working on integration tests, in theory it should be working though.

I can create a draft PR if it's of interest

johng avatar Jul 19 '21 17:07 johng

@johng that'd be awesome!

Kixunil avatar Jul 19 '21 19:07 Kixunil

Latest PR working on this is #5567, will takeover if contributor is no longer working on it.

carlaKC avatar Jan 11 '22 12:01 carlaKC

Current PR in progress to address this issue: https://github.com/lightningnetwork/lnd/pull/7036

saubyk avatar Oct 26 '22 01:10 saubyk