FIX: Attempts to connect without Orbot would not indicate errors

This commit is contained in:
Marcos Rodriguez Velez 2025-02-25 11:39:56 -04:00
parent 3f1ea9432b
commit 4be2668c81
3 changed files with 12 additions and 3 deletions

View file

@ -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.",

View file

@ -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

View file

@ -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);