diff --git a/electrum/gui/qml/components/ServerConfigDialog.qml b/electrum/gui/qml/components/ServerConfigDialog.qml index d5304e064..2d779b97b 100644 --- a/electrum/gui/qml/components/ServerConfigDialog.qml +++ b/electrum/gui/qml/components/ServerConfigDialog.qml @@ -44,6 +44,9 @@ ElDialog { onClicked: { Config.autoConnect = serverconfig.auto_connect Network.server = serverconfig.address + Network.oneServer = serverconfig.auto_connect + ? false + : serverconfig.one_server rootItem.close() } } diff --git a/electrum/gui/qml/components/controls/ServerConfig.qml b/electrum/gui/qml/components/controls/ServerConfig.qml index 9c7160489..12227d03b 100644 --- a/electrum/gui/qml/components/controls/ServerConfig.qml +++ b/electrum/gui/qml/components/controls/ServerConfig.qml @@ -12,6 +12,7 @@ Item { property bool showAutoselectServer: true property alias auto_connect: auto_server_cb.checked property alias address: address_tf.text + property alias one_server: one_server_cb.checked implicitHeight: rootLayout.height @@ -26,7 +27,7 @@ Item { id: auto_server_cb visible: showAutoselectServer text: qsTr('Select server automatically') - checked: true + checked: !showAutoselectServer } Label { @@ -45,6 +46,22 @@ Item { } } + RowLayout { + Layout.fillWidth: true + visible: !auto_server_cb.checked && address_tf.text + + CheckBox { + id: one_server_cb + Layout.fillWidth: true + text: qsTr('One server') + } + + HelpButton { + heading: qsTr('One server') + helptext: qsTr('Connect only to a single Electrum Server. This can help with privacy, but at the cost of detecting lagging and forks') + } + } + ColumnLayout { Heading { text: qsTr('Servers') @@ -96,6 +113,7 @@ Item { Component.onCompleted: { root.auto_connect = Config.autoConnectDefined ? Config.autoConnect : false root.address = Network.server + one_server_cb.checked = Network.oneServer // TODO: initial setup should not connect already, is Network.server defined? } } diff --git a/electrum/gui/qml/components/wizard/WCServerConfig.qml b/electrum/gui/qml/components/wizard/WCServerConfig.qml index df114f84a..a48a1bd70 100644 --- a/electrum/gui/qml/components/wizard/WCServerConfig.qml +++ b/electrum/gui/qml/components/wizard/WCServerConfig.qml @@ -12,6 +12,7 @@ WizardComponent { function apply() { wizard_data['autoconnect'] = sc.address.trim() == "" wizard_data['server'] = sc.address + wizard_data['one_server'] = sc.one_server } ColumnLayout { diff --git a/electrum/gui/qml/qenetwork.py b/electrum/gui/qml/qenetwork.py index 25dc1c24f..a8074647e 100644 --- a/electrum/gui/qml/qenetwork.py +++ b/electrum/gui/qml/qenetwork.py @@ -254,6 +254,18 @@ class QENetwork(QObject, QtEventListener): def isProxyTor(self): return bool(self.network.is_proxy_tor) + @pyqtProperty(bool, notify=statusChanged) + def oneServer(self): + return self.network.oneserver + + @oneServer.setter + def oneServer(self, one_server: bool): + if one_server != self.network.oneserver: + net_params = self.network.get_parameters() + net_params = net_params._replace(oneserver=one_server) + self.network.run_from_another_thread(self.network.set_parameters(net_params)) + self.statusChanged.emit() + @pyqtProperty('QVariant', notify=feeHistogramUpdated) def feeHistogram(self): return self._fee_histogram diff --git a/electrum/gui/qt/wizard/server_connect.py b/electrum/gui/qt/wizard/server_connect.py index cebe6f146..0c6b88b36 100644 --- a/electrum/gui/qt/wizard/server_connect.py +++ b/electrum/gui/qt/wizard/server_connect.py @@ -96,3 +96,4 @@ class WCServerConfig(WizardComponent): def apply(self): self.wizard_data['autoconnect'] = self.sw.server_e.text().strip() == '' self.wizard_data['server'] = self.sw.server_e.text() + self.wizard_data['one_server'] = False diff --git a/electrum/wizard.py b/electrum/wizard.py index c5e748013..0fae46537 100644 --- a/electrum/wizard.py +++ b/electrum/wizard.py @@ -745,6 +745,7 @@ class ServerConnectWizard(AbstractWizard): self._logger.debug(f'configuring server: {wizard_data!r}') net_params = self._daemon.network.get_parameters() server = '' + oneserver = wizard_data.get('one_server', False) if not wizard_data['autoconnect']: try: server = ServerAddr.from_str_with_inference(wizard_data['server']) @@ -752,7 +753,9 @@ class ServerConnectWizard(AbstractWizard): raise Exception('failed to parse server %s' % wizard_data['server']) except Exception: return - net_params = net_params._replace(server=server, auto_connect=wizard_data['autoconnect']) + else: + oneserver = False + net_params = net_params._replace(server=server, auto_connect=wizard_data['autoconnect'], oneserver=oneserver) self._daemon.network.run_from_another_thread(self._daemon.network.set_parameters(net_params)) def do_configure_autoconnect(self, wizard_data: dict):