From 96af21faeb9fa4e896d0dfcd39bb376de6683e8b Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 2 Dec 2022 13:50:31 +0100 Subject: [PATCH] qml: show extra fee in ConfirmTxDialog (2fa) --- .../gui/qml/components/ConfirmTxDialog.qml | 18 +++++++++++++++++ electrum/gui/qml/qetxfinalizer.py | 20 +++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/electrum/gui/qml/components/ConfirmTxDialog.qml b/electrum/gui/qml/components/ConfirmTxDialog.qml index 5c5cdbbc5..4eab721f3 100644 --- a/electrum/gui/qml/components/ConfirmTxDialog.qml +++ b/electrum/gui/qml/components/ConfirmTxDialog.qml @@ -106,6 +106,24 @@ ElDialog { } } + Label { + visible: !finalizer.extraFee.isEmpty + text: qsTr('Extra fee') + color: Material.accentColor + } + + RowLayout { + visible: !finalizer.extraFee.isEmpty + Label { + text: Config.formatSats(finalizer.extraFee) + } + + Label { + text: Config.baseUnit + color: Material.accentColor + } + } + Label { text: qsTr('Fee rate') color: Material.accentColor diff --git a/electrum/gui/qml/qetxfinalizer.py b/electrum/gui/qml/qetxfinalizer.py index f532cbed4..d177bd218 100644 --- a/electrum/gui/qml/qetxfinalizer.py +++ b/electrum/gui/qml/qetxfinalizer.py @@ -9,6 +9,7 @@ from electrum.transaction import PartialTxOutput, PartialTransaction from electrum.util import NotEnoughFunds, profiler from electrum.wallet import CannotBumpFee, CannotDoubleSpendTx, CannotCPFP from electrum.network import NetworkException +from electrum.plugin import run_hook from .qewallet import QEWallet from .qetypes import QEAmount @@ -227,6 +228,7 @@ class QETxFinalizer(TxFeeSlider): _address = '' _amount = QEAmount() _effectiveAmount = QEAmount() + _extraFee = QEAmount() _canRbf = False addressChanged = pyqtSignal() @@ -257,6 +259,17 @@ class QETxFinalizer(TxFeeSlider): def effectiveAmount(self): return self._effectiveAmount + extraFeeChanged = pyqtSignal() + @pyqtProperty(QEAmount, notify=extraFeeChanged) + def extraFee(self): + return self._extraFee + + @extraFee.setter + def extraFee(self, extrafee): + if self._extraFee != extrafee: + self._extraFee.copyFrom(extrafee) + self.extraFeeChanged.emit() + canRbfChanged = pyqtSignal() @pyqtProperty(bool, notify=canRbfChanged) def canRbf(self): @@ -311,8 +324,11 @@ class QETxFinalizer(TxFeeSlider): self.update_from_tx(tx) - #TODO - #x_fee = run_hook('get_tx_extra_fee', self._wallet.wallet, tx) + x_fee = run_hook('get_tx_extra_fee', self._wallet.wallet, tx) + if x_fee: + x_fee_address, x_fee_amount = x_fee + self.extraFee = QEAmount(amount_sat=x_fee_amount) + fee_warning_tuple = self._wallet.wallet.get_tx_fee_warning( invoice_amt=amount, tx_size=tx.estimated_size(), fee=tx.get_fee()) if fee_warning_tuple: