From 4be2668c81d33bc7a05e7cb456333a5efb0a53e3 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Tue, 25 Feb 2025 11:39:56 -0400 Subject: [PATCH] FIX: Attempts to connect without Orbot would not indicate errors --- loc/en.json | 2 ++ screen/settings/ElectrumSettings.tsx | 6 +++++- screen/settings/LightningSettings.tsx | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/loc/en.json b/loc/en.json index b3fc6c5e6..b5434ebb5 100644 --- a/loc/en.json +++ b/loc/en.json @@ -243,6 +243,7 @@ "electrum_connected": "Connected", "electrum_connected_not": "Not Connected", "electrum_error_connect": "Cannot connect to the provided Electrum server", + "electrum_error_connect_tor": "Cannot connect to the provided Electrum server. Please make sure Orbot app is connected and try again.", "lndhub_uri": "E.g., {example}", "electrum_host": "E.g., {example}", "electrum_offline_mode": "Offline Mode", @@ -289,6 +290,7 @@ "language_isRTL": "Restarting BlueWallet is required for the language orientation to take effect.", "license": "License", "lightning_error_lndhub_uri": "Invalid LNDhub URI", + "lightning_error_lndhub_uri_tor": "Invalid LNDhub URI. Please make sure Orbot app is connected and try again.", "lightning_saved": "Your changes have been saved successfully.", "lightning_settings": "Lightning Settings", "lightning_settings_explain": "To connect to your own LND node, please install LNDhub and put its URL here in settings. Please note that only wallets created after saving changes will connect to the specified LNDhub.", diff --git a/screen/settings/ElectrumSettings.tsx b/screen/settings/ElectrumSettings.tsx index 7e2a56fad..64739b09c 100644 --- a/screen/settings/ElectrumSettings.tsx +++ b/screen/settings/ElectrumSettings.tsx @@ -185,7 +185,11 @@ const ElectrumSettings: React.FC = () => { if (serverHost && (serverPort || serverSslPort)) { const testConnect = await BlueElectrum.testConnection(serverHost, Number(serverPort), Number(serverSslPort)); - if (!testConnect) return; + if (!testConnect) { + return presentAlert({ + message: serverHost.endsWith('.onion') ? loc.settings.electrum_error_connect_tor : loc.settings.electrum_error_connect, + }); + } await DefaultPreference.setName(GROUP_IO_BLUEWALLET); // Clear current data for the preferred host diff --git a/screen/settings/LightningSettings.tsx b/screen/settings/LightningSettings.tsx index ee0468712..b1ff7801a 100644 --- a/screen/settings/LightningSettings.tsx +++ b/screen/settings/LightningSettings.tsx @@ -80,10 +80,11 @@ const LightningSettings: React.FC = () => { }; const save = useCallback(async () => { setIsLoading(true); + let normalizedURI; try { await DefaultPreference.setName(GROUP_IO_BLUEWALLET); if (URI) { - const normalizedURI = new URL(URI.replace(/([^:]\/)\/+/g, '$1')).toString(); + normalizedURI = new URL(URI.replace(/([^:]\/)\/+/g, '$1')).toString(); await LightningCustodianWallet.isValidNodeAddress(normalizedURI); await setLNDHub(normalizedURI); @@ -95,7 +96,9 @@ const LightningSettings: React.FC = () => { triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess); } catch (error) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - presentAlert({ message: loc.settings.lightning_error_lndhub_uri }); + presentAlert({ + message: normalizedURI?.endsWith('.onion') ? loc.settings.lightning_error_lndhub_uri_tor : loc.settings.lightning_error_lndhub_uri, + }); console.log(error); } setIsLoading(false);