electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 6696f40e3668d393af455d89eef3223bc6f55b54
parent feb47b0a6ff7c5f0dd4ab09ccdb1443133198ff9
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 18 Feb 2020 13:58:17 +0100

follow-up previous commit: show onchain tx dialog for channel open/close transactions

Diffstat:
Melectrum/gui/kivy/uix/screens.py | 8+++++---
Melectrum/gui/qt/history_list.py | 25++++++++++++-------------
Melectrum/gui/qt/lightning_tx_dialog.py | 2+-
3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py @@ -127,10 +127,13 @@ class HistoryScreen(CScreen): def show_item(self, obj): key = obj.key tx_item = self.history.get(key) - if obj.is_lightning: + if tx_item.get('lightning') and tx_item['type'] == 'payment': self.app.lightning_tx_dialog(tx_item) return - tx = self.app.wallet.db.get_transaction(key) + if tx_item.get('lightning'): + tx = self.app.wallet.lnworker.lnwatcher.db.get_transaction(key) + else: + tx = self.app.wallet.db.get_transaction(key) if not tx: return self.app.tx_dialog(tx) @@ -160,7 +163,6 @@ class HistoryScreen(CScreen): fee_text = '' if fee is None else 'fee: %d sat'%fee ri = {} ri['screen'] = self - ri['is_lightning'] = is_lightning ri['key'] = key ri['icon'] = icon ri['date'] = status_str diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py @@ -576,16 +576,14 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): if self.hm.flags(self.model().mapToSource(idx)) & Qt.ItemIsEditable: super().mouseDoubleClickEvent(event) else: - self.show_transaction(tx_item) + tx_hash = tx_item['txid'] + tx = self.wallet.db.get_transaction(tx_hash) + if not tx: + return + self.show_transaction(tx_item, tx) - def show_transaction(self, tx_item): - if tx_item.get('lightning'): - self.parent.show_lightning_transaction(tx_item) - return + def show_transaction(self, tx_item, tx): tx_hash = tx_item['txid'] - tx = self.wallet.db.get_transaction(tx_hash) - if not tx: - return label = self.wallet.get_label(tx_hash) or None # prefer 'None' if not defined (force tx dialog to hide Description field if missing) self.parent.show_transaction(tx, tx_desc=label) @@ -608,15 +606,16 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): # can happen e.g. before list is populated for the first time return tx_item = self.hm.transactions.value_from_pos(idx.row()) - if tx_item.get('lightning'): + if tx_item.get('lightning') and tx_item['type'] == 'payment': menu = QMenu() - #tx_hash = tx_item['txid'] - #menu.addAction(_("Copy Transaction ID"), lambda: self.place_text_on_clipboard(tx_hash, title="TXID")) menu.addAction(_("Details"), lambda: self.parent.show_lightning_transaction(tx_item)) menu.exec_(self.viewport().mapToGlobal(position)) return tx_hash = tx_item['txid'] - tx = self.wallet.db.get_transaction(tx_hash) + if tx_item.get('lightning'): + tx = self.wallet.lnworker.lnwatcher.db.get_transaction(tx_hash) + else: + tx = self.wallet.db.get_transaction(tx_hash) if not tx: return tx_URL = block_explorer_URL(self.config, 'tx', tx_hash) @@ -635,7 +634,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): # TODO use siblingAtColumn when min Qt version is >=5.11 persistent = QPersistentModelIndex(org_idx.sibling(org_idx.row(), c)) menu.addAction(_("Edit {}").format(label), lambda p=persistent: self.edit(QModelIndex(p))) - menu.addAction(_("Details"), lambda: self.show_transaction(tx_item)) + menu.addAction(_("Details"), lambda: self.show_transaction(tx_item, tx)) if is_unconfirmed and tx: # note: the current implementation of RBF *needs* the old tx fee rbf = is_mine and not tx.is_final() and fee is not None diff --git a/electrum/gui/qt/lightning_tx_dialog.py b/electrum/gui/qt/lightning_tx_dialog.py @@ -41,7 +41,7 @@ class LightningTxDialog(WindowModalDialog): def __init__(self, parent: 'ElectrumWindow', tx_item: dict): WindowModalDialog.__init__(self, parent, _("Lightning Payment")) self.parent = parent - self.is_sent = bool(tx_item['direction'] is 'sent') + self.is_sent = bool(tx_item['direction'] == 'sent') self.label = tx_item['label'] self.timestamp = tx_item['timestamp'] self.amount = Decimal(tx_item['amount_msat']) /1000