Merge pull request #7640 from BlueWallet/toralert

FIX: Attempts to connect without Orbot would not indicate errors
This commit is contained in:
GLaDOS 2025-02-25 17:01:10 +00:00 committed by GitHub
commit 7205f70c30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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);