What changed, and why it matters
This commit rewrites how Skylight Wallet's background Monero syncing is configured. It replaces separate 'Background Sync' and 'Continuous Sync' toggles with a single 'Sync Frequency' setting, moves that setting out of the connection form and into the main Settings screen, and adds user-facing warnings when a light-wallet server has not yet approved the wallet or its restore height. The changes are mostly user-interface and scheduling plumbing; they do not appear to introduce a clear security vulnerability, but they do touch code that decides when the app runs with only the view key in the background, when it contacts servers, and how connection addresses are validated.
Treat as a normal feature/refactor review. Verify that the new applySyncFrequency path correctly enforces the documented view-key-only behavior on both Android and iOS, that the migration from old boolean flags to SyncFrequency preserves user intent, and that the path-rejection logic cannot be bypassed by URL encoding or trailing slashes. No immediate security response is indicated by the diff alone.
Security signals we found
Background/foreground sync scheduling logic changed
New server-approval state surfaced to users (LwsPendingApproval)
Connection address validation tightened to reject unsupported paths
SharedPreferences sync flags removed and migrated
iOS background sync behavior expanded from LWS-only to Sync Frequency-driven
Evidence from the diff
The patch is a feature refactor of sync scheduling and related UI. Key code changes: (1) SharedPreferences keys for backgroundSyncEnabled/foregroundSyncEnabled are removed in favor of a new SyncFrequency enum loaded from wallet_infra. (2) ConnectionSettingsForm no longer hosts sync toggles; it now rejects paths for server types that do not support them via a new ConnectionAddressError.pathNotSupported check. (3) A new sync_frequency_sheet.dart applies the chosen frequency through applySyncFrequency, which manages the continuous foreground service and periodic background tasks. (4) Wallet home now displays LwsPendingApproval.account/restoreHeight callouts. (5) Receive screen logic is adjusted so subaddress toggling only happens when a fresh unused subaddress is actually available. (6) iOS now gets periodic background tasks instead of LWS-only behavior. No cryptographic, authentication, or network transport code is changed in the visible diff.
Changed components
lib/main.dartlib/periodic_tasks.dartlib/screens/settings.dartlib/screens/wallet_home.dartlib/screens/receive.dartlib/widgets/connection_settings_form.dartlib/widgets/sync_frequency_sheet.dartlib/services/foreground_sync_service.dartlib/services/shared_preferences_service.dartlib/wallet_core_glue.dartlib/models/app_wallet.dartlib/models/monero_wallet_adapter.dartlocalization files (en, pt)Inspect captured patch +351 / −268
### README.md
@@ -4,7 +4,7 @@
A modern, open-source, and self-custody Monero light-wallet built with Flutter by [MAGIC Grants](https://magicgrants.org).
-On Android, the optional Background sync and Continuous sync use your view key only: they see incoming payments, but never hold a key that could spend.
+Periodic sync (on Android and iPhone) and Continuous sync (on Android), set under Sync Frequency, use your view key only: they see incoming payments, but never hold a key that could spend.
**Website:** [skylight.magicgrants.org](https://skylight.magicgrants.org)
### lib/l10n/app_en.arb
@@ -43,6 +43,9 @@
"connectionRemoteIpNotAllowed": "Connections to remote IP addresses aren't allowed. Use a domain name or a local IP address.",
"connectionLocalOverTorNotAllowed": "A local address can't be reached through Tor. Turn Tor off, or use the server's onion address.",
"connectionOnionNeedsTor": "An onion address can only be reached through Tor. Turn Tor on to use it.",
+ "connectionPathNotSupported": "This server is reached at its root, so its address can't include a path like /wallet. Remove the path.",
+ "lwsAwaitingApprovalAccount": "Your light wallet server hasn't approved this wallet yet. Ask the server's operator to approve it so you can see your balance and transactions.",
+ "lwsAwaitingApprovalRestoreHeight": "Your light wallet server hasn't approved scanning from your restore height yet, so older transactions may be missing. Ask the server's operator to approve it.",
"connectionTorDisabledWarning": "Tor is disabled, so this connection no longer works. Please reconfigure it.",
"connectionProtocolHttps": "Removing protocol. Using HTTPS for domains.",
"connectionProtocolHttp": "Removing protocol. Using HTTP for local addresses.",
@@ -63,10 +66,6 @@
"settingsConnectionOverTor": "over Tor",
"settingsConnectionOverClearnet": "over Clearnet",
"settingsConnectionInLocalNetwork": "in Local Network",
- "settingsBackgroundSyncLabel": "Background Sync",
- "settingsBackgroundSyncDescription": "Periodically sync Monero in the background so it's up to date when you open the app. Uses your view key only: it sees incoming payments but can never spend. Only runs while charging and on WiFi.",
- "settingsForegroundSyncLabel": "Continuous Sync",
- "settingsForegroundSyncDescription": "Keep Monero syncing continuously while the app runs in the background, with a persistent notification. Uses your view key only: it sees incoming payments once confirmed but can never spend. Uses more battery.",
"homeBlocksRemaining": "{count, plural, =1{1 block left} other{{count} blocks left}}",
"@homeBlocksRemaining": {
"placeholders": {
@@ -218,7 +217,8 @@
"coinHomeSent": "Sent",
"receiveTitle": "Receive",
"receivePrimaryAddressWarn": "Warning: Unless you know what you're doing, please use subaddresses for better privacy.",
- "receiveServerNoSubaddressesWarn": "Warning: This server does not support subaddresses. For better privacy, consider using a server that supports them. You are receiving to your primary address.",
+ "receiveServerNoSubaddressesWarn": "Warning: This server does not support subaddresses. For better privacy, consider using a server that supports them.",
+ "receiveSubaddressUnavailableWarn": "Warning: You need to configure Monero to enable subaddresses, which better protect your privacy.",
"receiveMaxSubaddressesReachedWarn": "You have reached the maximum number of subaddresses supported by this server. This is a used address.",
"receiveSubaddressTab": "Subaddress",
"receivePrimaryTab": "Primary address",
@@ -251,8 +251,17 @@
"settingsSectionWallet": "Wallet",
"settingsSectionAbout": "About",
"settingsNotifyNewTxsLabel": "Transaction Notifications",
- "settingsNotifyNewTxsDescription": "Show a notification when you receive a transaction. When connected to a Monero node, Background Sync must also be enabled.",
- "settingsNotifyNewTxsDescriptionIos": "Notifications will be delayed for Tor LWS connections.",
+ "settingsNotifyNewTxsDescription": "Show a notification when you receive a transaction. Increase the sync frequency setting to see them sooner.",
+ "settingsSyncFrequencyLabel": "Sync Frequency",
+ "syncFrequencySheetSubtitle": "How often Monero syncs while the app is closed.",
+ "syncFrequencyModeLabel": "Frequency",
+ "syncFrequencyContinuous": "Continuous",
+ "syncFrequencyContinuousDesc": "Continuously sync Monero in the background so it's always up to date when you open the app. Uses more battery and requires a persistent notification.",
+ "syncFrequencyPeriodic": "Periodic",
+ "syncFrequencyPeriodicDesc": "Periodically sync Monero in the background so it's usually up to date when you open the app. With a Monero node, it only syncs while charging and on WiFi.",
+ "syncFrequencyPeriodicDescIos": "Periodically sync Monero in the background so it's usually up to date when you open the app. With a Monero node, it only syncs while charging.",
+ "syncFrequencyOff": "Off",
+ "syncFrequencyOffDesc": "Only syncs while the app is open.",
"settingsAppLockUnlockReason": "Unlock Wallet",
"settingsLoggingLabel": "Diagnostic Logs",
"settingsLoggingDescription": "Log wallet operations to a text file in the app's data folder for debugging purposes.",
@@ -385,7 +394,6 @@
"torDisabledWalletsWarningConfirm": "Disable Tor",
"settingsTorSettingsLabel": "Tor Settings",
"lwsSetupTorDisabledError": "Tor is disabled. Please go back and enable it.",
- "lwsSetupInvalidQrCode": "Invalid connection address.",
"coinHomeSwap": "Swap",
"coinHomeSwapComingSoon": "Coming soon!",
"verifySeedTitle": "Verify Recovery Phrase",
### lib/l10n/app_localizations.dart
@@ -309,6 +309,24 @@ abstract class AppLocalizations {
/// **'An onion address can only be reached through Tor. Turn Tor on to use it.'**
String get connectionOnionNeedsTor;
+ /// No description provided for @connectionPathNotSupported.
+ ///
+ /// In en, this message translates to:
+ /// **'This server is reached at its root, so its address can\'t include a path like /wallet. Remove the path.'**
+ String get connectionPathNotSupported;
+
+ /// No description provided for @lwsAwaitingApprovalAccount.
+ ///
+ /// In en, this message translates to:
+ /// **'Your light wallet server hasn\'t approved this wallet yet. Ask the server\'s operator to approve it so you can see your balance and transactions.'**
+ String get lwsAwaitingApprovalAccount;
+
+ /// No description provided for @lwsAwaitingApprovalRestoreHeight.
+ ///
+ /// In en, this message translates to:
+ /// **'Your light wallet server hasn\'t approved scanning from your restore height yet, so older transactions may be missing. Ask the server\'s operator to approve it.'**
+ String get lwsAwaitingApprovalRestoreHeight;
+
/// No description provided for @connectionTorDisabledWarning.
///
/// In en, this message translates to:
@@ -429,30 +447,6 @@ abstract class AppLocalizations {
/// **'in Local Network'**
String get settingsConnectionInLocalNetwork;
- /// No description provided for @settingsBackgroundSyncLabel.
- ///
- /// In en, this message translates to:
- /// **'Background Sync'**
- String get settingsBackgroundSyncLabel;
-
- /// No description provided for @settingsBackgroundSyncDescription.
- ///
- /// In en, this message translates to:
- /// **'Periodically sync Monero in the background so it\'s up to date when you open the app. Uses your view key only: it sees incoming payments but can never spend. Only runs while charging and on WiFi.'**
- String get settingsBackgroundSyncDescription;
-
- /// No description provided for @settingsForegroundSyncLabel.
- ///
- /// In en, this message translates to:
- /// **'Continuous Sync'**
- String get settingsForegroundSyncLabel;
-
- /// No description provided for @settingsForegroundSyncDescription.
- ///
- /// In en, this message translates to:
- /// **'Keep Monero syncing continuously while the app runs in the background, with a persistent notification. Uses your view key only: it sees incoming payments once confirmed but can never spend. Uses more battery.'**
- String get settingsForegroundSyncDescription;
-
/// No description provided for @homeBlocksRemaining.
///
/// In en, this message translates to:
@@ -1194,9 +1188,15 @@ abstract class AppLocalizations {
/// No description provided for @receiveServerNoSubaddressesWarn.
///
/// In en, this message translates to:
- /// **'Warning: This server does not support subaddresses. For better privacy, consider using a server that supports them. You are receiving to your primary address.'**
+ /// **'Warning: This server does not support subaddresses. For better privacy, consider using a server that supports them.'**
String get receiveServerNoSubaddressesWarn;
+ /// No description provided for @receiveSubaddressUnavailableWarn.
+ ///
+ /// In en, this message translates to:
+ /// **'Warning: You need to configure Monero to enable subaddresses, which better protect your privacy.'**
+ String get receiveSubaddressUnavailableWarn;
+
/// No description provided for @receiveMaxSubaddressesReachedWarn.
///
/// In en, this message translates to:
@@ -1350,14 +1350,68 @@ abstract class AppLocalizations {
/// No description provided for @settingsNotifyNewTxsDescription.
///
/// In en, this message translates to:
- /// **'Show a notification when you receive a transaction. When connected to a Monero node, Background Sync must also be enabled.'**
+ /// **'Show a notification when you receive a transaction. Increase the sync frequency setting to see them sooner.'**
String get settingsNotifyNewTxsDescription;
- /// No description provided for @settingsNotifyNewTxsDescriptionIos.
+ /// No description provided for @settingsSyncFrequencyLabel.
+ ///
+ /// In en, this message translates to:
+ /// **'Sync Frequency'**
+ String get settingsSyncFrequencyLabel;
+
+ /// No description provided for @syncFrequencySheetSubtitle.
///
/// In en, this message translates to:
- /// **'Notifications will be delayed for Tor LWS connections.'**
- String get settingsNotifyNewTxsDescriptionIos;
+ /// **'How often Monero syncs while the app is closed.'**
+ String get syncFrequencySheetSubtitle;
+
+ /// No description provided for @syncFrequencyModeLabel.
+ ///
+ /// In en, this message translates to:
+ /// **'Frequency'**
+ String get syncFrequencyModeLabel;
+
+ /// No description provided for @syncFrequencyContinuous.
+ ///
+ /// In en, this message translates to:
+ /// **'Continuous'**
+ String get syncFrequencyContinuous;
+
+ /// No description provided for @syncFrequencyContinuousDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Continuously sync Monero in the background so it\'s always up to date when you open the app. Uses more battery and requires a persistent notification.'**
+ String get syncFrequencyContinuousDesc;
+
+ /// No description provided for @syncFrequencyPeriodic.
+ ///
+ /// In en, this message translates to:
+ /// **'Periodic'**
+ String get syncFrequencyPeriodic;
+
+ /// No description provided for @syncFrequencyPeriodicDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Periodically sync Monero in the background so it\'s usually up to date when you open the app. With a Monero node, it only syncs while charging and on WiFi.'**
+ String get syncFrequencyPeriodicDesc;
+
+ /// No description provided for @syncFrequencyPeriodicDescIos.
+ ///
+ /// In en, this message translates to:
+ /// **'Periodically sync Monero in the background so it\'s usually up to date when you open the app. With a Monero node, it only syncs while charging.'**
+ String get syncFrequencyPeriodicDescIos;
+
+ /// No description provided for @syncFrequencyOff.
+ ///
+ /// In en, this message translates to:
+ /// **'Off'**
+ String get syncFrequencyOff;
+
+ /// No description provided for @syncFrequencyOffDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Only syncs while the app is open.'**
+ String get syncFrequencyOffDesc;
/// No description provided for @settingsAppLockUnlockReason.
///
@@ -2067,12 +2121,6 @@ abstract class AppLocalizations {
/// **'Tor is disabled. Please go back and enable it.'**
String get lwsSetupTorDisabledError;
- /// No description provided for @lwsSetupInvalidQrCode.
- ///
- /// In en, this message translates to:
- /// **'Invalid connection address.'**
- String get lwsSetupInvalidQrCode;
-
/// No description provided for @coinHomeSwap.
///
/// In en, this message translates to:
### lib/l10n/app_localizations_en.dart
@@ -124,6 +124,18 @@ class AppLocalizationsEn extends AppLocalizations {
String get connectionOnionNeedsTor =>
'An onion address can only be reached through Tor. Turn Tor on to use it.';
+ @override
+ String get connectionPathNotSupported =>
+ 'This server is reached at its root, so its address can\'t include a path like /wallet. Remove the path.';
+
+ @override
+ String get lwsAwaitingApprovalAccount =>
+ 'Your light wallet server hasn\'t approved this wallet yet. Ask the server\'s operator to approve it so you can see your balance and transactions.';
+
+ @override
+ String get lwsAwaitingApprovalRestoreHeight =>
+ 'Your light wallet server hasn\'t approved scanning from your restore height yet, so older transactions may be missing. Ask the server\'s operator to approve it.';
+
@override
String get connectionTorDisabledWarning =>
'Tor is disabled, so this connection no longer works. Please reconfigure it.';
@@ -186,20 +198,6 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get settingsConnectionInLocalNetwork => 'in Local Network';
- @override
- String get settingsBackgroundSyncLabel => 'Background Sync';
-
- @override
- String get settingsBackgroundSyncDescription =>
- 'Periodically sync Monero in the background so it\'s up to date when you open the app. Uses your view key only: it sees incoming payments but can never spend. Only runs while charging and on WiFi.';
-
- @override
- String get settingsForegroundSyncLabel => 'Continuous Sync';
-
- @override
- String get settingsForegroundSyncDescription =>
- 'Keep Monero syncing continuously while the app runs in the background, with a persistent notification. Uses your view key only: it sees incoming payments once confirmed but can never spend. Uses more battery.';
-
@override
String homeBlocksRemaining(int count) {
final intl.NumberFormat countNumberFormat = intl.NumberFormat.decimalPattern(localeName);
@@ -608,7 +606,11 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get receiveServerNoSubaddressesWarn =>
- 'Warning: This server does not support subaddresses. For better privacy, consider using a server that supports them. You are receiving to your primary address.';
+ 'Warning: This server does not support subaddresses. For better privacy, consider using a server that supports them.';
+
+ @override
+ String get receiveSubaddressUnavailableWarn =>
+ 'Warning: You need to configure Monero to enable subaddresses, which better protect your privacy.';
@override
String get receiveMaxSubaddressesReachedWarn =>
@@ -691,11 +693,40 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get settingsNotifyNewTxsDescription =>
- 'Show a notification when you receive a transaction. When connected to a Monero node, Background Sync must also be enabled.';
+ 'Show a notification when you receive a transaction. Increase the sync frequency setting to see them sooner.';
+
+ @override
+ String get settingsSyncFrequencyLabel => 'Sync Frequency';
@override
- String get settingsNotifyNewTxsDescriptionIos =>
- 'Notifications will be delayed for Tor LWS connections.';
+ String get syncFrequencySheetSubtitle => 'How often Monero syncs while the app is closed.';
+
+ @override
+ String get syncFrequencyModeLabel => 'Frequency';
+
+ @override
+ String get syncFrequencyContinuous => 'Continuous';
+
+ @override
+ String get syncFrequencyContinuousDesc =>
+ 'Continuously sync Monero in the background so it\'s always up to date when you open the app. Uses more battery and requires a persistent notification.';
+
+ @override
+ String get syncFrequencyPeriodic => 'Periodic';
+
+ @override
+ String get syncFrequencyPeriodicDesc =>
+ 'Periodically sync Monero in the background so it\'s usually up to date when you open the app. With a Monero node, it only syncs while charging and on WiFi.';
+
+ @override
+ String get syncFrequencyPeriodicDescIos =>
+ 'Periodically sync Monero in the background so it\'s usually up to date when you open the app. With a Monero node, it only syncs while charging.';
+
+ @override
+ String get syncFrequencyOff => 'Off';
+
+ @override
+ String get syncFrequencyOffDesc => 'Only syncs while the app is open.';
@override
String get settingsAppLockUnlockReason => 'Unlock Wallet';
@@ -1070,9 +1101,6 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get lwsSetupTorDisabledError => 'Tor is disabled. Please go back and enable it.';
- @override
- String get lwsSetupInvalidQrCode => 'Invalid connection address.';
-
@override
String get coinHomeSwap => 'Swap';
### lib/l10n/app_localizations_pt.dart
@@ -124,6 +124,18 @@ class AppLocalizationsPt extends AppLocalizations {
String get connectionOnionNeedsTor =>
'Um endereço onion só pode ser acessado via Tor. Ative o Tor para usá-lo.';
+ @override
+ String get connectionPathNotSupported =>
+ 'Este servidor é acessado pela raiz, então o endereço não pode incluir um caminho como /wallet. Remova o caminho.';
+
+ @override
+ String get lwsAwaitingApprovalAccount =>
+ 'Seu servidor de carteira leve ainda não aprovou esta carteira. Peça ao operador do servidor para aprová-la para ver seu saldo e suas transações.';
+
+ @override
+ String get lwsAwaitingApprovalRestoreHeight =>
+ 'Seu servidor de carteira leve ainda não aprovou a verificação a partir da sua altura de restauração, então transações mais antigas podem estar faltando. Peça ao operador do servidor para aprová-la.';
+
@override
String get connectionTorDisabledWarning =>
'O Tor está desativado, então esta conexão não funciona mais. Reconfigure-a.';
@@ -187,20 +199,6 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get settingsConnectionInLocalNetwork => 'na rede local';
- @override
- String get settingsBackgroundSyncLabel => 'Sincronização em segundo plano';
-
- @override
- String get settingsBackgroundSyncDescription =>
- 'Sincroniza o Monero periodicamente em segundo plano para que esteja atualizado ao abrir o app. Usa só a sua chave de visualização: vê os pagamentos recebidos, mas nunca pode gastar. Só roda enquanto carrega e no WiFi.';
-
- @override
- String get settingsForegroundSyncLabel => 'Sincronização contínua';
-
- @override
- String get settingsForegroundSyncDescription =>
- 'Mantém o Monero sincronizando continuamente enquanto o app roda em segundo plano, com uma notificação persistente. Usa só a sua chave de visualização: vê os pagamentos recebidos depois de confirmados, mas nunca pode gastar. Usa mais bateria.';
-
@override
String homeBlocksRemaining(int count) {
final intl.NumberFormat countNumberFormat = intl.NumberFormat.decimalPattern(localeName);
@@ -612,7 +610,11 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get receiveServerNoSubaddressesWarn =>
- 'Aviso: Este servidor não suporta subendereços. Para melhor privacidade, considere usar um servidor que os suporte. Você está recebendo no seu endereço primário.';
+ 'Aviso: Este servidor não suporta subendereços. Para melhor privacidade, considere usar um servidor que os suporte.';
+
+ @override
+ String get receiveSubaddressUnavailableWarn =>
+ 'Aviso: Você precisa configurar o Monero para ativar subendereços, que protegem melhor sua privacidade.';
@override
String get receiveMaxSubaddressesReachedWarn =>
@@ -695,11 +697,41 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get settingsNotifyNewTxsDescription =>
- 'Mostrar uma notificação quando você receber uma transação. Ao conectar-se a um nó Monero, a Sincronização em Segundo Plano também precisa estar ativada.';
+ 'Mostrar uma notificação quando você receber uma transação. Aumente a frequência de sincronização para vê-las mais cedo.';
+
+ @override
+ String get settingsSyncFrequencyLabel => 'Frequência de sincronização';
@override
- String get settingsNotifyNewTxsDescriptionIos =>
- 'As notificações serão atrasadas para conexões LWS via Tor.';
+ String get syncFrequencySheetSubtitle =>
+ 'Com que frequência o Monero sincroniza enquanto o app está fechado.';
+
+ @override
+ String get syncFrequencyModeLabel => 'Frequência';
+
+ @override
+ String get syncFrequencyContinuous => 'Contínua';
+
+ @override
+ String get syncFrequencyContinuousDesc =>
+ 'Sincroniza o Monero continuamente em segundo plano para que esteja sempre atualizado ao abrir o app. Usa mais bateria e exige uma notificação persistente.';
+
+ @override
+ String get syncFrequencyPeriodic => 'Periódica';
+
+ @override
+ String get syncFrequencyPeriodicDesc =>
+ 'Sincroniza o Monero periodicamente em segundo plano para que geralmente esteja atualizado ao abrir o app. Com um nó Monero, só sincroniza enquanto carrega e no WiFi.';
+
+ @override
+ String get syncFrequencyPeriodicDescIos =>
+ 'Sincroniza o Monero periodicamente em segundo plano para que geralmente esteja atualizado ao abrir o app. Com um nó Monero, só sincroniza enquanto carrega.';
+
+ @override
+ String get syncFrequencyOff => 'Desligada';
+
+ @override
+ String get syncFrequencyOffDesc => 'Só sincroniza enquanto o app está aberto.';
@override
String get settingsAppLockUnlockReason => 'Desbloquear carteira';
@@ -1075,9 +1107,6 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get lwsSetupTorDisabledError => 'O Tor está desativado. Por favor, volte e ative-o.';
- @override
- String get lwsSetupInvalidQrCode => 'Endereço de conexão inválido.';
-
@override
String get coinHomeSwap => 'Trocar';
### lib/l10n/app_pt.arb
@@ -43,6 +43,9 @@
"connectionRemoteIpNotAllowed": "Conexões com endereços IP remotos não são permitidas. Use um nome de domínio ou um endereço IP local.",
"connectionLocalOverTorNotAllowed": "Um endereço local não pode ser acessado via Tor. Desative o Tor ou use o endereço onion do servidor.",
"connectionOnionNeedsTor": "Um endereço onion só pode ser acessado via Tor. Ative o Tor para usá-lo.",
+ "connectionPathNotSupported": "Este servidor é acessado pela raiz, então o endereço não pode incluir um caminho como /wallet. Remova o caminho.",
+ "lwsAwaitingApprovalAccount": "Seu servidor de carteira leve ainda não aprovou esta carteira. Peça ao operador do servidor para aprová-la para ver seu saldo e suas transações.",
+ "lwsAwaitingApprovalRestoreHeight": "Seu servidor de carteira leve ainda não aprovou a verificação a partir da sua altura de restauração, então transações mais antigas podem estar faltando. Peça ao operador do servidor para aprová-la.",
"connectionTorDisabledWarning": "O Tor está desativado, então esta conexão não funciona mais. Reconfigure-a.",
"connectionProtocolHttps": "Removendo protocolo. Usando HTTPS para domínios.",
"connectionProtocolHttp": "Removendo protocolo. Usando HTTP para endereços locais.",
@@ -63,10 +66,6 @@
"settingsConnectionOverTor": "via Tor",
"settingsConnectionOverClearnet": "via Clearnet",
"settingsConnectionInLocalNetwork": "na rede local",
- "settingsBackgroundSyncLabel": "Sincronização em segundo plano",
- "settingsBackgroundSyncDescription": "Sincroniza o Monero periodicamente em segundo plano para que esteja atualizado ao abrir o app. Usa só a sua chave de visualização: vê os pagamentos recebidos, mas nunca pode gastar. Só roda enquanto carrega e no WiFi.",
- "settingsForegroundSyncLabel": "Sincronização contínua",
- "settingsForegroundSyncDescription": "Mantém o Monero sincronizando continuamente enquanto o app roda em segundo plano, com uma notificação persistente. Usa só a sua chave de visualização: vê os pagamentos recebidos depois de confirmados, mas nunca pode gastar. Usa mais bateria.",
"homeBlocksRemaining": "{count, plural, =1{1 bloco restante} other{{count} blocos restantes}}",
"@homeBlocksRemaining": {
"placeholders": {
@@ -212,7 +211,8 @@
"coinHomeSent": "Enviado",
"receiveTitle": "Receber",
"receivePrimaryAddressWarn": "Aviso: A menos que saiba o que está fazendo, por favor use subendereços para melhor privacidade.",
- "receiveServerNoSubaddressesWarn": "Aviso: Este servidor não suporta subendereços. Para melhor privacidade, considere usar um servidor que os suporte. Você está recebendo no seu endereço primário.",
+ "receiveServerNoSubaddressesWarn": "Aviso: Este servidor não suporta subendereços. Para melhor privacidade, considere usar um servidor que os suporte.",
+ "receiveSubaddressUnavailableWarn": "Aviso: Você precisa configurar o Monero para ativar subendereços, que protegem melhor sua privacidade.",
"receiveMaxSubaddressesReachedWarn": "Você atingiu o número máximo de subendereços suportados por este servidor. Este é um endereço já usado.",
"receiveSubaddressTab": "Subendereço",
"receivePrimaryTab": "Endereço primário",
@@ -245,8 +245,17 @@
"settingsSectionWallet": "Carteira",
"settingsSectionAbout": "Sobre",
"settingsNotifyNewTxsLabel": "Notificações de Transações",
- "settingsNotifyNewTxsDescription": "Mostrar uma notificação quando você receber uma transação. Ao conectar-se a um nó Monero, a Sincronização em Segundo Plano também precisa estar ativada.",
- "settingsNotifyNewTxsDescriptionIos": "As notificações serão atrasadas para conexões LWS via Tor.",
+ "settingsNotifyNewTxsDescription": "Mostrar uma notificação quando você receber uma transação. Aumente a frequência de sincronização para vê-las mais cedo.",
+ "settingsSyncFrequencyLabel": "Frequência de sincronização",
+ "syncFrequencySheetSubtitle": "Com que frequência o Monero sincroniza enquanto o app está fechado.",
+ "syncFrequencyModeLabel": "Frequência",
+ "syncFrequencyContinuous": "Contínua",
+ "syncFrequencyContinuousDesc": "Sincroniza o Monero continuamente em segundo plano para que esteja sempre atualizado ao abrir o app. Usa mais bateria e exige uma notificação persistente.",
+ "syncFrequencyPeriodic": "Periódica",
+ "syncFrequencyPeriodicDesc": "Sincroniza o Monero periodicamente em segundo plano para que geralmente esteja atualizado ao abrir o app. Com um nó Monero, só sincroniza enquanto carrega e no WiFi.",
+ "syncFrequencyPeriodicDescIos": "Sincroniza o Monero periodicamente em segundo plano para que geralmente esteja atualizado ao abrir o app. Com um nó Monero, só sincroniza enquanto carrega.",
+ "syncFrequencyOff": "Desligada",
+ "syncFrequencyOffDesc": "Só sincroniza enquanto o app está aberto.",
"settingsAppLockUnlockReason": "Desbloquear carteira",
"settingsLoggingLabel": "Logs de Diagnóstico",
"settingsLoggingDescription": "Registrar operações da carteira em um arquivo de texto na pasta de dados do app para fins de depuração.",
@@ -379,7 +388,6 @@
"torDisabledWalletsWarningConfirm": "Desativar o Tor",
"settingsTorSettingsLabel": "Configurações do Tor",
"lwsSetupTorDisabledError": "O Tor está desativado. Por favor, volte e ative-o.",
- "lwsSetupInvalidQrCode": "Endereço de conexão inválido.",
"coinHomeSwap": "Trocar",
"coinHomeSwapComingSoon": "Em breve!",
"verifySeedTitle": "Verificar Frase de Recuperação",
### lib/main.dart
@@ -89,6 +89,9 @@ void main() async {
NotificationService().init();
}
+ // Before anything reads Sync Frequency: the tasks, the service, a wallet open.
+ await migrateSyncSettings();
+
if (Platform.isAndroid) {
registerPeriodicTasks();
startForegroundSyncIfEnabled();
@@ -97,8 +100,8 @@ void main() async {
if (Platform.isIOS) {
await cleanTorDirectoriesOnIOS();
- // Background sync here is LWS-only and decided by the connection; see
- // periodic_tasks._applyIosBackgroundTasks.
+ // BGTaskScheduler windows under Sync Frequency; see wallet_background's
+ // README.
registerPeriodicTasks();
NotificationService().init();
}
### lib/models/app_wallet.dart
@@ -1,4 +1,5 @@
import 'package:flutter/foundation.dart' show Listenable;
+import 'package:wallet_monero/wallet_monero.dart' show LwsPendingApproval;
import 'package:skylight_wallet/models/wallet_types.dart'
show TxDetails, LWSConnectionDetails, ResolvedOpenAlias;
@@ -31,7 +32,11 @@ abstract interface class AppWallet implements Listenable {
bool get hasAttemptedConnection;
bool get torRequirementBroken;
+ /// What the light-wallet server is still waiting to approve, or null.
+ LwsPendingApproval? get lwsPendingApproval;
+
String connectionAddressExampleForType(String type);
+ bool connectionAllowsPath(String type);
// Sync
bool get isConnected;
### lib/models/monero_wallet_adapter.dart
@@ -6,7 +6,7 @@ import 'package:skylight_wallet/models/wallet_types.dart'
import 'package:wallet_domain/wallet_domain.dart' as domain;
import 'package:wallet_infra/wallet_infra.dart' show requiresSecureTransport;
-import 'package:wallet_monero/wallet_monero.dart' show MoneroWallet;
+import 'package:wallet_monero/wallet_monero.dart' show LwsPendingApproval, MoneroWallet;
const _moneroDecimals = 12;
@@ -58,9 +58,14 @@ class MoneroWalletAdapter extends ChangeNotifier implements AppWallet {
@override
bool get torRequirementBroken => _wallet.torRequirementBroken;
@override
+ LwsPendingApproval? get lwsPendingApproval => _wallet.lwsPendingApproval;
+ @override
String connectionAddressExampleForType(String type) =>
_wallet.connectionAddressExampleForType(type);
+ @override
+ bool connectionAllowsPath(String type) => _wallet.connectionAllowsPath(type);
+
// Sync
@override
bool get isConnected => _wallet.isConnected;
### lib/periodic_tasks.dart
@@ -7,7 +7,7 @@ import 'package:wallet_background/wallet_background.dart';
// only the isolate entry point, because a fresh background isolate has none of
// the app's wallet-core statics and the package can't reach the app's bootstrap.
export 'package:wallet_background/wallet_background.dart'
- show PeriodicTasks, registerPeriodicTasks, applyBackgroundTaskRegistration;
+ show PeriodicTasks, registerPeriodicTasks, applyBackgroundTaskRegistration, migrateSyncSettings;
/// WorkManager isolate entry: bootstrap this isolate (`installWalletCore` also
/// installs the `BackgroundSync` config), then run the shared orchestration.
### lib/screens/receive.dart
@@ -107,20 +107,23 @@ class _ReceiveScreenState extends State<ReceiveScreen> {
// they can name different subaddresses.
final sub = isDemoMode ? null : wallet.unusedSubaddress;
final subSupported = wallet.serverSupportsSubaddresses;
- final canToggle = subSupported == true && !isDemoMode;
+ // The toggle needs a subaddress to toggle to. Until there is one (the
+ // server has not answered yet, or cannot be reached at all) the primary
+ // address is shown: every server scans it. Waiting for the subaddress
+ // instead spun forever with no connection.
+ final canToggle = subSupported == true && sub != null;
String? address;
- if (subSupported == false || isDemoMode) {
+ if (canToggle && _showSubaddress) {
+ address = sub.address;
+ } else if (primaryAddress.isNotEmpty) {
address = primaryAddress;
}
- if (subSupported == true) {
- address = _showSubaddress ? sub?.address : primaryAddress;
- }
- final ready = (subSupported != null || isDemoMode) && address != null;
- final warning = _warning(i18n, wallet, subSupported);
+ final ready = address != null;
+ final warning = _warning(i18n, wallet, isDemoMode, subSupported, sub);
final qrHeading = canToggle && _showSubaddress
- ? (sub != null ? '${i18n.receiveSubaddressTab} #${sub.index}' : i18n.receiveSubaddressTab)
+ ? '${i18n.receiveSubaddressTab} #${sub.index}'
: i18n.receiveAddressHeading('Monero');
if (isDesktop) {
@@ -173,12 +176,18 @@ class _ReceiveScreenState extends State<ReceiveScreen> {
);
}
- String? _warning(AppLocalizations i18n, AppWallet wallet, bool? subSupported) {
+ String? _warning(
+ AppLocalizations i18n,
+ AppWallet wallet,
+ bool isDemoMode,
+ bool? subSupported,
+ ({int index, String address})? sub,
+ ) {
+ if (isDemoMode) return null;
if (subSupported == false) return i18n.receiveServerNoSubaddressesWarn;
- if (subSupported == true && !_showSubaddress) return i18n.receivePrimaryAddressWarn;
- if (subSupported == true &&
- _showSubaddress &&
- wallet.unusedSubaddressIndexIsSupported == false) {
+ if (sub == null) return i18n.receiveSubaddressUnavailableWarn;
+ if (!_showSubaddress) return i18n.receivePrimaryAddressWarn;
+ if (wallet.unusedSubaddressIndexIsSupported == false) {
return i18n.receiveMaxSubaddressesReachedWarn;
}
return null;
### lib/screens/settings.dart
@@ -21,12 +21,13 @@ import 'package:wallet_fhse/security_keys_ui.dart'
show AppLockTile, DesktopAutoLockTile, FhseLocalizations, SecurityKeysState, securityKeysState;
import 'package:wallet_domain/wallet_domain.dart' show OpenAliasMode;
import 'package:wallet_fhse/wallet_fhse.dart' show SecurityKeyService;
-import 'package:skylight_wallet/periodic_tasks.dart';
+import 'package:wallet_infra/wallet_infra.dart' show SyncFrequency, loadSyncFrequency;
import 'package:skylight_wallet/services/notifications_service.dart';
import 'package:skylight_wallet/services/shared_preferences_service.dart';
import 'package:skylight_wallet/services/tor_settings_service.dart';
import 'package:skylight_wallet/widgets/language_sheet.dart';
import 'package:skylight_wallet/widgets/privacy_settings_sheets.dart';
+import 'package:skylight_wallet/widgets/sync_frequency_sheet.dart';
import 'package:skylight_wallet/widgets/ui/ui.dart';
import 'package:skylight_wallet/widgets/wallet_navigation_bar.dart';
@@ -56,6 +57,7 @@ class SettingsScreen extends StatefulWidget {
class _SettingsScreenState extends State<SettingsScreen> {
var _newTxNotificationsEnabled = false;
+ var _syncFrequency = SyncFrequency.periodic;
var _loggingEnabled = false;
SecurityKeysState? _securityKeys;
FiatApiMode _fiatMode = FiatApiMode.torOnly;
@@ -92,6 +94,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
final fiatMode = await FiatRateModel.loadFiatApiMode();
final openAliasMode = await OpenAliasMode.load();
+ final syncFrequency = await loadSyncFrequency();
await _loadSecurityKeys();
if (!mounted) return;
@@ -100,17 +103,18 @@ class _SettingsScreenState extends State<SettingsScreen> {
_loggingEnabled = loggingEnabled;
_fiatMode = fiatMode;
_openAliasMode = openAliasMode;
+ _syncFrequency = syncFrequency;
});
// Enable animation a frame after the loaded values are painted.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) setState(() => _animateToggles = true);
});
}
+ /// Only whether a background run that finds a payment says so. Whether runs
+ /// happen at all is Sync Frequency's.
void _setTxNotificationsEnabled(bool value) async {
final wallet = appWalletOf(context);
- // The notification check is view-only: its material follows this toggle.
- final applySyncSettings = syncSettingsApplier(context);
setState(() {
_newTxNotificationsEnabled = value;
@@ -124,16 +128,17 @@ class _SettingsScreenState extends State<SettingsScreen> {
// everything already received.
await wallet.markExistingTxsAsNotified();
await SharedPreferencesService.set<bool>(SharedPreferencesKeys.notificationsEnabled, true);
- await applySyncSettings();
- await applyBackgroundTaskRegistration();
}
} else {
await SharedPreferencesService.set<bool>(SharedPreferencesKeys.notificationsEnabled, false);
- await applySyncSettings();
- await applyBackgroundTaskRegistration();
}
}
+ void _showSyncFrequency() async {
+ final frequency = await showSyncFrequencySettings(context);
+ if (frequency != null && mounted) setState(() => _syncFrequency = frequency);
+ }
+
Future<void> _loadSecurityKeys() async {
if (!SecurityKeyService.isSupportedPlatform) return;
try {
@@ -438,7 +443,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
final theme = context.watch<ThemeModel>();
final wallet = appWalletOf(context, listen: true);
final fiatRate = context.watch<FiatRateModel>();
- final showNotifyToggle = Platform.isAndroid || (Platform.isIOS && !wallet.isNodeMode);
+ // Sync Frequency and the notifications it feeds: phones only.
+ final showNotifyToggle = Platform.isAndroid || Platform.isIOS;
final connectionSubtitle = _connectionSubtitle(wallet, i18n);
final fiatSubtitle = _fiatMode == FiatApiMode.disabled
? _fiatModeLabel(i18n)
@@ -533,11 +539,14 @@ class _SettingsScreenState extends State<SettingsScreen> {
SettingsGroup(
label: i18n.settingsSectionBehaviour,
tiles: [
+ SettingsNavTile(
+ title: i18n.settingsSyncFrequencyLabel,
+ value: syncFrequencyLabels(i18n).nameOf(_syncFrequency),
+ onTap: _showSyncFrequency,
+ ),
SettingsToggleTile(
title: i18n.settingsNotifyNewTxsLabel,
- description: Platform.isIOS
- ? i18n.settingsNotifyNewTxsDescriptionIos
- : i18n.settingsNotifyNewTxsDescription,
+ description: i18n.settingsNotifyNewTxsDescription,
value: _newTxNotificationsEnabled,
onChanged: _setTxNotificationsEnabled,
animate: _animateToggles,
### lib/screens/wallet_home.dart
@@ -7,6 +7,7 @@ import 'package:provider/provider.dart';
import 'package:skylight_wallet/l10n/app_localizations.dart';
import 'package:skylight_wallet/models/app_wallet.dart';
import 'package:skylight_wallet/models/fiat_rate_model.dart';
+import 'package:skylight_wallet/periodic_tasks.dart' show applyBackgroundTaskRegistration;
import 'package:skylight_wallet/screens/desktop/home_shell.dart';
import 'package:skylight_wallet/services/tor_service.dart';
import 'package:skylight_wallet/util/platform.dart';
@@ -16,6 +17,7 @@ import 'package:skylight_wallet/widgets/home_labels.dart';
import 'package:skylight_wallet/widgets/privacy_settings_sheets.dart';
import 'package:skylight_wallet/widgets/ui/ui.dart';
import 'package:skylight_wallet/widgets/wallet_navigation_bar.dart';
+import 'package:wallet_monero/wallet_monero.dart' show LwsPendingApproval;
import 'package:wallet_backup_platform/wallet_backup_platform.dart' show MetadataBackupSetup;
import 'package:wallet_domain/wallet_domain.dart' show CryptoWallet, SeedStore;
import 'package:wallet_fhse/security_keys_ui.dart' show securityKeysOn;
@@ -96,6 +98,10 @@ class _WalletHomeScreenState extends State<WalletHomeScreen> with WidgetsBinding
_checklist.refresh();
WidgetsBinding.instance.addPostFrameCallback((_) {
+ // Here a wallet exists and its connection is applied: the first time
+ // after onboarding, and after every unlock. Updates the tasks in place.
+ unawaited(applyBackgroundTaskRegistration());
+
final Map<String, dynamic>? args =
ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>?;
@@ -174,6 +180,12 @@ class _WalletHomeScreenState extends State<WalletHomeScreen> with WidgetsBinding
void swap() => showBrandToast(context, i18n.coinHomeSwapComingSoon);
final incoming = sections.incoming(coins);
final chart = sections.chart(coins);
+ // The server still waiting to approve this wallet, said where it matters.
+ final notice = switch (wallet.lwsPendingApproval) {
+ null => null,
+ LwsPendingApproval.account => WarningCallout(i18n.lwsAwaitingApprovalAccount),
+ LwsPendingApproval.restoreHeight => WarningCallout(i18n.lwsAwaitingApprovalRestoreHeight),
+ };
final checklist = securityChecklistCard(
checklist: _checklist,
labels: securityChecklistLabels(i18n),
@@ -196,7 +208,7 @@ class _WalletHomeScreenState extends State<WalletHomeScreen> with WidgetsBinding
onSend: send,
onSwap: swap,
),
- wide: [?incoming, chart],
+ wide: [?notice, ?incoming, chart],
side: checklist,
),
);
@@ -210,6 +222,7 @@ class _WalletHomeScreenState extends State<WalletHomeScreen> with WidgetsBinding
),
title: 'Skylight Wallet',
),
+ notice: notice,
balance: hero(_ConnectionRow(wallet: wallet, disconnected: v.disconnected)),
actions: HomeActionRow(
receiveLabel: i18n.homeReceive,
### lib/services/foreground_sync_service.dart
@@ -13,6 +13,7 @@ export 'package:wallet_background/wallet_background.dart'
restartForegroundSyncIfRunning,
isWalletFullySynced,
stopSyncAndDeleteWallets,
+ applySyncFrequency,
ForegroundSyncLink;
/// Foreground-service isolate entry: bootstrap this isolate, then hand off to
### lib/services/shared_preferences_service.dart
@@ -15,8 +15,6 @@ class SharedPreferencesKeys {
static const String fiatRate = SettingsKeys.fiatRate;
static const String theme = SettingsKeys.theme;
static const String notificationsEnabled = SettingsKeys.notificationsEnabled;
- static const String backgroundSyncEnabled = SettingsKeys.backgroundSyncEnabled;
- static const String foregroundSyncEnabled = SettingsKeys.foregroundSyncEnabled;
static const String backgroundSyncIntervalMinutes = SettingsKeys.backgroundSyncIntervalMinutes;
static const String loggingEnabled = SettingsKeys.loggingEnabled;
static const String contacts = SettingsKeys.contacts;
### lib/wallet_core_glue.dart
@@ -9,7 +9,8 @@ import 'package:skylight_wallet/models/app_wallet.dart';
import 'package:skylight_wallet/models/fiat_rate_model.dart';
import 'package:skylight_wallet/models/monero_wallet_adapter.dart';
import 'package:skylight_wallet/widgets/tx_details.dart' show TxDetailsDialog;
-import 'package:skylight_wallet/periodic_tasks.dart' show backgroundDispatcher;
+import 'package:skylight_wallet/periodic_tasks.dart'
+ show applyBackgroundTaskRegistration, backgroundDispatcher;
import 'package:skylight_wallet/services/foreground_sync_service.dart'
show foregroundSyncCallback, stopSyncAndDeleteWallets, restartForegroundSyncIfRunning;
import 'package:skylight_wallet/services/notifications_service.dart';
@@ -240,13 +241,6 @@ Future<int> commitGeneratedWallet(
return manager.getWallet('XMR')!.getRestoreHeight();
}
-/// After a sync or notifications toggle changes: Monero's view-only background
-/// copy and the view-only material every background run uses, set up or
-/// removed now rather than at the next launch ([WalletManager.applySyncSettings]).
-/// Bound before the caller's awaits.
-Future<void> Function() syncSettingsApplier(BuildContext context) =>
- Provider.of<WalletManager>(context, listen: false).applySyncSettings;
-
/// Where the welcome safety-net sends an install that already has a wallet,
/// or null when there is none: through the same locks as a launch, so the
/// unlock screen (App Lock is always on; the typed password on Linux and
@@ -273,8 +267,15 @@ Future<void> deleteWallet(BuildContext context) async {
/// Rebuilds the wallet if the server kind (LWS↔node) changed, then resyncs.
void applyConnectionChange(BuildContext context) {
final manager = Provider.of<WalletManager>(context, listen: false);
- // Restart the foreground service too, so its isolate re-reads the new server.
- unawaited(manager.applyConnectionChange('XMR').then((_) => restartForegroundSyncIfRunning()));
+ // Restart the foreground service too, so its isolate re-reads the new server,
+ // and re-register the background tasks, which depend on LWS or node and on
+ // Tor; both only once the wallet has been rebuilt for it.
+ unawaited(
+ manager
+ .applyConnectionChange('XMR')
+ .then((_) => restartForegroundSyncIfRunning())
+ .then((_) => applyBackgroundTaskRegistration()),
+ );
}
// ----- Security keys (FHSE) -----
### lib/widgets/connection_settings_form.dart
@@ -1,14 +1,11 @@
import 'dart:async';
import 'dart:io';
+
import 'package:flutter/material.dart';
-import 'package:skylight_wallet/periodic_tasks.dart';
-import 'package:skylight_wallet/services/foreground_sync_service.dart';
-import 'package:skylight_wallet/services/shared_preferences_service.dart';
import 'package:skylight_wallet/services/tor_settings_service.dart';
import 'package:skylight_wallet/util/logging.dart';
import 'package:skylight_wallet/l10n/app_localizations.dart';
-import 'package:skylight_wallet/models/app_wallet.dart';
import 'package:skylight_wallet/wallet_core_glue.dart';
import 'package:skylight_wallet/services/tor_service.dart';
import 'package:skylight_wallet/widgets/ui/ui.dart';
@@ -70,83 +67,15 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
bool _connectionTestIsLoading = false;
bool _connectionSuccess = false;
String? _errorMessage;
- bool _backgroundSyncEnabled = false;
- bool _foregroundSyncEnabled = false;
TorConnectionStatus _torStatus = TorService.sharedInstance.status;
Timer? _torStatusTimer;
bool _testCancelled = false;
int? _latencyMs;
- // The as-loaded values, so save can tell what the user actually changed:
- // enabling sync or editing the connection needs a working test; disabling
- // sync alone does not.
- String _initialAddress = '';
- String _initialProxyPort = '';
- bool _initialUseTor = false;
- String _initialConnectionType = 'lws';
- bool _initialBackgroundSync = false;
- bool _initialForegroundSync = false;
-
// The saved connection's raw Tor flag (before masking by the global Tor mode).
// Used to warn when a Tor connection was silently turned off by disabling Tor.
bool _savedConnectionUsedTor = false;
- bool get _isNode => _connectionType == 'node';
-
- /// Background/continuous sync only helps a full-node connection (the slow
- /// on-device scan); LWS syncs server-side. Android-only.
- bool get _showSyncOptions => Platform.isAndroid && _isNode;
-
- Future<void> _loadSyncPrefs() async {
- final bg =
- await SharedPreferencesService.get<bool>(SharedPreferencesKeys.backgroundSyncEnabled) ??
- false;
- final fg =
- await SharedPreferencesService.get<bool>(SharedPreferencesKeys.foregroundSyncEnabled) ??
- false;
- if (mounted) {
- setState(() {
- _backgroundSyncEnabled = bg;
- _foregroundSyncEnabled = fg;
- _initialBackgroundSync = bg;
- _initialForegroundSync = fg;
- });
- }
- }
-
- // Toggles are pending: they stage the choice and are applied by _saveConnection
- // (enabling requires saving over a working connection; disabling does not).
- void _setBackgroundSyncEnabled(bool value) => setState(() => _backgroundSyncEnabled = value);
-
- void _setForegroundSyncEnabled(bool value) => setState(() => _foregroundSyncEnabled = value);
-
- /// Persists the pending sync selection and starts/stops the services. LWS
- /// can't sync on-device, so both are forced off when the saved connection
- /// isn't an Android node.
- Future<void> _applySyncSelection() async {
- final bg = _showSyncOptions && _backgroundSyncEnabled;
- final fg = _showSyncOptions && _foregroundSyncEnabled;
- // Captured before the await so the notification starts from the live status.
- final synced = fg && appWalletOf(context).isFullySynced;
- final applySyncSettings = syncSettingsApplier(context);
- await SharedPreferencesService.set<bool>(SharedPreferencesKeys.backgroundSyncEnabled, bg);
- await SharedPreferencesService.set<bool>(SharedPreferencesKeys.foregroundSyncEnabled, fg);
- // Both syncs are view-only: the copy they open exists before they start.
- await applySyncSettings();
- if (fg) {
- await startForegroundSync(synced: synced);
- } else {
- await stopForegroundSync();
- }
- await applyBackgroundTaskRegistration();
- if (mounted) {
- setState(() {
- _backgroundSyncEnabled = bg;
- _foregroundSyncEnabled = fg;
- });
- }
- }
-
@override
void initState() {
super.initState();
@@ -176,41 +105,23 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
_useTor = useTor;
_savedConnectionUsedTor = conn.useTor;
_connectionType = type;
- _initialAddress = cleanConnectionAddress(conn.address);
- _initialProxyPort = conn.proxyPort;
- _initialUseTor = useTor;
- _initialConnectionType = type;
});
if (conn.useTor && TorSettingsService.sharedInstance.torMode == TorMode.builtIn) {
_pollTorStatus();
}
-
- if (_showSyncOptions) _loadSyncPrefs();
}
Future<void> _scanQrCode() async {
- final i18n = AppLocalizations.of(context)!;
-
final result = await Navigator.pushNamed(context, '/scan_qr');
if (!mounted) return;
+ // Filled in exactly as if typed: the address rules run at Test and Save,
+ // for a scanned address and a typed one alike.
if (result != null && result is String) {
final scannedAddress = cleanConnectionAddress(result);
- if (isValidConnectionAddress(scannedAddress)) {
- _addressController.text = scannedAddress;
- _onAddressChange(scannedAddress);
- } else {
- if (mounted) {
- if (widget.isInDialog) {
- setState(() {
- _errorMessage = i18n.lwsSetupInvalidQrCode;
- });
- } else {
- showBrandToast(context, i18n.lwsSetupInvalidQrCode);
- }
- }
- }
+ _addressController.text = scannedAddress;
+ _onAddressChange(scannedAddress);
}
}
@@ -289,7 +200,6 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
_hasTested = false;
_errorMessage = null;
});
- if (value == 'node' && Platform.isAndroid) _loadSyncPrefs();
_loadConnectionForType(value);
}
@@ -301,8 +211,7 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
/// the node the private view key.
///
/// A mode with nothing saved clears the field rather than inheriting the other
- /// one's address. `_initial*` is deliberately not updated: switching mode is a
- /// change, so Save stays gated on a passing test.
+ /// one's address. Switching mode clears the test, so Save waits for a new one.
Future<void> _loadConnectionForType(String type) async {
final wallet = appWalletOf(context);
final conn = await wallet.getPersistedConnectionForType(type);
@@ -328,6 +237,7 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
String _connectionAddressErrorMessage(AppLocalizations i18n, ConnectionAddressError error) =>
switch (error) {
ConnectionAddressError.remoteIp => i18n.connectionRemoteIpNotAllowed,
+ ConnectionAddressError.pathNotSupported => i18n.connectionPathNotSupported,
ConnectionAddressError.localOverTor => i18n.connectionLocalOverTorNotAllowed,
ConnectionAddressError.onionNeedsTor => i18n.connectionOnionNeedsTor,
};
@@ -344,6 +254,10 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
return custom.isEmpty ? null : custom;
}
+ /// Whether this connection may carry a path after host:port (a server behind
+ /// a reverse proxy at `/wallet`). The wallet decides: a node's client drops it.
+ bool get _allowsPath => appWalletOf(context).connectionAllowsPath(_connectionType);
+
Future _testConnection() async {
final i18n = AppLocalizations.of(context)!;
final wallet = appWalletOf(context);
@@ -361,6 +275,7 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
address: daemonAddress,
useTor: _useTor,
hasProxy: _customProxyPortController.text.trim().isNotEmpty,
+ allowPath: _allowsPath,
);
if (addrError != null) {
setState(() {
@@ -433,6 +348,7 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
address: daemonAddress,
useTor: _useTor,
hasProxy: proxyAddress.trim().isNotEmpty,
+ allowPath: _allowsPath,
);
if (addrError != null) {
setState(() => _errorMessage = _connectionAddressErrorMessage(i18n, addrError));
@@ -450,11 +366,6 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
await wallet.persistCurrentConnection();
- // Apply the pending sync selection over the connection just saved (also
- // rebuilds the background schedule, which on iOS depends on whether the
- // saved connection is LWS and whether it uses Tor).
- await _applySyncSelection();
-
await widget.onBeforeSave?.call();
widget.onSaved();
@@ -486,21 +397,7 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
final addressHint = appWalletOf(context).connectionAddressExampleForType(_connectionType);
final hasWorkingConnection = _hasTested && _connectionSuccess && !_connectionTestIsLoading;
- final connectionChanged =
- cleanConnectionAddress(_addressController.text) != _initialAddress ||
- _useTor != _initialUseTor ||
- _customProxyPortController.text != _initialProxyPort ||
- _connectionType != _initialConnectionType;
- final enablingSync =
- (_backgroundSyncEnabled && !_initialBackgroundSync) ||
- (_foregroundSyncEnabled && !_initialForegroundSync);
- final syncChanged =
- _backgroundSyncEnabled != _initialBackgroundSync ||
- _foregroundSyncEnabled != _initialForegroundSync;
- // Disabling sync alone needs no working connection; enabling it or editing
- // the connection does.
- final disablingSyncOnly = syncChanged && !enablingSync && !connectionChanged;
- final canSave = !_connectionTestIsLoading && (hasWorkingConnection || disablingSyncOnly);
+ final canSave = !_connectionTestIsLoading && hasWorkingConnection;
// Publish save state for an external Continue button (embedded mode).
final controller = widget.controller;
@@ -546,22 +443,6 @@ class _ConnectionSettingsFormState extends State<ConnectionSettingsForm> {
onToggleTor: () => _setUseTor(!_useTor),
pillProxyPort: _customProxyPortController.text,
pillAddress: cleanConnectionAddress(_addressController.text),
- syncRows: _showSyncOptions
- ? [
- ConnectionSyncRow(
- label: i18n.settingsBackgroundSyncLabel,
- help: i18n.settingsBackgroundSyncDescription,
- checked: _backgroundSyncEnabled,
- onToggle: _setBackgroundSyncEnabled,
- ),
- ConnectionSyncRow(
- label: i18n.settingsForegroundSyncLabel,
- help: i18n.settingsForegroundSyncDescription,
- checked: _foregroundSyncEnabled,
- onToggle: _setForegroundSyncEnabled,
- ),
- ]
- : const [],
testState: _testState(torMode),
onTest: _testConnection,
onStopTest: _stopTest,
### lib/widgets/sync_frequency_sheet.dart
@@ -0,0 +1,37 @@
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:provider/provider.dart';
+import 'package:wallet_domain/wallet_domain.dart' show WalletManager;
+import 'package:wallet_infra/wallet_infra.dart' show SyncFrequency;
+
+import 'package:skylight_wallet/l10n/app_localizations.dart';
+import 'package:skylight_wallet/services/foreground_sync_service.dart';
+import 'package:skylight_wallet/widgets/ui/ui.dart';
+
+/// The Sync Frequency sheet's strings. Periodic names the Monero node's limits,
+/// which differ by platform: iOS can only wait for a charger, not for WiFi.
+SyncFrequencyLabels syncFrequencyLabels(AppLocalizations i18n) => SyncFrequencyLabels(
+ title: i18n.settingsSyncFrequencyLabel,
+ subtitle: i18n.syncFrequencySheetSubtitle,
+ modeLabel: i18n.syncFrequencyModeLabel,
+ continuous: i18n.syncFrequencyContinuous,
+ continuousDesc: i18n.syncFrequencyContinuousDesc,
+ periodic: i18n.syncFrequencyPeriodic,
+ periodicDesc: Platform.isIOS ? i18n.syncFrequencyPeriodicDescIos : i18n.syncFrequencyPeriodicDesc,
+ off: i18n.syncFrequencyOff,
+ offDesc: i18n.syncFrequencyOffDesc,
+ save: i18n.torSettingsSaveButton,
+ cancel: i18n.cancel,
+);
+
+/// Opens Sync Frequency and applies a saved choice: the view-only material, the
+/// Continuous Sync service and the background tasks (`applySyncFrequency`).
+/// Resolves to the saved choice, or null when the user cancelled.
+Future<SyncFrequency?> showSyncFrequencySettings(BuildContext context) async {
+ final labels = syncFrequencyLabels(AppLocalizations.of(context)!);
+ final manager = Provider.of<WalletManager>(context, listen: false);
+ final frequency = await showSyncFrequencySheet(context, labels: labels);
+ if (frequency != null) await applySyncFrequency(manager, frequency);
+ return frequency;
+}Why this scored 34/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.