diff --git a/Bitkit/Resources/Localization/cs.lproj/Localizable.strings b/Bitkit/Resources/Localization/cs.lproj/Localizable.strings
index 1844973a..3786aefa 100644
--- a/Bitkit/Resources/Localization/cs.lproj/Localizable.strings
+++ b/Bitkit/Resources/Localization/cs.lproj/Localizable.strings
@@ -710,8 +710,6 @@
"settings__adv__section_other" = "Další";
"settings__adv__address_type" = "Typ bitcoinové adresy";
"settings__adv__monitored_address_types" = "Sledované typy adres";
-"settings__adv__monitored_address_types_update_title" = "Aktualizace sledovaných typů adres";
-"settings__adv__monitored_address_types_update_description" = "Změny se plně projeví po restartu aplikace.";
"settings__adv__gap_limit" = "Limit mezery v adrese";
"settings__adv__coin_selection" = "Výběr mince";
"settings__adv__cs_method" = "Metoda výběru mince";
diff --git a/Bitkit/Resources/Localization/de.lproj/Localizable.strings b/Bitkit/Resources/Localization/de.lproj/Localizable.strings
index 89415cb1..c21b6802 100644
--- a/Bitkit/Resources/Localization/de.lproj/Localizable.strings
+++ b/Bitkit/Resources/Localization/de.lproj/Localizable.strings
@@ -708,8 +708,6 @@
"settings__adv__section_other" = "Andere";
"settings__adv__address_type" = "Bitcoin Adressen-Typ";
"settings__adv__monitored_address_types" = "Überwachte Adress-Typen";
-"settings__adv__monitored_address_types_update_title" = "Überwachte Adress-Typen aktualisiert";
-"settings__adv__monitored_address_types_update_description" = "Änderungen werden nach dem Neustart der App vollständig wirksam.";
"settings__adv__gap_limit" = "Address Gap Limit";
"settings__adv__coin_selection" = "Coin-Auswahl";
"settings__adv__cs_method" = "Coin-Auswahlmethode";
diff --git a/Bitkit/Resources/Localization/en.lproj/Localizable.strings b/Bitkit/Resources/Localization/en.lproj/Localizable.strings
index 0bd8efcf..72caccfb 100644
--- a/Bitkit/Resources/Localization/en.lproj/Localizable.strings
+++ b/Bitkit/Resources/Localization/en.lproj/Localizable.strings
@@ -738,10 +738,6 @@
"settings__adv__section_other" = "Other";
"settings__adv__address_type" = "Bitcoin Address Type";
"settings__adv__monitored_address_types" = "Monitored Address Types";
-"settings__adv__monitored_address_types_update_title" = "Monitored Address Types Updated";
-"settings__adv__monitored_address_types_update_description" = "Changes will take full effect after app restarts.";
-"settings__adv__addr_type_timeout_title" = "Timeout";
-"settings__adv__addr_type_timeout_desc" = "The operation took too long. Please try again.";
"settings__adv__addr_type_failed_title" = "Failed";
"settings__adv__addr_type_change_failed_desc" = "Could not change address type. Please try again.";
"settings__adv__addr_type_applying" = "Applying changes…";
@@ -755,11 +751,6 @@
"settings__adv__addr_type_monitored_failed_desc" = "Could not update monitoring settings. Please try again.";
"settings__adv__addr_type_currently_selected" = "Currently selected";
"settings__adv__addr_type_monitored_note" = "Enable monitoring to track funds received at different address types. The app will watch these addresses for incoming transactions. Disabling monitoring for a type with balance may hide your funds.";
-"settings__adv__addr_type_loading_nav_address" = "Address Type";
-"settings__adv__addr_type_loading_nav_monitoring" = "Address Monitoring";
-"settings__adv__addr_type_loading_headline" = "Switching to {type}";
-"settings__adv__addr_type_loading_updating" = "Updating Wallet";
-"settings__adv__addr_type_loading_desc" = "Please wait while the wallet restarts...";
"settings__adv__gap_limit" = "Address Gap Limit";
"settings__adv__coin_selection" = "Coin Selection";
"settings__adv__cs_method" = "Coin Selection Method";
diff --git a/Bitkit/Resources/Localization/es-419.lproj/Localizable.strings b/Bitkit/Resources/Localization/es-419.lproj/Localizable.strings
index e3decc0e..4bd44c09 100644
--- a/Bitkit/Resources/Localization/es-419.lproj/Localizable.strings
+++ b/Bitkit/Resources/Localization/es-419.lproj/Localizable.strings
@@ -717,8 +717,6 @@
"settings__adv__section_other" = "Otros";
"settings__adv__address_type" = "Tipo de dirección Bitcoin";
"settings__adv__monitored_address_types" = "Tipos de Direcciones en monitoreo";
-"settings__adv__monitored_address_types_update_title" = "Tipos de dirección monitoreados actualizados";
-"settings__adv__monitored_address_types_update_description" = "Los cambios surtirán pleno efecto tras reiniciar la aplicación.";
"settings__adv__gap_limit" = "Límite de la brecha de direcciones";
"settings__adv__coin_selection" = "Selección de monedas";
"settings__adv__cs_method" = "Método de selección de monedas";
diff --git a/Bitkit/Resources/Localization/fr.lproj/Localizable.strings b/Bitkit/Resources/Localization/fr.lproj/Localizable.strings
index 4f65eb31..efb6a557 100644
--- a/Bitkit/Resources/Localization/fr.lproj/Localizable.strings
+++ b/Bitkit/Resources/Localization/fr.lproj/Localizable.strings
@@ -721,8 +721,6 @@
"settings__adv__section_other" = "Autre";
"settings__adv__address_type" = "Type d\'adresse Bitcoin";
"settings__adv__monitored_address_types" = "Types d\'adresses suivies";
-"settings__adv__monitored_address_types_update_title" = "Mise à jour des types d\'adresses suivies";
-"settings__adv__monitored_address_types_update_description" = "Les modifications prendront effet après le redémarrage de l\'application.";
"settings__adv__gap_limit" = "Limite de l\'écart d\'adresse";
"settings__adv__coin_selection" = "Sélection des UTXOs";
"settings__adv__cs_method" = "Méthode de sélection des UTXOs";
diff --git a/Bitkit/Resources/Localization/it.lproj/Localizable.strings b/Bitkit/Resources/Localization/it.lproj/Localizable.strings
index 9832602b..56fa30ce 100644
--- a/Bitkit/Resources/Localization/it.lproj/Localizable.strings
+++ b/Bitkit/Resources/Localization/it.lproj/Localizable.strings
@@ -699,8 +699,6 @@
"settings__adv__section_other" = "Altro";
"settings__adv__address_type" = "Tipologia Indirizzo Bitcoin";
"settings__adv__monitored_address_types" = "Tipi di indirizzi monitorati";
-"settings__adv__monitored_address_types_update_title" = "Tipi di indirizzi monitorati aggiornati";
-"settings__adv__monitored_address_types_update_description" = "Le modifiche avranno pieno effetto dopo il riavvio dell\'app.";
"settings__adv__gap_limit" = "Limite del gap di indirizzi";
"settings__adv__coin_selection" = "Coin Selection";
"settings__adv__cs_method" = "Metodo di Coin Selection";
diff --git a/Bitkit/Resources/Localization/nl.lproj/Localizable.strings b/Bitkit/Resources/Localization/nl.lproj/Localizable.strings
index 890b6bcf..ccce1096 100644
--- a/Bitkit/Resources/Localization/nl.lproj/Localizable.strings
+++ b/Bitkit/Resources/Localization/nl.lproj/Localizable.strings
@@ -718,8 +718,6 @@
"settings__adv__section_other" = "Overige";
"settings__adv__address_type" = "Bitcoin adres type";
"settings__adv__monitored_address_types" = "Bewaakte adrestypes";
-"settings__adv__monitored_address_types_update_title" = "Bewaakte adrestypes bijgewerkt";
-"settings__adv__monitored_address_types_update_description" = "Wijzigingen worden volledig van kracht nadat de app opnieuw is opgestart.";
"settings__adv__gap_limit" = "Adres Gap Limit";
"settings__adv__coin_selection" = "Coin selectie";
"settings__adv__cs_method" = "Coin Selectie Methode";
diff --git a/Bitkit/Resources/Localization/pl.lproj/Localizable.strings b/Bitkit/Resources/Localization/pl.lproj/Localizable.strings
index 809c1c9b..8a6182bf 100644
--- a/Bitkit/Resources/Localization/pl.lproj/Localizable.strings
+++ b/Bitkit/Resources/Localization/pl.lproj/Localizable.strings
@@ -722,8 +722,6 @@
"settings__adv__section_other" = "Inne";
"settings__adv__address_type" = "Typ adresu Bitcoin";
"settings__adv__monitored_address_types" = "Monitorowane typy adresów";
-"settings__adv__monitored_address_types_update_title" = "Zaktualizowano monitorowane typy adresów";
-"settings__adv__monitored_address_types_update_description" = "Zmiany zostaną zastosowane po ponownym uruchomieniu aplikacji.";
"settings__adv__gap_limit" = "Limit odstępu adresów";
"settings__adv__coin_selection" = "Wybór monet";
"settings__adv__cs_method" = "Metoda wyboru monet";
diff --git a/Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings b/Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings
index 4d0911b8..2abbeca0 100644
--- a/Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings
+++ b/Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings
@@ -722,8 +722,6 @@
"settings__adv__section_other" = "Outros";
"settings__adv__address_type" = "Tipo de endereço Bitcoin";
"settings__adv__monitored_address_types" = "Tipos de Endereços Monitorados";
-"settings__adv__monitored_address_types_update_title" = "Tipos de Endereços Monitorados Atualizados";
-"settings__adv__monitored_address_types_update_description" = "As alterações terão após a reinicialização do aplicativo.";
"settings__adv__gap_limit" = "Limite de Endereços";
"settings__adv__coin_selection" = "Controle de Moedas";
"settings__adv__cs_method" = "Método de Controle de Moedas";
diff --git a/Bitkit/Resources/Localization/ru.lproj/Localizable.strings b/Bitkit/Resources/Localization/ru.lproj/Localizable.strings
index 517fc0f8..8376885f 100644
--- a/Bitkit/Resources/Localization/ru.lproj/Localizable.strings
+++ b/Bitkit/Resources/Localization/ru.lproj/Localizable.strings
@@ -722,8 +722,6 @@
"settings__adv__section_other" = "Другое";
"settings__adv__address_type" = "Тип Биткойн-Адреса";
"settings__adv__monitored_address_types" = "Отслеживаемые Типы Адресов";
-"settings__adv__monitored_address_types_update_title" = "Отслеживаемые Типы Адресов Обновлены";
-"settings__adv__monitored_address_types_update_description" = "Изменения вступят в силу после перезапуска приложения.";
"settings__adv__gap_limit" = "Gap Limit Адресов";
"settings__adv__coin_selection" = "Выбор Монет";
"settings__adv__cs_method" = "Метод Выбора Монет";
diff --git a/Bitkit/Services/LightningService.swift b/Bitkit/Services/LightningService.swift
index ea4a6c04..2fd2b4db 100644
--- a/Bitkit/Services/LightningService.swift
+++ b/Bitkit/Services/LightningService.swift
@@ -892,6 +892,46 @@ extension LightningService {
}
}
+ func addAddressTypeToMonitor(_ addressType: LDKNode.AddressType) async throws {
+ guard let node else {
+ throw AppError(serviceError: .nodeNotSetup)
+ }
+ guard let mnemonic = try Keychain.loadString(key: .bip39Mnemonic(index: currentWalletIndex)) else {
+ throw CustomServiceError.mnemonicNotFound
+ }
+ let passphraseRaw = try? Keychain.loadString(key: .bip39Passphrase(index: currentWalletIndex))
+ let passphrase = passphraseRaw?.isEmpty == true ? nil : passphraseRaw
+
+ try await ServiceQueue.background(.ldk) {
+ try node.addAddressTypeToMonitorWithMnemonic(addressType: addressType, mnemonic: mnemonic, passphrase: passphrase)
+ }
+ }
+
+ func removeAddressTypeFromMonitor(_ addressType: LDKNode.AddressType) async throws {
+ guard let node else {
+ throw AppError(serviceError: .nodeNotSetup)
+ }
+
+ try await ServiceQueue.background(.ldk) {
+ try node.removeAddressTypeFromMonitor(addressType: addressType)
+ }
+ }
+
+ func setPrimaryAddressType(_ addressType: LDKNode.AddressType) async throws {
+ guard let node else {
+ throw AppError(serviceError: .nodeNotSetup)
+ }
+ guard let mnemonic = try Keychain.loadString(key: .bip39Mnemonic(index: currentWalletIndex)) else {
+ throw CustomServiceError.mnemonicNotFound
+ }
+ let passphraseRaw = try? Keychain.loadString(key: .bip39Passphrase(index: currentWalletIndex))
+ let passphrase = passphraseRaw?.isEmpty == true ? nil : passphraseRaw
+
+ try await ServiceQueue.background(.ldk) {
+ try node.setPrimaryAddressTypeWithMnemonic(addressType: addressType, mnemonic: mnemonic, passphrase: passphrase)
+ }
+ }
+
/// Sum of spendable on-chain balance for non-legacy address types (selected + monitored), for channel funding.
/// - Parameters:
/// - selectedType: Current primary address type.
diff --git a/Bitkit/Utilities/Errors.swift b/Bitkit/Utilities/Errors.swift
index b1301a7b..3b9494c0 100644
--- a/Bitkit/Utilities/Errors.swift
+++ b/Bitkit/Utilities/Errors.swift
@@ -400,6 +400,18 @@ struct AppError: LocalizedError {
case let .BackgroundSyncNotEnabled(ldkMessage):
message = "Background sync not enabled"
debugMessage = ldkMessage
+ case let .AddressTypeAlreadyMonitored(message: ldkMessage):
+ message = "Address type already monitored"
+ debugMessage = ldkMessage
+ case let .AddressTypeIsPrimary(message: ldkMessage):
+ message = "Address type is primary"
+ debugMessage = ldkMessage
+ case let .AddressTypeNotMonitored(message: ldkMessage):
+ message = "Address type not monitored"
+ debugMessage = ldkMessage
+ case let .InvalidSeedBytes(message: ldkMessage):
+ message = "Invalid seed bytes"
+ debugMessage = ldkMessage
}
Logger.error("\(message) [\(debugMessage ?? "")]", context: "ldk-node error")
}
diff --git a/Bitkit/ViewModels/SettingsViewModel.swift b/Bitkit/ViewModels/SettingsViewModel.swift
index de502977..a34adcab 100644
--- a/Bitkit/ViewModels/SettingsViewModel.swift
+++ b/Bitkit/ViewModels/SettingsViewModel.swift
@@ -316,6 +316,15 @@ class SettingsViewModel: NSObject, ObservableObject {
if !current.contains(addressType) {
current.append(addressType)
addressTypesToMonitor = current
+
+ do {
+ try await lightningService.addAddressTypeToMonitor(addressType)
+ try await lightningService.sync()
+ } catch {
+ Logger.error("Failed to add address type to monitor: \(error)")
+ addressTypesToMonitor = previousAddressTypesToMonitor
+ return false
+ }
}
} else {
if addressType == selectedAddressType { return false }
@@ -324,12 +333,10 @@ class SettingsViewModel: NSObject, ObservableObject {
let balance = try await getBalanceForAddressType(addressType)
if balance > 0 { return false }
} catch {
- // Fail safely: block disable if balance check fails
Logger.error("Failed to check balance for \(addressType), preventing disable: \(error)")
return false
}
- // At least one native witness type required for Lightning
let nativeWitnessTypes: [AddressScriptType] = [.nativeSegwit, .taproot]
let remainingNativeWitness = current.filter { $0 != addressType && nativeWitnessTypes.contains($0) }
if remainingNativeWitness.isEmpty {
@@ -338,18 +345,15 @@ class SettingsViewModel: NSObject, ObservableObject {
current.removeAll { $0 == addressType }
addressTypesToMonitor = current
- }
- UserDefaults.standard.synchronize()
-
- do {
- try await lightningService.restart()
- try await lightningService.sync()
- } catch {
- Logger.error("Failed to restart node after monitored types change: \(error)")
- addressTypesToMonitor = previousAddressTypesToMonitor
- UserDefaults.standard.synchronize()
- return false
+ do {
+ try await lightningService.removeAddressTypeFromMonitor(addressType)
+ try await lightningService.sync()
+ } catch {
+ Logger.error("Failed to remove address type from monitor: \(error)")
+ addressTypesToMonitor = previousAddressTypesToMonitor
+ return false
+ }
}
wallet?.syncState()
@@ -412,18 +416,23 @@ class SettingsViewModel: NSObject, ObservableObject {
guard changed else { return }
+ let toRemove = addressTypesToMonitor.filter { !newMonitored.contains($0) }
addressTypesToMonitor = newMonitored
- UserDefaults.standard.synchronize()
-
+ for type in toRemove {
+ do {
+ try await lightningService.removeAddressTypeFromMonitor(type)
+ } catch {
+ Logger.error("Failed to remove address type \(type) from monitor: \(error)")
+ }
+ }
do {
- try await lightningService.restart()
try await lightningService.sync()
Logger.info(
"Pruned empty address types after restore: \(newMonitored.map(\.stringValue).joined(separator: ","))",
context: "SettingsViewModel"
)
} catch {
- Logger.error("Failed to restart after prune: \(error)")
+ Logger.error("Failed to sync after prune: \(error)")
}
}
@@ -460,26 +469,16 @@ class SettingsViewModel: NSObject, ObservableObject {
selectedAddressType = addressType
ensureMonitoring(addressType)
- UserDefaults.standard.set("", forKey: "onchainAddress")
- UserDefaults.standard.set("", forKey: "bip21")
- UserDefaults.standard.synchronize()
-
- if let wallet {
- wallet.onchainAddress = ""
- wallet.bip21 = ""
- }
-
do {
- try await lightningService.restart()
+ try await lightningService.setPrimaryAddressType(addressType)
try await lightningService.sync()
await generateAndUpdateAddress(addressType: addressType, wallet: wallet)
} catch {
- Logger.error("Failed to restart node after address type change: \(error)")
+ Logger.error("Failed to set primary address type: \(error)")
selectedAddressType = previousSelectedAddressType
addressTypesToMonitor = previousAddressTypesToMonitor
UserDefaults.standard.set(previousOnchainAddress, forKey: "onchainAddress")
UserDefaults.standard.set(previousBip21, forKey: "bip21")
- UserDefaults.standard.synchronize()
if let wallet {
wallet.onchainAddress = previousOnchainAddress
wallet.bip21 = previousBip21
diff --git a/Bitkit/Views/Settings/Advanced/AddressTypeLoadingView.swift b/Bitkit/Views/Settings/Advanced/AddressTypeLoadingView.swift
deleted file mode 100644
index 8b694d28..00000000
--- a/Bitkit/Views/Settings/Advanced/AddressTypeLoadingView.swift
+++ /dev/null
@@ -1,77 +0,0 @@
-import SwiftUI
-
-struct AddressTypeLoadingView: View {
- let targetAddressType: AddressScriptType?
- let isMonitoringChange: Bool
-
- private var navTitle: String {
- isMonitoringChange ? t("settings__adv__addr_type_loading_nav_monitoring") : t("settings__adv__addr_type_loading_nav_address")
- }
-
- private var headline: String {
- if let addressType = targetAddressType, !isMonitoringChange {
- return t("settings__adv__addr_type_loading_headline", variables: ["type": addressType.localizedTitle])
- }
- return t("settings__adv__addr_type_loading_updating")
- }
-
- private var description: String {
- t("settings__adv__addr_type_loading_desc")
- }
-
- var body: some View {
- VStack(spacing: 0) {
- NavigationBar(title: navTitle, showBackButton: false, showMenuButton: false)
-
- VStack(spacing: 0) {
- VStack {
- Spacer()
-
- Image("wallet")
- .resizable()
- .scaledToFit()
- .frame(maxWidth: .infinity)
- .aspectRatio(1, contentMode: .fit)
-
- Spacer()
- }
- .frame(maxWidth: .infinity)
- .frame(maxHeight: .infinity)
- .layoutPriority(1)
-
- VStack(alignment: .leading, spacing: 14) {
- DisplayText(headline)
- .frame(maxWidth: .infinity, alignment: .leading)
- .fixedSize(horizontal: false, vertical: true)
- BodyMText(description)
- .frame(maxWidth: .infinity, alignment: .leading)
- .fixedSize(horizontal: false, vertical: true)
- }
-
- ActivityIndicator(size: 32)
- .padding(.top, 32)
- }
- .padding(.horizontal, 16)
- }
- .frame(maxWidth: .infinity, maxHeight: .infinity)
- .padding(.horizontal, 16)
- .bottomSafeAreaPadding()
- .background(Color.customBlack)
- .navigationBarHidden(true)
- .accessibilityIdentifier("AddressTypeLoadingView")
- .onAppear {
- UIApplication.shared.isIdleTimerDisabled = true
- }
- .onDisappear {
- UIApplication.shared.isIdleTimerDisabled = false
- }
- }
-}
-
-#Preview {
- AddressTypeLoadingView(
- targetAddressType: .taproot,
- isMonitoringChange: false
- )
- .preferredColorScheme(.dark)
-}
diff --git a/Bitkit/Views/Settings/Advanced/AddressTypePreferenceView.swift b/Bitkit/Views/Settings/Advanced/AddressTypePreferenceView.swift
index b6c2769e..2f07ea56 100644
--- a/Bitkit/Views/Settings/Advanced/AddressTypePreferenceView.swift
+++ b/Bitkit/Views/Settings/Advanced/AddressTypePreferenceView.swift
@@ -83,17 +83,10 @@ struct AddressTypePreferenceView: View {
@EnvironmentObject private var settingsViewModel: SettingsViewModel
@EnvironmentObject private var wallet: WalletViewModel
@EnvironmentObject private var app: AppViewModel
- @EnvironmentObject private var navigation: NavigationViewModel
@AppStorage("showDevSettings") private var showDevSettings = Env.isDebug
@State private var showMonitoredTypesNote = false
- @State private var showLoadingView = false
- @State private var loadingAddressType: AddressScriptType?
- @State private var isMonitoringChange = false
- @State private var loadingTask: Task?
-
- private let timeoutSeconds: UInt64 = 60
var body: some View {
VStack(alignment: .leading, spacing: 0) {
@@ -114,27 +107,12 @@ struct AddressTypePreferenceView: View {
) {
guard settingsViewModel.selectedAddressType != addressType else { return }
- loadingAddressType = addressType
- isMonitoringChange = false
- showLoadingView = true
-
- loadingTask = Task {
- var success = false
- let didTimeout = await withTimeout(seconds: timeoutSeconds) {
- success = await settingsViewModel.updateAddressType(addressType, wallet: wallet)
- }
-
- showLoadingView = false
+ app.toast(type: .info, title: t("settings__adv__addr_type_applying"), autoHide: false)
- if didTimeout {
- app.toast(
- type: .error,
- title: t("settings__adv__addr_type_timeout_title"),
- description: t("settings__adv__addr_type_timeout_desc")
- )
- } else if success {
+ Task {
+ let success = await settingsViewModel.updateAddressType(addressType, wallet: wallet)
+ if success {
Haptics.notify(.success)
- navigation.reset()
app.toast(
type: .success,
title: t("settings__adv__addr_type_changed_title"),
@@ -184,25 +162,11 @@ struct AddressTypePreferenceView: View {
isMonitored: settingsViewModel.isMonitoring(addressType),
isSelectedType: settingsViewModel.selectedAddressType == addressType
) { enabled in
- loadingAddressType = addressType
- isMonitoringChange = true
- showLoadingView = true
-
- loadingTask = Task {
- var success = false
- let didTimeout = await withTimeout(seconds: timeoutSeconds) {
- success = await settingsViewModel.setMonitoring(addressType, enabled: enabled, wallet: wallet)
- }
+ app.toast(type: .info, title: t("settings__adv__addr_type_applying"), autoHide: false)
- showLoadingView = false
-
- if didTimeout {
- app.toast(
- type: .error,
- title: t("settings__adv__addr_type_timeout_title"),
- description: t("settings__adv__addr_type_timeout_desc")
- )
- } else if success {
+ Task {
+ let success = await settingsViewModel.setMonitoring(addressType, enabled: enabled, wallet: wallet)
+ if success {
Haptics.notify(.success)
app.toast(
type: .success,
@@ -249,41 +213,6 @@ struct AddressTypePreferenceView: View {
.navigationBarHidden(true)
.padding(.horizontal, 16)
.bottomSafeAreaPadding()
- .fullScreenCover(isPresented: $showLoadingView) {
- AddressTypeLoadingView(
- targetAddressType: loadingAddressType,
- isMonitoringChange: isMonitoringChange
- )
- }
- .onDisappear {
- loadingTask?.cancel()
- }
- }
-}
-
-private struct TimeoutError: Error {}
-
-/// Returns true if operation timed out.
-private func withTimeout(seconds: UInt64, operation: @escaping () async -> some Any) async -> Bool {
- do {
- try await withThrowingTaskGroup(of: Void.self) { group in
- group.addTask {
- _ = await operation()
- }
-
- group.addTask {
- try await Task.sleep(nanoseconds: seconds * 1_000_000_000)
- throw TimeoutError()
- }
-
- try await group.next()
- group.cancelAll()
- }
- return false
- } catch is TimeoutError {
- return true
- } catch {
- return false
}
}
@@ -294,7 +223,6 @@ private func withTimeout(seconds: UInt64, operation: @escaping () async -> some
.environmentObject(SettingsViewModel.shared)
.environmentObject(app)
.environmentObject(WalletViewModel())
- .environmentObject(NavigationViewModel())
}
.preferredColorScheme(.dark)
}
diff --git a/BitkitTests/AddressTypeIntegrationTests.swift b/BitkitTests/AddressTypeIntegrationTests.swift
index 1fd51bf3..e66a8f2e 100644
--- a/BitkitTests/AddressTypeIntegrationTests.swift
+++ b/BitkitTests/AddressTypeIntegrationTests.swift
@@ -109,7 +109,6 @@ final class AddressTypeIntegrationTests: XCTestCase {
func testSetMonitoringDisableForEmptyTypeSucceeds() async throws {
try await setupWalletAndNode()
- // Add taproot via setMonitoring (handles restart internally so LDK creates taproot wallet)
settings.addressTypesToMonitor = [.nativeSegwit]
UserDefaults.standard.synchronize()
let addSuccess = await settings.setMonitoring(.taproot, enabled: true, wallet: nil)
@@ -139,7 +138,6 @@ final class AddressTypeIntegrationTests: XCTestCase {
func testSetMonitoringDisableSelectedTypeFails() async throws {
try await setupWalletAndNode()
- // Add taproot, then set taproot as selected; cannot disable selected type
settings.addressTypesToMonitor = [.nativeSegwit]
UserDefaults.standard.synchronize()
let addSuccess = await settings.setMonitoring(.taproot, enabled: true, wallet: nil)
@@ -159,7 +157,7 @@ final class AddressTypeIntegrationTests: XCTestCase {
settings.addressTypesToMonitor = [.nativeSegwit, .taproot]
UserDefaults.standard.synchronize()
- try await settings.lightningService.restart()
+ try await settings.lightningService.addAddressTypeToMonitor(.taproot)
try await settings.lightningService.sync()
Logger.test("Pruning empty address types after restore", context: "AddressTypeIntegrationTests")