Skip to content

Commit 99ede04

Browse files
committed
(ios) Adding a notice when Tor is enabled, but we're having issues connecting. Matches similar UI in Android.
1 parent 358f03b commit 99ede04

File tree

15 files changed

+316
-18
lines changed

15 files changed

+316
-18
lines changed

phoenix-ios/phoenix-ios.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
DC5631C72C5944CF00DCB5BF /* KotlinExtensions+Manager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5631C62C5944CF00DCB5BF /* KotlinExtensions+Manager.swift */; };
167167
DC5631C82C59466000DCB5BF /* KotlinExtensions+Manager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5631C62C5944CF00DCB5BF /* KotlinExtensions+Manager.swift */; };
168168
DC5631CA2C597B8600DCB5BF /* SourceInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5631C92C597B8600DCB5BF /* SourceInfo.swift */; };
169+
DC5895D02E57856D00CBCCF9 /* TorNetworkIssueSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5895CF2E57856600CBCCF9 /* TorNetworkIssueSheet.swift */; };
169170
DC59377127516297003B4B53 /* Sequence+Sum.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC59377027516296003B4B53 /* Sequence+Sum.swift */; };
170171
DC5A935329846044004F19FD /* FileHandle+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5A935229846043004F19FD /* FileHandle+Async.swift */; };
171172
DC5CA4ED28F83C3B0048A737 /* DrainWalletView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5CA4EC28F83C3B0048A737 /* DrainWalletView.swift */; };
@@ -658,6 +659,7 @@
658659
DC5631C42C541E5C00DCB5BF /* Experimental.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Experimental.swift; sourceTree = "<group>"; };
659660
DC5631C62C5944CF00DCB5BF /* KotlinExtensions+Manager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KotlinExtensions+Manager.swift"; sourceTree = "<group>"; };
660661
DC5631C92C597B8600DCB5BF /* SourceInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceInfo.swift; sourceTree = "<group>"; };
662+
DC5895CF2E57856600CBCCF9 /* TorNetworkIssueSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TorNetworkIssueSheet.swift; sourceTree = "<group>"; };
661663
DC59377027516296003B4B53 /* Sequence+Sum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Sequence+Sum.swift"; sourceTree = "<group>"; };
662664
DC5A935229846043004F19FD /* FileHandle+Async.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileHandle+Async.swift"; sourceTree = "<group>"; };
663665
DC5CA4EC28F83C3B0048A737 /* DrainWalletView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrainWalletView.swift; sourceTree = "<group>"; };
@@ -1788,6 +1790,7 @@
17881790
DCDD9ED1286377C5001800A3 /* MainView_Small.swift */,
17891791
DC5E28C92C62D37A0037B3D3 /* NavigationCoordinator.swift */,
17901792
DCDD9ED328637EBB001800A3 /* ToolsButton.swift */,
1793+
DC5895CF2E57856600CBCCF9 /* TorNetworkIssueSheet.swift */,
17911794
);
17921795
path = main;
17931796
sourceTree = "<group>";
@@ -2344,6 +2347,7 @@
23442347
DC9CF8412D2ECF08003F3B0F /* IncomingBalancePopover.swift in Sources */,
23452348
DCDD9ED2286377C5001800A3 /* MainView_Small.swift in Sources */,
23462349
DC4CBC752D64DAC600129BDB /* Details_Incoming_Bolt11.swift in Sources */,
2350+
DC5895D02E57856D00CBCCF9 /* TorNetworkIssueSheet.swift in Sources */,
23472351
C8D7AFF5BC5754DBBEEB2688 /* ElectrumConfigurationView.swift in Sources */,
23482352
DC2210D92DE4F7E30096D8D2 /* LabelAlignment.swift in Sources */,
23492353
DCC3E57F2D08A63900CCDA40 /* XPC+Foreground.swift in Sources */,

