mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 15:31:31 +00:00
follow-up previous commit: show onchain tx dialog for channel open/close transactions
This commit is contained in:
parent
feb47b0a6f
commit
6696f40e36
3 changed files with 18 additions and 17 deletions
|
@ -127,9 +127,12 @@ class HistoryScreen(CScreen):
|
||||||
def show_item(self, obj):
|
def show_item(self, obj):
|
||||||
key = obj.key
|
key = obj.key
|
||||||
tx_item = self.history.get(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)
|
self.app.lightning_tx_dialog(tx_item)
|
||||||
return
|
return
|
||||||
|
if tx_item.get('lightning'):
|
||||||
|
tx = self.app.wallet.lnworker.lnwatcher.db.get_transaction(key)
|
||||||
|
else:
|
||||||
tx = self.app.wallet.db.get_transaction(key)
|
tx = self.app.wallet.db.get_transaction(key)
|
||||||
if not tx:
|
if not tx:
|
||||||
return
|
return
|
||||||
|
@ -160,7 +163,6 @@ class HistoryScreen(CScreen):
|
||||||
fee_text = '' if fee is None else 'fee: %d sat'%fee
|
fee_text = '' if fee is None else 'fee: %d sat'%fee
|
||||||
ri = {}
|
ri = {}
|
||||||
ri['screen'] = self
|
ri['screen'] = self
|
||||||
ri['is_lightning'] = is_lightning
|
|
||||||
ri['key'] = key
|
ri['key'] = key
|
||||||
ri['icon'] = icon
|
ri['icon'] = icon
|
||||||
ri['date'] = status_str
|
ri['date'] = status_str
|
||||||
|
|
|
@ -576,16 +576,14 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
|
||||||
if self.hm.flags(self.model().mapToSource(idx)) & Qt.ItemIsEditable:
|
if self.hm.flags(self.model().mapToSource(idx)) & Qt.ItemIsEditable:
|
||||||
super().mouseDoubleClickEvent(event)
|
super().mouseDoubleClickEvent(event)
|
||||||
else:
|
else:
|
||||||
self.show_transaction(tx_item)
|
|
||||||
|
|
||||||
def show_transaction(self, tx_item):
|
|
||||||
if tx_item.get('lightning'):
|
|
||||||
self.parent.show_lightning_transaction(tx_item)
|
|
||||||
return
|
|
||||||
tx_hash = tx_item['txid']
|
tx_hash = tx_item['txid']
|
||||||
tx = self.wallet.db.get_transaction(tx_hash)
|
tx = self.wallet.db.get_transaction(tx_hash)
|
||||||
if not tx:
|
if not tx:
|
||||||
return
|
return
|
||||||
|
self.show_transaction(tx_item, tx)
|
||||||
|
|
||||||
|
def show_transaction(self, tx_item, tx):
|
||||||
|
tx_hash = tx_item['txid']
|
||||||
label = self.wallet.get_label(tx_hash) or None # prefer 'None' if not defined (force tx dialog to hide Description field if missing)
|
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)
|
self.parent.show_transaction(tx, tx_desc=label)
|
||||||
|
|
||||||
|
@ -608,14 +606,15 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
|
||||||
# can happen e.g. before list is populated for the first time
|
# can happen e.g. before list is populated for the first time
|
||||||
return
|
return
|
||||||
tx_item = self.hm.transactions.value_from_pos(idx.row())
|
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()
|
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.addAction(_("Details"), lambda: self.parent.show_lightning_transaction(tx_item))
|
||||||
menu.exec_(self.viewport().mapToGlobal(position))
|
menu.exec_(self.viewport().mapToGlobal(position))
|
||||||
return
|
return
|
||||||
tx_hash = tx_item['txid']
|
tx_hash = tx_item['txid']
|
||||||
|
if tx_item.get('lightning'):
|
||||||
|
tx = self.wallet.lnworker.lnwatcher.db.get_transaction(tx_hash)
|
||||||
|
else:
|
||||||
tx = self.wallet.db.get_transaction(tx_hash)
|
tx = self.wallet.db.get_transaction(tx_hash)
|
||||||
if not tx:
|
if not tx:
|
||||||
return
|
return
|
||||||
|
@ -635,7 +634,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
|
||||||
# TODO use siblingAtColumn when min Qt version is >=5.11
|
# TODO use siblingAtColumn when min Qt version is >=5.11
|
||||||
persistent = QPersistentModelIndex(org_idx.sibling(org_idx.row(), c))
|
persistent = QPersistentModelIndex(org_idx.sibling(org_idx.row(), c))
|
||||||
menu.addAction(_("Edit {}").format(label), lambda p=persistent: self.edit(QModelIndex(p)))
|
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:
|
if is_unconfirmed and tx:
|
||||||
# note: the current implementation of RBF *needs* the old tx fee
|
# note: the current implementation of RBF *needs* the old tx fee
|
||||||
rbf = is_mine and not tx.is_final() and fee is not None
|
rbf = is_mine and not tx.is_final() and fee is not None
|
||||||
|
|
|
@ -41,7 +41,7 @@ class LightningTxDialog(WindowModalDialog):
|
||||||
def __init__(self, parent: 'ElectrumWindow', tx_item: dict):
|
def __init__(self, parent: 'ElectrumWindow', tx_item: dict):
|
||||||
WindowModalDialog.__init__(self, parent, _("Lightning Payment"))
|
WindowModalDialog.__init__(self, parent, _("Lightning Payment"))
|
||||||
self.parent = parent
|
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.label = tx_item['label']
|
||||||
self.timestamp = tx_item['timestamp']
|
self.timestamp = tx_item['timestamp']
|
||||||
self.amount = Decimal(tx_item['amount_msat']) /1000
|
self.amount = Decimal(tx_item['amount_msat']) /1000
|
||||||
|
|
Loading…
Add table
Reference in a new issue