Browse Source

QML: show onchain and offchain amounts for groups in txdetails

master
ThomasV 2 years ago
parent
commit
6cd42faa68
  1. 16
      electrum/gui/qml/components/TxDetails.qml
  2. 10
      electrum/gui/qml/qetxdetails.py

16
electrum/gui/qml/components/TxDetails.qml

@ -68,13 +68,21 @@ Pane {
}
Label {
visible: !txdetails.isUnrelated && txdetails.lnAmount.satsInt == 0
visible: !txdetails.isUnrelated && txdetails.amount.satsInt != 0
text: txdetails.amount.satsInt > 0
? qsTr('Amount received')
: qsTr('Amount sent')
? qsTr('Amount received onchain')
: qsTr('Amount sent onchain')
color: Material.accentColor
}
FormattedAmount {
visible: !txdetails.isUnrelated && txdetails.amount.satsInt != 0
Layout.preferredWidth: 1
Layout.fillWidth: true
amount: txdetails.amount
timestamp: txdetails.timestamp
}
Label {
Layout.fillWidth: true
visible: !txdetails.isUnrelated && txdetails.lnAmount.satsInt != 0
@ -86,7 +94,7 @@ Pane {
}
FormattedAmount {
visible: !txdetails.isUnrelated
visible: !txdetails.isUnrelated && txdetails.lnAmount.satsInt != 0
Layout.preferredWidth: 1
Layout.fillWidth: true
amount: txdetails.lnAmount.isEmpty ? txdetails.amount : txdetails.lnAmount

10
electrum/gui/qml/qetxdetails.py

@ -284,10 +284,18 @@ class QETxDetails(QObject, QtEventListener):
self._mempool_depth = self._wallet.wallet.config.depth_tooltip(txinfo.mempool_depth_bytes)
if self._wallet.wallet.lnworker:
# Calling lnworker.get_onchain_history and wallet.get_full_history here
# is inefficient. We should probably pass the tx_item to the constructor.
lnworker_history = self._wallet.wallet.lnworker.get_onchain_history()
if self._txid in lnworker_history:
item = lnworker_history[self._txid]
self._lnamount.satsInt = int(item['amount_msat'] / 1000)
group_id = item.get('group_id')
if group_id:
full_history = self._wallet.wallet.get_full_history()
group_item = full_history['group:'+ group_id]
self._lnamount.satsInt = int(group_item['ln_value'].value)
else:
self._lnamount.satsInt = int(item['amount_msat'] / 1000)
else:
self._lnamount.satsInt = 0

Loading…
Cancel
Save