electrum

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

commit e48c7d01cdfdaac1c4419648e96d4747c0d8c810
parent c3c6b818573da915cdf01b2e9ce8e27253494abe
Author: ThomasV <thomasv@electrum.org>
Date:   Fri,  6 Mar 2020 08:47:31 +0100

Qt: add 'View channel' to history menu, 'View funding transaction' to channel menu

Diffstat:
Melectrum/gui/qt/channels_list.py | 12+++++-------
Melectrum/gui/qt/history_list.py | 15++++++++++-----
Melectrum/gui/qt/main_window.py | 4++++
Melectrum/wallet.py | 2++
4 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py @@ -16,7 +16,6 @@ from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id, LN_MAX_FUNDI from .util import (MyTreeView, WindowModalDialog, Buttons, OkButton, CancelButton, EnterButton, WaitingDialog, MONOSPACE_FONT) from .amountedit import BTCAmountEdit, FreezableLineEdit -from .channel_details import ChannelDetailsDialog ROLE_CHANNEL_ID = Qt.UserRole @@ -118,8 +117,11 @@ class ChannelsList(MyTreeView): return channel_id = idx.sibling(idx.row(), self.Columns.NODE_ID).data(ROLE_CHANNEL_ID) chan = self.lnworker.channels[channel_id] - menu.addAction(_("Details..."), lambda: self.details(channel_id)) + menu.addAction(_("Details..."), lambda: self.parent.show_channel(channel_id)) self.add_copy_menu(menu, idx) + funding_tx = self.parent.wallet.db.get_transaction(chan.funding_outpoint.txid) + if funding_tx: + menu.addAction(_("View funding transaction"), lambda: self.parent.show_transaction(funding_tx)) if not chan.is_closed(): if chan.peer_state == peer_states.GOOD: menu.addAction(_("Close channel"), lambda: self.close_channel(channel_id)) @@ -132,13 +134,9 @@ class ChannelsList(MyTreeView): if closing_tx: menu.addAction(_("View closing transaction"), lambda: self.parent.show_transaction(closing_tx)) if chan.is_redeemed(): - menu.addAction(_("Remove"), lambda: self.remove_channel(channel_id)) + menu.addAction(_("Delete"), lambda: self.remove_channel(channel_id)) menu.exec_(self.viewport().mapToGlobal(position)) - def details(self, channel_id): - assert self.parent.wallet - ChannelDetailsDialog(self.parent, channel_id).show() - @QtCore.pyqtSlot(Channel) def do_update_single_row(self, chan): lnworker = self.parent.wallet.lnworker diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py @@ -274,9 +274,10 @@ class HistoryModel(QAbstractItemModel, Logger): if fx: fx.history_used_spot = False wallet = self.parent.wallet self.set_visibility_of_columns() - transactions = wallet.get_full_history(self.parent.fx, - onchain_domain=self.get_domain(), - include_lightning=self.should_include_lightning_payments()) + transactions = wallet.get_full_history( + self.parent.fx, + onchain_domain=self.get_domain(), + include_lightning=self.should_include_lightning_payments()) if transactions == list(self.transactions.values()): return old_length = len(self.transactions) @@ -621,7 +622,8 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): tx_item = self.hm.transactions.value_from_pos(idx.row()) if tx_item.get('lightning') and tx_item['type'] == 'payment': menu = QMenu() - menu.addAction(_("Details"), lambda: self.parent.show_lightning_transaction(tx_item)) + menu.addAction(_("View payment"), lambda: self.parent.show_lightning_transaction(tx_item)) + self.add_copy_menu(menu, idx) menu.exec_(self.viewport().mapToGlobal(position)) return tx_hash = tx_item['txid'] @@ -646,7 +648,10 @@ 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, tx)) + menu.addAction(_("View transaction"), lambda: self.show_transaction(tx_item, tx)) + channel_id = tx_item.get('channel_id') + if channel_id: + menu.addAction(_("View channel"), lambda: self.parent.show_channel(bytes.fromhex(channel_id))) if is_unconfirmed and tx: # note: the current implementation of RBF *needs* the old tx fee if tx_details.can_bump and tx_details.fee is not None: diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -969,6 +969,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): d = address_dialog.AddressDialog(self, addr) d.exec_() + def show_channel(self, channel_id): + from . import channel_details + channel_details.ChannelDetailsDialog(self, channel_id).show() + def show_transaction(self, tx, *, tx_desc=None): '''tx_desc is set only for txs created in the Send tab''' show_transaction(tx, parent=self, desc=tx_desc) diff --git a/electrum/wallet.py b/electrum/wallet.py @@ -763,6 +763,8 @@ class Abstract_Wallet(AddressSynchronizer, ABC): if txid and txid in transactions_tmp: item = transactions_tmp[txid] item['label'] = tx_item['label'] + item['type'] = tx_item['type'] + item['channel_id'] = tx_item['channel_id'] item['ln_value'] = Satoshis(ln_value) else: tx_item['lightning'] = True