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: