From 5f7388a475cd796c30caab688e7f8136a8c6ac27 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 22 Apr 2022 19:18:07 +0200 Subject: [PATCH] lnworker: fix get_onchain_history if running with --offline ``` Traceback (most recent call last): File "...\electrum\electrum\gui\qt\main_window.py", line 898, in timer_actions self.update_wallet() File "...\electrum\electrum\gui\qt\main_window.py", line 1040, in update_wallet self.update_tabs() File "...\electrum\electrum\gui\qt\main_window.py", line 1047, in update_tabs self.history_model.refresh('update_tabs') File "...\electrum\electrum\util.py", line 439, in return lambda *args, **kw_args: do_profile(args, kw_args) File "...\electrum\electrum\util.py", line 435, in do_profile o = func(*args, **kw_args) File "...\electrum\electrum\gui\qt\history_list.py", line 275, in refresh transactions = wallet.get_full_history( File "...\electrum\electrum\util.py", line 439, in return lambda *args, **kw_args: do_profile(args, kw_args) File "...\electrum\electrum\util.py", line 435, in do_profile o = func(*args, **kw_args) File "...\electrum\electrum\wallet.py", line 947, in get_full_history lnworker_history = self.lnworker.get_onchain_history() if self.lnworker and include_lightning else {} File "...\electrum\electrum\lnworker.py", line 911, in get_onchain_history tx_height = self.lnwatcher.get_tx_height(swap.funding_txid) AttributeError: 'NoneType' object has no attribute 'get_tx_height' ``` --- electrum/lnworker.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 107e31670..b782dc4cf 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -908,9 +908,10 @@ class LNWallet(LNWorker): amount_msat = 0 label = 'Reverse swap' if swap.is_reverse else 'Forward swap' delta = current_height - swap.locktime - tx_height = self.lnwatcher.get_tx_height(swap.funding_txid) - if swap.is_reverse and tx_height.height <=0: - label += ' (%s)' % _('waiting for funding tx confirmation') + if self.lnwatcher: + tx_height = self.lnwatcher.get_tx_height(swap.funding_txid) + if swap.is_reverse and tx_height.height <= 0: + label += ' (%s)' % _('waiting for funding tx confirmation') if not swap.is_reverse and not swap.is_redeemed and swap.spending_txid is None and delta < 0: label += f' (refundable in {-delta} blocks)' # fixme: only if unspent out[txid] = {