From 6cd42faa68bbafa92ac0036b89bf21bf0cac9455 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sat, 16 Sep 2023 15:29:12 +0200 Subject: [PATCH] QML: show onchain and offchain amounts for groups in txdetails --- electrum/gui/qml/components/TxDetails.qml | 16 ++++++++++++---- electrum/gui/qml/qetxdetails.py | 10 +++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/electrum/gui/qml/components/TxDetails.qml b/electrum/gui/qml/components/TxDetails.qml index cf4624b3d..139ec1646 100644 --- a/electrum/gui/qml/components/TxDetails.qml +++ b/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 diff --git a/electrum/gui/qml/qetxdetails.py b/electrum/gui/qml/qetxdetails.py index 8732f9776..b70bc838c 100644 --- a/electrum/gui/qml/qetxdetails.py +++ b/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