add numtx and address history model to addres details
This commit is contained in:
@@ -215,6 +215,15 @@ Pane {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr('Transactions')
|
||||||
|
color: Material.accentColor
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: addressdetails.numTx
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: qsTr('Derivation path')
|
text: qsTr('Derivation path')
|
||||||
color: Material.accentColor
|
color: Material.accentColor
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from electrum.util import DECIMAL_POINT_DEFAULT
|
|||||||
|
|
||||||
from .qewallet import QEWallet
|
from .qewallet import QEWallet
|
||||||
from .qetypes import QEAmount
|
from .qetypes import QEAmount
|
||||||
|
from .qetransactionlistmodel import QETransactionListModel
|
||||||
|
|
||||||
class QEAddressDetails(QObject):
|
class QEAddressDetails(QObject):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
@@ -25,8 +26,9 @@ class QEAddressDetails(QObject):
|
|||||||
_pubkeys = None
|
_pubkeys = None
|
||||||
_privkey = None
|
_privkey = None
|
||||||
_derivationPath = None
|
_derivationPath = None
|
||||||
|
_numtx = 0
|
||||||
|
|
||||||
_txlistmodel = None
|
_historyModel = None
|
||||||
|
|
||||||
detailsChanged = pyqtSignal()
|
detailsChanged = pyqtSignal()
|
||||||
|
|
||||||
@@ -70,6 +72,10 @@ class QEAddressDetails(QObject):
|
|||||||
def derivationPath(self):
|
def derivationPath(self):
|
||||||
return self._derivationPath
|
return self._derivationPath
|
||||||
|
|
||||||
|
@pyqtProperty(int, notify=detailsChanged)
|
||||||
|
def numTx(self):
|
||||||
|
return self._numtx
|
||||||
|
|
||||||
|
|
||||||
frozenChanged = pyqtSignal()
|
frozenChanged = pyqtSignal()
|
||||||
@pyqtProperty(bool, notify=frozenChanged)
|
@pyqtProperty(bool, notify=frozenChanged)
|
||||||
@@ -95,6 +101,14 @@ class QEAddressDetails(QObject):
|
|||||||
self._label = label
|
self._label = label
|
||||||
self.labelChanged.emit()
|
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):
|
def update(self):
|
||||||
if self._wallet is None:
|
if self._wallet is None:
|
||||||
self._logger.error('wallet undefined')
|
self._logger.error('wallet undefined')
|
||||||
@@ -110,4 +124,6 @@ class QEAddressDetails(QObject):
|
|||||||
self._pubkeys = self._wallet.wallet.get_public_keys(self._address)
|
self._pubkeys = self._wallet.wallet.get_public_keys(self._address)
|
||||||
self._derivationPath = self._wallet.wallet.get_address_path_str(self._address)
|
self._derivationPath = self._wallet.wallet.get_address_path_str(self._address)
|
||||||
self._derivationPath = self._derivationPath.replace('m', self._wallet.derivationPrefix)
|
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()
|
self.detailsChanged.emit()
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ from electrum.util import Satoshis, TxMinedInfo
|
|||||||
from .qetypes import QEAmount
|
from .qetypes import QEAmount
|
||||||
|
|
||||||
class QETransactionListModel(QAbstractListModel):
|
class QETransactionListModel(QAbstractListModel):
|
||||||
def __init__(self, wallet, parent=None):
|
def __init__(self, wallet, parent=None, *, onchain_domain=None, include_lightning=True):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.wallet = wallet
|
self.wallet = wallet
|
||||||
|
self.onchain_domain = onchain_domain
|
||||||
|
self.include_lightning = include_lightning
|
||||||
self.init_model()
|
self.init_model()
|
||||||
|
|
||||||
_logger = get_logger(__name__)
|
_logger = get_logger(__name__)
|
||||||
@@ -101,7 +103,8 @@ class QETransactionListModel(QAbstractListModel):
|
|||||||
|
|
||||||
# initial model data
|
# initial model data
|
||||||
def init_model(self):
|
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 = []
|
txs = []
|
||||||
for key, tx in history.items():
|
for key, tx in history.items():
|
||||||
txs.append(self.tx_to_model(tx))
|
txs.append(self.tx_to_model(tx))
|
||||||
|
|||||||
Reference in New Issue
Block a user