1
0

QML: show onchain and offchain amounts for groups in txdetails

This commit is contained in:
ThomasV
2023-09-16 15:29:12 +02:00
parent 7eabbbc81f
commit 6cd42faa68
2 changed files with 21 additions and 5 deletions

View File

@@ -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

View File

@@ -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