commit ae402303caa0b8b88b97bc74f8e6a836afcc7d9c
parent f6f5cbee723ccbfc114733d4d3234840bce0fa8d
Author: ThomasV <thomasv@electrum.org>
Date: Wed, 30 Jan 2019 19:40:20 +0100
channel: is_closed
Diffstat:
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/electrum/lnchan.py b/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')
diff --git a/electrum/lnworker.py b/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: