From a9282c0e360f46228ce41c72ae56bb6046aafbb0 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Thu, 22 Feb 2024 17:16:56 +0100 Subject: [PATCH] qml: add tx options to ConfirmTxDialog, RbfBumpFeeDialog --- .../gui/qml/components/ConfirmTxDialog.qml | 60 +++++++++++++++++++ .../gui/qml/components/RbfBumpFeeDialog.qml | 40 +++++++++++++ electrum/gui/qml/qeconfig.py | 11 ++++ electrum/gui/qml/qetxfinalizer.py | 4 ++ electrum/gui/qml/qewallet.py | 12 ++++ 5 files changed, 127 insertions(+) diff --git a/electrum/gui/qml/components/ConfirmTxDialog.qml b/electrum/gui/qml/components/ConfirmTxDialog.qml index cef9e081e..1f2e6d67b 100644 --- a/electrum/gui/qml/components/ConfirmTxDialog.qml +++ b/electrum/gui/qml/components/ConfirmTxDialog.qml @@ -137,6 +137,66 @@ ElDialog { } } + ToggleLabel { + id: optionstoggle + Layout.columnSpan: 2 + labelText: qsTr('Options') + color: Material.accentColor + } + + TextHighlightPane { + Layout.columnSpan: 2 + Layout.fillWidth: true + visible: !optionstoggle.collapsed + height: optionslayout.height + + GridLayout { + id: optionslayout + width: parent.width + columns: 2 + + ElCheckBox { + Layout.fillWidth: true + text: qsTr('Use multiple change addresses') + onCheckedChanged: { + if (activeFocus) { + Daemon.currentWallet.multipleChange = checked + finalizer.doUpdate() + } + } + Component.onCompleted: { + checked = Daemon.currentWallet.multipleChange + } + } + + HelpButton { + heading: qsTr('Use multiple change addresses') + helptext: qsTr('To somewhat protect your privacy, Electrum tries to create change with similar precision to other outputs.') + } + + ElCheckBox { + Layout.fillWidth: true + text: qsTr('Enable output value rounding') + onCheckedChanged: { + if (activeFocus) { + Config.outputValueRounding = checked + finalizer.doUpdate() + } + } + Component.onCompleted: { + checked = Config.outputValueRounding + } + } + + HelpButton { + heading: qsTr('Enable output value rounding') + helptext: qsTr('In some cases, use up to 3 change addresses in order to break up large coin amounts and obfuscate the recipient address.') + + ' ' + qsTr('This may result in higher transactions fees.') + } + + } + } + InfoTextArea { Layout.columnSpan: 2 Layout.fillWidth: true diff --git a/electrum/gui/qml/components/RbfBumpFeeDialog.qml b/electrum/gui/qml/components/RbfBumpFeeDialog.qml index 22e02eb82..e3199c7ae 100644 --- a/electrum/gui/qml/components/RbfBumpFeeDialog.qml +++ b/electrum/gui/qml/components/RbfBumpFeeDialog.qml @@ -120,6 +120,46 @@ ElDialog { } } + ToggleLabel { + id: optionstoggle + Layout.columnSpan: 2 + labelText: qsTr('Options') + color: Material.accentColor + } + + TextHighlightPane { + Layout.columnSpan: 2 + Layout.fillWidth: true + visible: !optionstoggle.collapsed + height: optionslayout.height + + GridLayout { + id: optionslayout + width: parent.width + columns: 2 + + ElCheckBox { + Layout.fillWidth: true + text: qsTr('Enable output value rounding') + onCheckedChanged: { + if (activeFocus) { + Config.outputValueRounding = checked + rbffeebumper.doUpdate() + } + } + Component.onCompleted: { + checked = Config.outputValueRounding + } + } + + HelpButton { + heading: qsTr('Enable output value rounding') + helptext: qsTr('In some cases, use up to 3 change addresses in order to break up large coin amounts and obfuscate the recipient address.') + + ' ' + qsTr('This may result in higher transactions fees.') + } + } + } + InfoTextArea { Layout.columnSpan: 2 Layout.preferredWidth: parent.width * 3/4 diff --git a/electrum/gui/qml/qeconfig.py b/electrum/gui/qml/qeconfig.py index 32d4a57cf..534e3cdf0 100644 --- a/electrum/gui/qml/qeconfig.py +++ b/electrum/gui/qml/qeconfig.py @@ -244,6 +244,17 @@ class QEConfig(AuthMixin, QObject): self.config.GUI_QML_ADDRESS_LIST_SHOW_USED = addresslistShowUsed self.addresslistShowUsedChanged.emit() + outputValueRoundingChanged = pyqtSignal() + @pyqtProperty(bool, notify=outputValueRoundingChanged) + def outputValueRounding(self): + return self.config.WALLET_COIN_CHOOSER_OUTPUT_ROUNDING + + @outputValueRounding.setter + def outputValueRounding(self, outputValueRounding): + if outputValueRounding != self.config.WALLET_COIN_CHOOSER_OUTPUT_ROUNDING: + self.config.WALLET_COIN_CHOOSER_OUTPUT_ROUNDING = outputValueRounding + self.outputValueRoundingChanged.emit() + @pyqtSlot('qint64', result=str) @pyqtSlot(QEAmount, result=str) def formatSatsForEditing(self, satoshis): diff --git a/electrum/gui/qml/qetxfinalizer.py b/electrum/gui/qml/qetxfinalizer.py index 28e84a2a2..56548bef2 100644 --- a/electrum/gui/qml/qetxfinalizer.py +++ b/electrum/gui/qml/qetxfinalizer.py @@ -214,6 +214,10 @@ class TxFeeSlider(FeeSlider): def valid(self): return self._valid + @pyqtSlot() + def doUpdate(self): + self.update() + def update_from_tx(self, tx): tx_size = tx.estimated_size() fee = tx.get_fee() diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index 30a839a09..66fa2aac8 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -161,6 +161,18 @@ class QEWallet(AuthMixin, QObject, QtEventListener): self._logger.info(progress) self.synchronizingProgressChanged.emit() + multipleChangeChanged = pyqtSignal() + @pyqtProperty(bool, notify=multipleChangeChanged) + def multipleChange(self): + return self.wallet.multiple_change + + @multipleChange.setter + def multipleChange(self, multiple_change): + if self.wallet.multiple_change != multiple_change: + self.wallet.multiple_change = multiple_change + self.wallet.db.put('multiple_change', self.wallet.multiple_change) + self.multipleChangeChanged.emit() + @qt_event_listener def on_event_request_status(self, wallet, key, status): if wallet == self.wallet: