From 4917f7e3ceb6b60573d89cc77535d6c39a846996 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 28 Feb 2025 09:42:24 +0100 Subject: [PATCH] fix balance sanity check in get_lightning_history --- electrum/lnchannel.py | 4 ++++ electrum/lnworker.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py index bf48259dc..ae1a6f187 100644 --- a/electrum/lnchannel.py +++ b/electrum/lnchannel.py @@ -235,6 +235,10 @@ class AbstractChannel(Logger, ABC): # the closing txid has been saved return self.get_state() >= ChannelState.CLOSING + def is_closed_or_closing(self): + # related: self.get_state_for_GUI + return self.is_closed() or self.unconfirmed_closing_txid is not None + def is_redeemed(self) -> bool: return self.get_state() == ChannelState.REDEEMED diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 70d11e1c3..952f1639b 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -1056,7 +1056,7 @@ class LNWallet(LNWorker): # sanity check balance_msat = sum([x.amount_msat for x in out.values()]) - lb = sum(chan.balance(LOCAL) if not chan.is_closed() else 0 + lb = sum(chan.balance(LOCAL) if not chan.is_closed_or_closing() else 0 for chan in self.channels.values()) assert balance_msat == lb return out