diff --git a/electrum/lnchan.py b/electrum/lnchan.py index e2abb54dc..c8a53fa04 100644 --- 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 index 310f6036c..b7882dc77 100644 --- 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: