From 9d0c10bb59c2869d955d7925f1c459712ba0fe5f Mon Sep 17 00:00:00 2001 From: Pierre-Marie Padiou Date: Thu, 5 Oct 2023 14:15:08 +0200 Subject: [PATCH] Filter `LegacyWaitForFundingConfirmed` on startup (#549) There are two reasons why a channel would be in this state: a) The peer was shut down during channel creation. The funding tx got published but the peer hasn't been started since. b) The channel creation was actually aborted, and not only will the funding tx never be published, the channel was forgotten altogether by the counterparty. In this case, the channel stays permanently in the state `Syncing(LegacyWaitForFundingConfirmed)` because the counterparty never sends `channel_reestablish` and lightning-kmp will not send his when the remote backup is enabled. There are some users in the b) case, it caused them to be stuck during migration (because we were checking that all states were either synced or closed). We published a path, but then the same users are stuck with the swap-in, because we do the same kind of check. I fail to see why we even stored channels in that state in the first place: either the channel was actually created and it would be restored upon reconnection, or the channel creation was aborted and it's better to forget about it. --- src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt b/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt index b7ffc6f87..3086767ea 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt @@ -225,7 +225,7 @@ class Peer( } launch { // we don't restore closed channels - val bootChannels = db.channels.listLocalChannels().filterNot { it is Closed } + val bootChannels = db.channels.listLocalChannels().filterNot { it is Closed || it is LegacyWaitForFundingConfirmed } _bootChannelsFlow.value = bootChannels.associateBy { it.channelId } val channelIds = bootChannels.map { logger.info { "restoring channel ${it.channelId} from local storage" }