Browse Source

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'
```
patch-4
SomberNight 3 years ago
parent
commit
1810835fae
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 10
      electrum/lnchannel.py

10
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

Loading…
Cancel
Save