1
0

qml TxDetails: show short_id instead of block height and txpos

The "TX index" (txpos) item I think was confusing.
This commit is contained in:
SomberNight
2023-03-23 16:57:16 +00:00
parent f9f57b58b4
commit 8c1fe10f54
3 changed files with 15 additions and 26 deletions

View File

@@ -207,24 +207,13 @@ Pane {
Label {
visible: txdetails.isMined
text: qsTr('Height')
text: qsTr('Mined at')
color: Material.accentColor
}
Label {
visible: txdetails.isMined
text: txdetails.height
}
Label {
visible: txdetails.isMined
text: qsTr('TX index')
color: Material.accentColor
}
Label {
visible: txdetails.isMined
text: txdetails.txpos
text: txdetails.shortId
}
Label {

View File

@@ -4,7 +4,7 @@ from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
from electrum.i18n import _
from electrum.logging import get_logger
from electrum.util import format_time, AddTransactionException
from electrum.util import format_time, AddTransactionException, TxMinedInfo
from electrum.transaction import tx_from_any
from electrum.network import Network
@@ -56,10 +56,9 @@ class QETxDetails(QObject, QtEventListener):
self._mempool_depth = ''
self._date = ''
self._height = 0
self._confirmations = 0
self._txpos = -1
self._header_hash = ''
self._short_id = ""
def on_destroy(self):
self.unregister_callbacks()
@@ -166,17 +165,13 @@ class QETxDetails(QObject, QtEventListener):
def date(self):
return self._date
@pyqtProperty(int, notify=detailsChanged)
def height(self):
return self._height
@pyqtProperty(int, notify=detailsChanged)
def confirmations(self):
return self._confirmations
@pyqtProperty(int, notify=detailsChanged)
def txpos(self):
return self._txpos
@pyqtProperty(str, notify=detailsChanged)
def shortId(self):
return self._short_id
@pyqtProperty(str, notify=detailsChanged)
def headerHash(self):
@@ -296,13 +291,12 @@ class QETxDetails(QObject, QtEventListener):
self._label = txinfo.label
self.labelChanged.emit()
def update_mined_status(self, tx_mined_info):
def update_mined_status(self, tx_mined_info: TxMinedInfo):
self._mempool_depth = ''
self._date = format_time(tx_mined_info.timestamp)
self._height = tx_mined_info.height
self._confirmations = tx_mined_info.conf
self._txpos = tx_mined_info.txpos
self._header_hash = tx_mined_info.header_hash
self._short_id = tx_mined_info.short_id() or ""
@pyqtSlot()
@pyqtSlot(bool)

View File

@@ -1299,6 +1299,12 @@ class TxMinedInfo(NamedTuple):
header_hash: Optional[str] = None # hash of block that mined tx
wanted_height: Optional[int] = None # in case of timelock, min abs block height
def short_id(self) -> Optional[str]:
if self.txpos is not None and self.txpos >= 0:
assert self.height > 0
return f"{self.height}x{self.txpos}"
return None
class ShortID(bytes):