From 8f1382d00df1841c51cfa0ffa11ec545f400ebcf Mon Sep 17 00:00:00 2001 From: gerlofvanek Date: Thu, 29 Jan 2026 11:50:51 +0100 Subject: [PATCH] Fixed electrum logic (settings). - Fixed empty arrays to fall back to default servers. - Fixed RPC/Electrum settings logic. - Added option set electrum servers before switch RPC -> Electrum mode. - Fixed "No servers discovered", some servers don't support peer discovery. --- basicswap/static/js/pages/settings-page.js | 36 +++++++++++++++++++++- basicswap/templates/settings.html | 14 ++++++--- basicswap/ui/page_settings.py | 4 +-- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/basicswap/static/js/pages/settings-page.js b/basicswap/static/js/pages/settings-page.js index 5a86462..b0994e7 100644 --- a/basicswap/static/js/pages/settings-page.js +++ b/basicswap/static/js/pages/settings-page.js @@ -72,6 +72,39 @@ connectionTypeSelects.forEach(select => { const originalValue = select.dataset.originalValue || select.value; this.originalConnectionTypes[select.name] = originalValue; + + select.addEventListener('change', (e) => { + const coinName = select.name.replace('connection_type_', ''); + const electrumSection = document.getElementById(`electrum-section-${coinName}`); + const fundTransferSection = document.getElementById(`fund-transfer-section-${coinName}`); + const originalValue = this.originalConnectionTypes[select.name]; + + if (e.target.value === 'electrum') { + if (electrumSection) { + electrumSection.classList.remove('hidden'); + + const clearnetTextarea = document.getElementById(`electrum_clearnet_${coinName}`); + const onionTextarea = document.getElementById(`electrum_onion_${coinName}`); + + if (clearnetTextarea && !clearnetTextarea.value.trim()) { + clearnetTextarea.value = electrumSection.dataset.defaultClearnet || ''; + } + if (onionTextarea && !onionTextarea.value.trim()) { + onionTextarea.value = electrumSection.dataset.defaultOnion || ''; + } + } + if (fundTransferSection) { + fundTransferSection.classList.add('hidden'); + } + } else { + if (electrumSection) { + electrumSection.classList.add('hidden'); + } + if (fundTransferSection && originalValue === 'electrum') { + fundTransferSection.classList.remove('hidden'); + } + } + }); }); this.setupWalletModeModal(); @@ -561,7 +594,8 @@ } if (!data.clearnet_servers?.length && !data.onion_servers?.length) { - html = '
No servers discovered. The connected server may not support peer discovery.
'; + const serverName = data.current_server ? `${data.current_server.host}:${data.current_server.port}` : 'The connected server'; + html = `
No servers discovered. ${serverName} does not return peer lists.
`; } else { html += `
Click a server to add it to your list
`; } diff --git a/basicswap/templates/settings.html b/basicswap/templates/settings.html index 8c351c5..b397afa 100644 --- a/basicswap/templates/settings.html +++ b/basicswap/templates/settings.html @@ -204,8 +204,10 @@ - {% if c.connection_type == 'electrum' %} -
+ {% if c.supports_electrum %} +

Electrum Servers

@@ -213,7 +215,7 @@
Clearnet
- +

One per line. Format: host:port (50002=SSL, 50001=non-SSL)

@@ -221,7 +223,7 @@
TOR (.onion)
- +

One per line. Used when TOR is enabled.

@@ -253,8 +255,10 @@
+ -
+ +