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'
```
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user