From 3541ecb5765ae4971a7bb8109e4600e58d7f603b Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 15 Aug 2022 13:54:24 +0000 Subject: [PATCH] lnwatcher: don't add `REDEEMED` channels Previously lnworker called LNWatcher.add_channel() on these, and then LNWatcher itself decided to unwatch them. ----- note: motivation related to https://github.com/spesmilo/electrum/pull/7932#discussion_r945755584 , where I have legacy (pre-staticremotekey) redeemed channels in a wallet. Tracebacks: ``` E/W | lnwatcher.LNWalletWatcher.[default_wallet-LNW] | Exception in do_breach_remedy: AssertionError() Traceback (most recent call last): File "...\electrum\electrum\util.py", line 1235, in wrapper return await func(*args, **kwargs) File "...\electrum\electrum\lnwatcher.py", line 443, in do_breach_remedy sweep_info_dict = chan.sweep_ctx(closing_tx) File "...\electrum\electrum\lnchannel.py", line 264, in sweep_ctx our_sweep_info = self.create_sweeptxs_for_our_ctx(ctx) File "...\electrum\electrum\lnchannel.py", line 253, in create_sweeptxs_for_our_ctx return create_sweeptxs_for_our_ctx(chan=self, ctx=ctx, sweep_address=self.sweep_address) File "...\electrum\electrum\lnchannel.py", line 757, in sweep_address assert self.is_static_remotekey_enabled() AssertionError ``` ``` E/W | lnwatcher.LNWalletWatcher.[default_wallet-LNW] | Exception in trigger_callbacks: AssertionError() Traceback (most recent call last): File "...\electrum\electrum\util.py", line 1235, in wrapper return await func(*args, **kwargs) File "...\electrum\electrum\lnwatcher.py", line 208, in trigger_callbacks await callback() File "...\electrum\electrum\lnwatcher.py", line 225, in check_onchain_situation keep_watching = await self.do_breach_remedy(funding_outpoint, closing_tx, spenders) File "...\electrum\electrum\util.py", line 1235, in wrapper return await func(*args, **kwargs) File "...\electrum\electrum\lnwatcher.py", line 443, in do_breach_remedy sweep_info_dict = chan.sweep_ctx(closing_tx) File "...\electrum\electrum\lnchannel.py", line 264, in sweep_ctx our_sweep_info = self.create_sweeptxs_for_our_ctx(ctx) File "...\electrum\electrum\lnchannel.py", line 253, in create_sweeptxs_for_our_ctx return create_sweeptxs_for_our_ctx(chan=self, ctx=ctx, sweep_address=self.sweep_address) File "...\electrum\electrum\lnchannel.py", line 757, in sweep_address assert self.is_static_remotekey_enabled() AssertionError ``` --- electrum/lnworker.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index c0021b486..b16878eaf 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -758,9 +758,11 @@ class LNWallet(LNWorker): self.lnrater = LNRater(self, network) for chan in self.channels.values(): - self.lnwatcher.add_channel(chan.funding_outpoint.to_str(), chan.get_funding_address()) + if not chan.is_redeemed(): + self.lnwatcher.add_channel(chan.funding_outpoint.to_str(), chan.get_funding_address()) for cb in self.channel_backups.values(): - self.lnwatcher.add_channel(cb.funding_outpoint.to_str(), cb.get_funding_address()) + if not cb.is_redeemed(): + self.lnwatcher.add_channel(cb.funding_outpoint.to_str(), cb.get_funding_address()) for coro in [ self.maybe_listen(),