Force-close channels on reorg only if the funding is unconfirmed
authorMatt Corallo <git@bluematt.me>
Mon, 2 May 2022 02:51:50 +0000 (02:51 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 2 May 2022 02:53:58 +0000 (02:53 +0000)
commit7016c2f20203d804f843ab6fa04720af62f85621
treee0ac9948047ba436db88bf8a53243d69161240da
parent9bdce47f0e0516e37c89c09f1975dfc06b5870b1
Force-close channels on reorg only if the funding is unconfirmed

Currently, if a channel's funding is locked in and then later
reorg'd back to half of the channel's minimum-depth we will
immediately force-close the channel. However, this can happen at
the fork-point while processing a reorg, and generally reorgs do
not reduce the block height at all, making this a rather useless
endeavor.

Ideally we'd never auto-force-close channels at all due to a reorg,
instead simply marking it as inactive until the funding
transaction is re-confirmed (or allowing the user to attempt to
force-close or force-closing once we're confident we have
completed reorg processing if we're at risk of losing funds
already received in the channel).

Sadly, we currently do not support changing a channel's SCID and
updating our SCID maps, so we cannot yet remove the automated
force-close logic. Still, there is no reason to do it until a
funding transaction has been removed from the chain.

This implements that change - only force-closeing once a channel's
funding transaction has been reorg'd out (still potentially at a
reorg's fork point). This continues to imply a 1-confirmation
channel will always be force-closed after a reorg of the funding
transaction, and will imply a similar behavior with 0-conf
channels.
lightning/src/ln/channel.rs
lightning/src/ln/reorg_tests.rs