Browse Source

add numtx and address history model to addres details

patch-4
Sander van Grieken 3 years ago
parent
commit
02ccd46fd5
  1. 9
      electrum/gui/qml/components/AddressDetails.qml
  2. 18
      electrum/gui/qml/qeaddressdetails.py
  3. 7
      electrum/gui/qml/qetransactionlistmodel.py

9
electrum/gui/qml/components/AddressDetails.qml

@ -215,6 +215,15 @@ Pane {
}
}
Label {
text: qsTr('Transactions')
color: Material.accentColor
}
Label {
text: addressdetails.numTx
}
Label {
text: qsTr('Derivation path')
color: Material.accentColor

18
electrum/gui/qml/qeaddressdetails.py

@ -7,6 +7,7 @@ from electrum.util import DECIMAL_POINT_DEFAULT
from .qewallet import QEWallet
from .qetypes import QEAmount
from .qetransactionlistmodel import QETransactionListModel
class QEAddressDetails(QObject):
def __init__(self, parent=None):
@ -25,8 +26,9 @@ class QEAddressDetails(QObject):
_pubkeys = None
_privkey = None
_derivationPath = None
_numtx = 0
_txlistmodel = None
_historyModel = None
detailsChanged = pyqtSignal()
@ -70,6 +72,10 @@ class QEAddressDetails(QObject):
def derivationPath(self):
return self._derivationPath
@pyqtProperty(int, notify=detailsChanged)
def numTx(self):
return self._numtx
frozenChanged = pyqtSignal()
@pyqtProperty(bool, notify=frozenChanged)
@ -95,6 +101,14 @@ class QEAddressDetails(QObject):
self._label = label
self.labelChanged.emit()
historyModelChanged = pyqtSignal()
@pyqtProperty(QETransactionListModel, notify=historyModelChanged)
def historyModel(self):
if self._historyModel is None:
self._historyModel = QETransactionListModel(self._wallet.wallet,
onchain_domain=[self._address], include_lightning=False)
return self._historyModel
def update(self):
if self._wallet is None:
self._logger.error('wallet undefined')
@ -110,4 +124,6 @@ class QEAddressDetails(QObject):
self._pubkeys = self._wallet.wallet.get_public_keys(self._address)
self._derivationPath = self._wallet.wallet.get_address_path_str(self._address)
self._derivationPath = self._derivationPath.replace('m', self._wallet.derivationPrefix)
self._numtx = self._wallet.wallet.get_address_history_len(self._address)
assert(self._numtx == self.historyModel.rowCount(0))
self.detailsChanged.emit()

7
electrum/gui/qml/qetransactionlistmodel.py

@ -9,9 +9,11 @@ from electrum.util import Satoshis, TxMinedInfo
from .qetypes import QEAmount
class QETransactionListModel(QAbstractListModel):
def __init__(self, wallet, parent=None):
def __init__(self, wallet, parent=None, *, onchain_domain=None, include_lightning=True):
super().__init__(parent)
self.wallet = wallet
self.onchain_domain = onchain_domain
self.include_lightning = include_lightning
self.init_model()
_logger = get_logger(__name__)
@ -101,7 +103,8 @@ class QETransactionListModel(QAbstractListModel):
# initial model data
def init_model(self):
history = self.wallet.get_full_history()
history = self.wallet.get_full_history(onchain_domain=self.onchain_domain,
include_lightning=self.include_lightning)
txs = []
for key, tx in history.items():
txs.append(self.tx_to_model(tx))

Loading…
Cancel
Save