From 3fd64b60ab369909fce9026a24ebb2bcf8b06c78 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Mon, 24 Mar 2025 14:35:06 +0100 Subject: [PATCH] qml: show warning in ConfirmTxDialog if max amount cannot be fully sent due to channel reserve requirements. --- electrum/gui/qml/components/controls/TxOutput.qml | 4 +++- electrum/gui/qml/qetxfinalizer.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/electrum/gui/qml/components/controls/TxOutput.qml b/electrum/gui/qml/components/controls/TxOutput.qml index 19666f307..422d1daef 100644 --- a/electrum/gui/qml/components/controls/TxOutput.qml +++ b/electrum/gui/qml/components/controls/TxOutput.qml @@ -14,7 +14,9 @@ TextHighlightPane { property int idx: -1 property string _suffix: model.is_mine || model.is_change - ? qsTr('mine') + ? model.is_reserve + ? qsTr('reserve') + : qsTr('mine') : model.is_swap ? qsTr('swap') : model.is_billing diff --git a/electrum/gui/qml/qetxfinalizer.py b/electrum/gui/qml/qetxfinalizer.py index 373e7262d..96ac3070e 100644 --- a/electrum/gui/qml/qetxfinalizer.py +++ b/electrum/gui/qml/qetxfinalizer.py @@ -275,7 +275,8 @@ class TxFeeSlider(FeeSlider): 'is_mine': self._wallet.wallet.is_mine(o.get_ui_address_str()), 'is_change': self._wallet.wallet.is_change(o.get_ui_address_str()), 'is_billing': self._wallet.wallet.is_billing_address(o.get_ui_address_str()), - 'is_swap': False if not sm else sm.is_lockup_address_for_a_swap(o.get_ui_address_str()) or o.get_ui_address_str() == DummyAddress.SWAP + 'is_swap': False if not sm else sm.is_lockup_address_for_a_swap(o.get_ui_address_str()) or o.get_ui_address_str() == DummyAddress.SWAP, + 'is_reserve': o.is_utxo_reserve }) self.outputs = outputs @@ -417,6 +418,15 @@ class QETxFinalizer(TxFeeSlider): self.update_fee_warning_from_tx(tx=tx, invoice_amt=amount) + if self._amount.isMax and not self.warning: + if reserve_sats := sum(txo.value for txo in tx.outputs() if txo.is_utxo_reserve): + reserve_str = self._config.format_amount_and_units(reserve_sats) + self.warning = ' '.join([ + _('Warning') + ':', + _('Could not spend max: a security reserve of {} was kept for your Lightning channels.') + .format(reserve_str) + ]) + self._valid = True self.validChanged.emit()