From 1810835faeece3b7ed17ef7c4203dbf99715ff9d Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 29 Mar 2022 18:30:55 +0200 Subject: [PATCH] lnchannel: get_capacity() should not raise when running with --offline ``` E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter Traceback (most recent call last): File "...\electrum\electrum\gui\qt\channels_list.py", line 295, in do_update_rows field_map = self.format_fields(chan) File "...\electrum\electrum\gui\qt\channels_list.py", line 99, in format_fields capacity_str = self.parent.format_amount(chan.get_capacity(), whitespaces=True) File "...\electrum\electrum\lnchannel.py", line 481, in get_capacity return self.lnworker.lnwatcher.get_tx_delta(self.funding_outpoint.txid, self.cb.funding_address) AttributeError: 'NoneType' object has no attribute 'get_tx_delta' ``` --- electrum/lnchannel.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py index ba8b8750a..6963c1e6a 100644 --- a/electrum/lnchannel.py +++ b/electrum/lnchannel.py @@ -407,6 +407,11 @@ class AbstractChannel(Logger, ABC): """Returns our node ID.""" pass + @abstractmethod + def get_capacity(self) -> Optional[int]: + """Returns channel capacity in satoshis, or None if unknown.""" + pass + class ChannelBackup(AbstractChannel): """ @@ -478,7 +483,10 @@ class ChannelBackup(AbstractChannel): return self.is_imported or self.is_redeemed() def get_capacity(self): - return self.lnworker.lnwatcher.get_tx_delta(self.funding_outpoint.txid, self.cb.funding_address) + lnwatcher = self.lnworker.lnwatcher + if lnwatcher: + return lnwatcher.get_tx_delta(self.funding_outpoint.txid, self.cb.funding_address) + return None def is_backup(self): return True