qml: expose more flags and TxMinedInfo in qetxdetails
This commit is contained in:
@@ -50,12 +50,85 @@ Pane {
|
||||
width: parent.width
|
||||
columns: 2
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
visible: txdetails.lnAmount.satsInt == 0
|
||||
text: txdetails.amount.satsInt > 0
|
||||
? qsTr('Amount received')
|
||||
: qsTr('Amount sent')
|
||||
color: Material.accentColor
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
visible: txdetails.lnAmount.satsInt != 0
|
||||
text: txdetails.lnAmount.satsInt > 0
|
||||
? qsTr('Amount received in channels')
|
||||
: qsTr('Amount withdrawn from channels')
|
||||
color: Material.accentColor
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Label {
|
||||
visible: txdetails.lnAmount.satsInt == 0
|
||||
text: Config.formatSats(txdetails.amount)
|
||||
font.family: FixedFont
|
||||
}
|
||||
Label {
|
||||
visible: txdetails.lnAmount.satsInt != 0
|
||||
text: Config.formatSats(txdetails.lnAmount)
|
||||
font.family: FixedFont
|
||||
}
|
||||
Label {
|
||||
text: Config.baseUnit
|
||||
color: Material.accentColor
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
visible: Daemon.fx.enabled; Layout.preferredWidth: 1; Layout.preferredHeight: 1
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: Daemon.fx.enabled && txdetails.lnAmount.satsInt == 0
|
||||
text: Daemon.fx.fiatValue(txdetails.amount, false) + ' ' + Daemon.fx.fiatCurrency
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: Daemon.fx.enabled && txdetails.lnAmount.satsInt != 0
|
||||
text: Daemon.fx.fiatValue(txdetails.lnAmount, false) + ' ' + Daemon.fx.fiatCurrency
|
||||
}
|
||||
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
visible: txdetails.amount.satsInt < 0
|
||||
text: qsTr('Transaction fee')
|
||||
color: Material.accentColor
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
visible: txdetails.amount.satsInt < 0
|
||||
Label {
|
||||
text: Config.formatSats(txdetails.fee)
|
||||
font.family: FixedFont
|
||||
}
|
||||
Label {
|
||||
text: Config.baseUnit
|
||||
color: Material.accentColor
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr('Status')
|
||||
color: Material.accentColor
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: txdetails.status
|
||||
}
|
||||
|
||||
@@ -71,48 +144,36 @@ Pane {
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: txdetails.isMined
|
||||
text: qsTr('Date')
|
||||
color: Material.accentColor
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: txdetails.isMined
|
||||
text: txdetails.date
|
||||
}
|
||||
|
||||
Label {
|
||||
text: txdetails.amount.satsInt > 0
|
||||
? qsTr('Amount received')
|
||||
: qsTr('Amount sent')
|
||||
visible: txdetails.isMined
|
||||
text: qsTr('Height')
|
||||
color: Material.accentColor
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Label {
|
||||
text: Config.formatSats(txdetails.amount)
|
||||
font.family: FixedFont
|
||||
}
|
||||
Label {
|
||||
text: Config.baseUnit
|
||||
color: Material.accentColor
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: txdetails.amount.satsInt < 0
|
||||
text: qsTr('Transaction fee')
|
||||
visible: txdetails.isMined
|
||||
text: txdetails.height
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: txdetails.isMined
|
||||
text: qsTr('TX index')
|
||||
color: Material.accentColor
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
visible: txdetails.amount.satsInt < 0
|
||||
Label {
|
||||
text: Config.formatSats(txdetails.fee)
|
||||
font.family: FixedFont
|
||||
}
|
||||
Label {
|
||||
text: Config.baseUnit
|
||||
color: Material.accentColor
|
||||
}
|
||||
Label {
|
||||
visible: txdetails.isMined
|
||||
text: txdetails.txpos
|
||||
}
|
||||
|
||||
Label {
|
||||
|
||||
@@ -14,9 +14,31 @@ class QETxDetails(QObject):
|
||||
|
||||
_wallet = None
|
||||
_txid = None
|
||||
_label = ''
|
||||
|
||||
_mempool_depth = None
|
||||
_date = None
|
||||
_status = ''
|
||||
_amount = QEAmount(amount_sat=0)
|
||||
_fee = QEAmount(amount_sat=0)
|
||||
_inputs = []
|
||||
_outputs = []
|
||||
|
||||
_is_lightning_funding_tx = False
|
||||
_can_bump = False
|
||||
_can_dscancel = False
|
||||
_can_broadcast = False
|
||||
_can_cpfp = False
|
||||
_can_save_as_local = False
|
||||
_can_remove = False
|
||||
|
||||
_is_mined = False
|
||||
|
||||
_mempool_depth = ''
|
||||
|
||||
_date = ''
|
||||
_height = 0
|
||||
_confirmations = 0
|
||||
_txpos = -1
|
||||
_header_hash = ''
|
||||
|
||||
detailsChanged = pyqtSignal()
|
||||
|
||||
@@ -60,30 +82,6 @@ class QETxDetails(QObject):
|
||||
def status(self):
|
||||
return self._status
|
||||
|
||||
@pyqtProperty(str, notify=detailsChanged)
|
||||
def date(self):
|
||||
return self._date
|
||||
|
||||
@pyqtProperty(str, notify=detailsChanged)
|
||||
def mempoolDepth(self):
|
||||
return self._mempool_depth
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def isMined(self):
|
||||
return self._is_mined
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def isLightningFundingTx(self):
|
||||
return self._is_lightning_funding_tx
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def canBump(self):
|
||||
return self._can_bump
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def canCancel(self):
|
||||
return self._can_dscancel
|
||||
|
||||
@pyqtProperty(QEAmount, notify=detailsChanged)
|
||||
def amount(self):
|
||||
return self._amount
|
||||
@@ -100,6 +98,62 @@ class QETxDetails(QObject):
|
||||
def outputs(self):
|
||||
return self._outputs
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def isMined(self):
|
||||
return self._is_mined
|
||||
|
||||
@pyqtProperty(str, notify=detailsChanged)
|
||||
def mempoolDepth(self):
|
||||
return self._mempool_depth
|
||||
|
||||
@pyqtProperty(str, notify=detailsChanged)
|
||||
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 headerHash(self):
|
||||
return self._header_hash
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def isLightningFundingTx(self):
|
||||
return self._is_lightning_funding_tx
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def canBump(self):
|
||||
return self._can_bump
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def canCancel(self):
|
||||
return self._can_dscancel
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def canBroadcast(self):
|
||||
return self._can_broadcast
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def canCpfp(self):
|
||||
return self._can_cpfp
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def canSaveAsLocal(self):
|
||||
return self._can_save_as_local
|
||||
|
||||
@pyqtProperty(bool, notify=detailsChanged)
|
||||
def canRemove(self):
|
||||
return self._can_remove
|
||||
|
||||
def update(self):
|
||||
if self._wallet is None:
|
||||
self._logger.error('wallet undefined')
|
||||
@@ -108,6 +162,8 @@ class QETxDetails(QObject):
|
||||
# abusing get_input_tx to get tx from txid
|
||||
tx = self._wallet.wallet.get_input_tx(self._txid)
|
||||
|
||||
#self._logger.debug(repr(tx.to_json()))
|
||||
|
||||
self._inputs = list(map(lambda x: x.to_json(), tx.inputs()))
|
||||
self._outputs = list(map(lambda x: {
|
||||
'address': x.get_ui_address_str(),
|
||||
@@ -116,26 +172,46 @@ class QETxDetails(QObject):
|
||||
}, tx.outputs()))
|
||||
|
||||
txinfo = self._wallet.wallet.get_tx_info(tx)
|
||||
|
||||
#self._logger.debug(repr(txinfo))
|
||||
|
||||
# can be None if outputs unrelated to wallet seed,
|
||||
# e.g. to_local local_force_close commitment CSV-locked p2wsh script
|
||||
if txinfo.amount is None:
|
||||
self._amount = QEAmount(amount_sat=0)
|
||||
else:
|
||||
self._amount = QEAmount(amount_sat=txinfo.amount)
|
||||
|
||||
self._status = txinfo.status
|
||||
self._label = txinfo.label
|
||||
self._amount = QEAmount(amount_sat=txinfo.amount) # can be None?
|
||||
self._fee = QEAmount(amount_sat=txinfo.fee)
|
||||
|
||||
self._is_mined = txinfo.tx_mined_status != None
|
||||
if self._is_mined:
|
||||
self._date = format_time(txinfo.tx_mined_status.timestamp)
|
||||
self.update_mined_status(txinfo.tx_mined_status)
|
||||
else:
|
||||
#TODO mempool_depth_bytes can be None?
|
||||
# TODO mempool_depth_bytes can be None if not mined?
|
||||
if txinfo.mempool_depth_bytes is None:
|
||||
self._logger.error('TX is not mined, yet mempool_depth_bytes is None')
|
||||
self._mempool_depth = self._wallet.wallet.config.depth_tooltip(txinfo.mempool_depth_bytes)
|
||||
|
||||
self._is_lightning_funding_tx = txinfo.is_lightning_funding_tx
|
||||
self._can_bump = txinfo.can_bump
|
||||
self._can_dscancel = txinfo.can_dscancel
|
||||
|
||||
self._logger.debug(repr(txinfo.mempool_depth_bytes))
|
||||
self._logger.debug(repr(txinfo.can_broadcast))
|
||||
self._logger.debug(repr(txinfo.can_cpfp))
|
||||
self._logger.debug(repr(txinfo.can_save_as_local))
|
||||
self._logger.debug(repr(txinfo.can_remove))
|
||||
self._can_broadcast = txinfo.can_broadcast
|
||||
self._can_cpfp = txinfo.can_cpfp
|
||||
self._can_save_as_local = txinfo.can_save_as_local
|
||||
self._can_remove = txinfo.can_remove
|
||||
|
||||
self.detailsChanged.emit()
|
||||
|
||||
if self._label != txinfo.label:
|
||||
self._label = txinfo.label
|
||||
self.labelChanged.emit()
|
||||
|
||||
def update_mined_status(self, tx_mined_info):
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user