phoenix-ios/phoenix-ios/Localizable.xcstrings

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8572,6 +8572,9 @@
85728572
}
85738573
}
85748574
}
8575+
},
8576+
"Cannot access the Tor network. Phoenix will not function correctly." : {
8577+
85758578
},
85768579
"Cannot be swapped anymore, after 4 months waiting. These funds must be spent manually." : {
85778580
"localizations" : {
@@ -20890,6 +20893,9 @@
2089020893
}
2089120894
}
2089220895
}
20896+
},
20897+
"If you don't have a Tor VPN app, install one. We recommend Orbot." : {
20898+
2089320899
},
2089420900
"If you enable [Advanced Data Protection](https://support.apple.com/en-us/108756) for iCloud, your recovery phrase will be encrypted end-to-end, and Apple cannot access it." : {
2089520901
"localizations" : {
@@ -25046,6 +25052,9 @@
2504625052
}
2504725053
}
2504825054
}
25055+
},
25056+
"Make sure your Tor Proxy VPN app is up and running, and that it's connected to Tor." : {
25057+
2504925058
},
2505025059
"Make sure your Tor VPN is active and running." : {
2505125060
"localizations" : {
@@ -27052,6 +27061,9 @@
2705227061
}
2705327062
}
2705427063
}
27064+
},
27065+
"No access to the Tor network" : {
27066+
2705527067
},
2705627068
"No address yet..." : {
2705727069
"localizations" : {
@@ -28597,6 +28609,12 @@
2859728609
}
2859828610
}
2859928611
}
28612+
},
28613+
"Open Orbot website" : {
28614+
28615+
},
28616+
"Open Tor settings" : {
28617+
2860028618
},
2860128619
"Opening the app" : {
2860228620

@@ -30940,6 +30958,9 @@
3094030958
}
3094130959
}
3094230960
}
30961+
},
30962+
"Phoenix needs access to Tor to function properly." : {
30963+
3094330964
},
3094430965
"Phoenix uses payment channels to make Bitcoin fast and private." : {
3094530966
"localizations" : {

phoenix-ios/phoenix-ios/views/configuration/ConfigurationView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,12 @@ struct ConfigurationList: View {
635635
case .electrum : newNavLinkTag = .ElectrumServer ; delay *= 1
636636
case .backgroundPayments : newNavLinkTag = .PaymentOptions ; delay *= 2
637637
case .liquiditySettings : newNavLinkTag = .ChannelManagement ; delay *= 1
638+
case .torSettings : newNavLinkTag = .Tor ; delay *= 1
638639
case .forceCloseChannels : newNavLinkTag = .ForceCloseChannels ; delay *= 1
639640
case .swapInWallet : newNavLinkTag = .WalletInfo ; delay *= 2
640641
case .finalWallet : newNavLinkTag = .WalletInfo ; delay *= 2
641642
case .appAccess : newNavLinkTag = .AppAccess ; delay *= 1
642-
case .walletMetadata : newNavLinkTag = .WalletMetadata ; delay *= 1
643+
case .walletMetadata : newNavLinkTag = .WalletMetadata ; delay *= 1
643644
}
644645

645646
if let newNavLinkTag {

phoenix-ios/phoenix-ios/views/configuration/advanced/wallet/WalletInfoView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ struct WalletInfoView: View {
612612
case .electrum : break
613613
case .backgroundPayments : break
614614
case .liquiditySettings : break
615+
case .torSettings : break
615616
case .forceCloseChannels : break
616617
case .swapInWallet : newNavLinkTag = NavLinkTag.SwapInWalletDetails
617618
case .finalWallet : newNavLinkTag = NavLinkTag.FinalWalletDetails

phoenix-ios/phoenix-ios/views/configuration/general/payment options/PaymentOptionsView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ struct PaymentOptionsList: View {
383383
case .electrum : break
384384
case .backgroundPayments : newNavLinkTag = NavLinkTag.BackgroundPaymentsSelector
385385
case .liquiditySettings : break
386+
case .torSettings : break
386387
case .forceCloseChannels : break
387388
case .swapInWallet : break
388389
case .finalWallet : break

phoenix-ios/phoenix-ios/views/configuration/privacy and security/tor/TorConfigurationView.swift

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ struct TorConfigurationView: View {
1313
@State var isTorEnabled = GroupPrefs.current.isTorEnabled
1414

1515
@State var ignoreToggleStateChange = false
16+
17+
@State var didAppear = false
1618

19+
@EnvironmentObject var deepLinkManager: DeepLinkManager
1720
@EnvironmentObject var popoverState: PopoverState
1821
@EnvironmentObject var smartModalState: SmartModalState
1922

@@ -36,6 +39,9 @@ struct TorConfigurationView: View {
3639
}
3740
.listStyle(.insetGrouped)
3841
.listBackgroundColor(.primaryBackground)
42+
.onAppear() {
43+
onAppear()
44+
}
3945
}
4046

4147
@ViewBuilder
@@ -78,6 +84,25 @@ struct TorConfigurationView: View {
7884
}
7985
}
8086

87+
// --------------------------------------------------
88+
// MARK: Notifications
89+
// --------------------------------------------------
90+
91+
func onAppear() {
92+
log.trace(#function)
93+
94+
if !didAppear {
95+
didAppear = true
96+
97+
if let deepLink = deepLinkManager.deepLink, deepLink == .torSettings {
98+
// Reached our destination
99+
DispatchQueue.main.async { // iOS 14 issues workaround
100+
deepLinkManager.unbroadcast(deepLink)
101+
}
102+
}
103+
}
104+
}
105+
81106
// --------------------------------------------------
82107
// MARK: Actions
83108
// --------------------------------------------------
@@ -106,14 +131,14 @@ struct TorConfigurationView: View {
106131
}
107132

108133
func usingTorSheet_didCancel() {
109-
log.trace("usingTorSheet_didCancel()")
134+
log.trace(#function)
110135

111136
ignoreToggleStateChange = true
112137
toggleState = false
113138
}
114139

115140
func usingTorSheet_didConfirm() {
116-
log.trace("usingTorSheet_didConfirm()")
141+
log.trace(#function)
117142

118143
isTorEnabled = true
119144
GroupPrefs.current.isTorEnabled = true
@@ -124,14 +149,14 @@ struct TorConfigurationView: View {
124149
}
125150

126151
func disablingTorSheet_didCancel() {
127-
log.trace("disablingTorSheet_didCancel()")
152+
log.trace(#function)
128153

129154
ignoreToggleStateChange = true
130155
toggleState = true
131156
}
132157

133158
func disablingTorSheet_didConfirm() {
134-
log.trace("disablingTorSheet_didConfirm()")
159+
log.trace(#function)
135160

136161
isTorEnabled = false
137162
GroupPrefs.current.isTorEnabled = false
@@ -142,7 +167,7 @@ struct TorConfigurationView: View {
142167
}
143168

144169
func openLink() {
145-
log.trace("openLink()")
170+
log.trace(#function)
146171

147172
guard let link = URL(string: "https://phoenix.acinq.co/faq#how-to-use-tor-on-phoenix") else {
148173
return

phoenix-ios/phoenix-ios/views/environment/DeepLink.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ enum DeepLink: Equatable, CustomStringConvertible {
1515
case electrum
1616
case backgroundPayments
1717
case liquiditySettings
18+
case torSettings
1819
case forceCloseChannels
1920
case swapInWallet
2021
case finalWallet
@@ -30,6 +31,7 @@ enum DeepLink: Equatable, CustomStringConvertible {
3031
case .electrum : "electrum"
3132
case .backgroundPayments : "backgroundPayments"
3233
case .liquiditySettings : "liquiditySettings"
34+
case .torSettings : "torSettings"
3335
case .forceCloseChannels : "forceCloseChannels"
3436
case .swapInWallet : "swapInWallet"
3537
case .finalWallet : "finalWallet"

phoenix-ios/phoenix-ios/views/main/HomeView.swift

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct HomeView : MVIView {
8484

8585
@EnvironmentObject var deviceInfo: DeviceInfo
8686
@EnvironmentObject var popoverState: PopoverState
87+
@EnvironmentObject var smartModalState: SmartModalState
8788
@EnvironmentObject var deepLinkManager: DeepLinkManager
8889

8990
// --------------------------------------------------
@@ -481,6 +482,8 @@ struct HomeView : MVIView {
481482
navigationToBackgroundPayments()
482483
} else if noticeMonitor.hasNotice_watchTower {
483484
fixBackgroundAppRefreshDisabled()
485+
} else if noticeMonitor.hasNotice_torNetworkIssue {
486+
showTorNetworkIssueSheet()
484487
} else if noticeMonitor.hasNotice_mempoolFull {
485488
openMempoolFullURL()
486489
}
@@ -520,6 +523,10 @@ struct HomeView : MVIView {
520523
NotificationCell.mempoolFull()
521524
.font(.footnote)
522525

526+
} else if noticeMonitor.hasNotice_torNetworkIssue {
527+
NotificationCell.torNetworkIssue()
528+
.font(.footnote)
529+
523530
} else if let item = bizNotifications_watchtower.first {
524531
let location = isSingle ?
525532
BizNotificationCell.Location.HomeView_Single(preAction: {})
@@ -735,6 +742,7 @@ struct HomeView : MVIView {
735742
if noticeMonitor.hasNotice_mempoolFull { count += 1 }
736743
if noticeMonitor.hasNotice_backgroundPayments { count += 1 }
737744
if noticeMonitor.hasNotice_watchTower { count += 1 }
745+
if noticeMonitor.hasNotice_torNetworkIssue { count += 1 }
738746

739747
count += bizNotifications_watchtower.count
740748

@@ -809,6 +817,7 @@ struct HomeView : MVIView {
809817
case .electrum : break
810818
case .backgroundPayments : break
811819
case .liquiditySettings : break
820+
case .torSettings : break
812821
case .forceCloseChannels : break
813822
case .swapInWallet : break
814823
case .finalWallet : break
@@ -989,7 +998,7 @@ struct HomeView : MVIView {
989998
// --------------------------------------------------
990999

9911000
func toggleCurrencyType() -> Void {
992-
log.trace("toggleCurrencyType()")
1001+
log.trace(#function)
9931002

9941003
// bitcoin -> fiat -> hidden
9951004

@@ -1008,7 +1017,7 @@ struct HomeView : MVIView {
10081017
}
10091018

10101019
func showIncomingBalancePopover() {
1011-
log.trace("showIncomingBalancePopover()")
1020+
log.trace(#function)
10121021

10131022
popoverState.display(dismissable: true) {
10141023
IncomingBalancePopover(
@@ -1025,49 +1034,57 @@ struct HomeView : MVIView {
10251034
}
10261035

10271036
func openNotificationsSheet() {
1028-
log.trace("openNotificationSheet()")
1037+
log.trace(#function)
10291038

10301039
if activeSheet == nil {
10311040
activeSheet = .notificationsView
10321041
}
10331042
}
10341043

10351044
func navigateToBackup() {
1036-
log.trace("navigateToBackup()")
1045+
log.trace(#function)
10371046

10381047
deepLinkManager.broadcast(DeepLink.backup)
10391048
}
10401049

10411050
func navigationToElecrumServer() {
1042-
log.trace("navigateToElectrumServer()")
1051+
log.trace(#function)
10431052

10441053
deepLinkManager.broadcast(DeepLink.electrum)
10451054
}
10461055

10471056
func navigationToBackgroundPayments() {
1048-
log.trace("navigateToBackgroundPayments()")
1057+
log.trace(#function)
10491058

10501059
deepLinkManager.broadcast(DeepLink.backgroundPayments)
10511060
}
10521061

10531062
func openMempoolFullURL() {
1054-
log.trace("openMempoolFullURL()")
1063+
log.trace(#function)
10551064

10561065
if let url = URL(string: "https://phoenix.acinq.co/faq#high-mempool-size-impacts") {
10571066
openURL(url)
10581067
}
10591068
}
10601069

10611070
func fixBackgroundAppRefreshDisabled() {
1062-
log.trace("fixBackgroundAppRefreshDisabled()")
1071+
log.trace(#function)
10631072

10641073
popoverState.display(dismissable: true) {
10651074
BgRefreshDisabledPopover()
10661075
}
10671076
}
10681077

1078+
func showTorNetworkIssueSheet() {
1079+
log.trace(#function)
1080+
1081+
smartModalState.display(dismissable: true) {
1082+
TorNetworkIssueSheet()
1083+
}
1084+
}
1085+
10691086
func didSelectPayment(row: WalletPaymentInfo) -> Void {
1070-
log.trace("didSelectPayment()")
1087+
log.trace(#function)
10711088

10721089
if activeSheet == nil {
10731090
activeSheet = .paymentView(payment: row)

phoenix-ios/phoenix-ios/views/main/MainView_Big.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ struct MainView_Big: View {
620620
case .electrum : showSettings()
621621
case .backgroundPayments : showSettings()
622622
case .liquiditySettings : showSettings()
623+
case .torSettings : showSettings()
623624
case .forceCloseChannels : showSettings()
624625
case .swapInWallet : showSettings()
625626
case .finalWallet : showSettings()
@@ -654,6 +655,10 @@ struct MainView_Big: View {
654655
navCoordinator_settings.path.removeAll()
655656
navCoordinator_settings.path.append(ConfigurationList.NavLinkTag.ChannelManagement)
656657

658+
case .torSettings:
659+
navCoordinator_settings.path.removeAll()
660+
navCoordinator_settings.path.append(ConfigurationList.NavLinkTag.Tor)
661+
657662
case .forceCloseChannels:
658663
navCoordinator_settings.path.removeAll()
659664
navCoordinator_settings.path.append(ConfigurationList.NavLinkTag.ForceCloseChannels)

phoenix-ios/phoenix-ios/views/main/MainView_Small.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,10 @@ struct MainView_Small: View {
689689
navCoordinator.path.append(NavLinkTag.ConfigurationView)
690690
navCoordinator.path.append(ConfigurationList.NavLinkTag.ChannelManagement)
691691

692+
case .torSettings:
693+
navCoordinator.path.append(NavLinkTag.ConfigurationView)
694+
navCoordinator.path.append(ConfigurationList.NavLinkTag.Tor)
695+
692696
case .forceCloseChannels:
693697
navCoordinator.path.append(NavLinkTag.ConfigurationView)
694698
navCoordinator.path.append(ConfigurationList.NavLinkTag.ForceCloseChannels)
@@ -726,7 +730,8 @@ struct MainView_Small: View {
726730
case .drainWallet : newNavLinkTag = .ConfigurationView ; delay *= 2
727731
case .electrum : newNavLinkTag = .ConfigurationView ; delay *= 2
728732
case .backgroundPayments : newNavLinkTag = .ConfigurationView ; delay *= 3
729-
case .liquiditySettings : newNavLinkTag = .ConfigurationView ; delay *= 3
733+
case .liquiditySettings : newNavLinkTag = .ConfigurationView ; delay *= 2
734+
case .torSettings : newNavLinkTag = .ConfigurationView ; delay *= 2
730735
case .forceCloseChannels : newNavLinkTag = .ConfigurationView ; delay *= 2
731736
case .swapInWallet : newNavLinkTag = .ConfigurationView ; delay *= 2
732737
case .finalWallet : newNavLinkTag = .ConfigurationView ; delay *= 2

0 commit comments

Comments
 (0)