Browse Source

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

hard-fail-on-bad-server-string
ThomasV 5 years ago
parent
commit
e48c7d01cd
  1. 12
      electrum/gui/qt/channels_list.py
  2. 15
      electrum/gui/qt/history_list.py
  3. 4
      electrum/gui/qt/main_window.py
  4. 2
      electrum/wallet.py

12
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

15
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:

4
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)

2
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

Loading…
Cancel
Save