From e936b6e4a571ce12135c0d6717eab4895c8e6a50 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Wed, 7 Apr 2021 17:21:48 +0200 Subject: [PATCH] fix #7185 --- electrum/lnworker.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 06c512255..cd0f8983a 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -1953,22 +1953,21 @@ class LNWallet(LNWorker): return Decimal(can_send_minus_fees) / 1000 def num_sats_can_receive(self) -> Decimal: - can_receive = 0 with self.lock: - if self.channels: - for c in self.channels.values(): - if c.is_active() and not c.is_frozen_for_receiving(): - can_receive += c.available_to_spend(REMOTE) + channels = [ + c for c in self.channels.values() + if c.is_active() and not c.is_frozen_for_receiving() + ] + can_receive = sum([c.available_to_spend(REMOTE) for c in channels]) if channels else 0 return Decimal(can_receive) / 1000 def num_sats_can_receive_no_mpp(self) -> Decimal: - can_receive = 0 with self.lock: - if self.channels: - can_receive = max([ - c.available_to_spend(REMOTE) for c in self.channels.values() - if c.is_active() and not c.is_frozen_for_receiving() - ]) + channels = [ + c for c in self.channels.values() + if c.is_active() and not c.is_frozen_for_receiving() + ] + can_receive = max([c.available_to_spend(REMOTE) for c in channels]) if channels else 0 return Decimal(can_receive) / 1000 def can_pay_invoice(self, invoice: LNInvoice) -> bool: