Browse Source

channel: is_closed

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
ThomasV 6 years ago
parent
commit
ae402303ca
  1. 3
      electrum/lnchan.py
  2. 4
      electrum/lnworker.py

3
electrum/lnchan.py

@ -207,6 +207,9 @@ class Channel(PrintError):
def get_state(self):
return self._state
def is_closed(self):
return self.get_state() in ['CLOSED', 'FORCE_CLOSING']
def _check_can_pay(self, amount_msat: int) -> None:
if self.get_state() != 'OPEN':
raise PaymentFailure('Channel not open')

4
electrum/lnworker.py

@ -180,7 +180,7 @@ class LNWorker(PrintError):
for node_id, peer in self.peers.items():
if not peer.initialized.is_set():
continue
if not all([chan.get_state() in ['CLOSED'] for chan in peer.channels.values()]):
if not all([chan.is_closed() for chan in peer.channels.values()]):
continue
return node_id
@ -574,7 +574,7 @@ class LNWorker(PrintError):
def get_balance(self):
with self.lock:
return Decimal(sum(chan.balance(LOCAL) if chan.get_state() not in ['CLOSED', 'FORCE_CLOSING'] else 0 for chan in self.channels.values()))/1000
return Decimal(sum(chan.balance(LOCAL) if not chan.is_closed() else 0 for chan in self.channels.values()))/1000
def list_channels(self):
with self.lock:

Loading…
Cancel
Save