Skip to content

Commit 490f981

Browse files
committed
chore: update env vars for mainnet
1 parent 7d1578a commit 490f981

File tree

13 files changed

+269
-168
lines changed

13 files changed

+269
-168
lines changed

Bitkit/AppScene.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ struct AppScene: View {
239239
// Schedule full backup after wallet create/restore to prevent epoch dates in backup status
240240
await BackupService.shared.scheduleFullBackup()
241241
} catch {
242-
Logger.error("Failed to start wallet")
242+
Logger.error(error, context: "Failed to start wallet")
243243
Haptics.notify(.error)
244244
}
245245
}

Bitkit/Bitkit.entitlements

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<key>keychain-access-groups</key>
1818
<array>
1919
<string>$(AppIdentifierPrefix)to.bitkit</string>
20+
<string>$(AppIdentifierPrefix)to.bitkit.signet</string>
21+
<string>$(AppIdentifierPrefix)to.bitkit.testnet</string>
22+
<string>$(AppIdentifierPrefix)to.bitkit.regtest</string>
2023
</array>
2124
</dict>
2225
</plist>

Bitkit/Constants/Env.swift

Lines changed: 96 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,67 @@ enum Env {
99
static let isPreview = ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
1010
static let isTestFlight = Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
1111
static let isUnitTest = ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] != nil
12-
#if E2E_BUILD
13-
static let isE2E = true
14-
#else
15-
static let isE2E = ProcessInfo.processInfo.environment["E2E"] == "true"
16-
#endif
17-
static let dustLimit = 547
18-
static let msatsPerSat: UInt64 = 1000
1912

20-
#if CHECK_GEOBLOCK
21-
static let isGeoblockingEnabled = true
13+
#if DEBUG
14+
static let isDebug = true
2215
#else
23-
static let isGeoblockingEnabled = ProcessInfo.processInfo.environment["GEO"] == "true"
16+
static let isDebug = false
2417
#endif
2518

19+
static var isE2E: Bool {
20+
#if E2E_BUILD
21+
return true
22+
#else
23+
return ProcessInfo.processInfo.environment["E2E"] == "true"
24+
#endif
25+
}
26+
27+
static var isGeoblockingEnabled: Bool {
28+
#if CHECK_GEOBLOCK
29+
return true
30+
#else
31+
return ProcessInfo.processInfo.environment["GEO"] == "true"
32+
#endif
33+
}
34+
2635
/// The current execution context of the app
2736
static var currentExecutionContext: ExecutionContext {
28-
return Bundle.main.bundleIdentifier?.lowercased().contains("notification") == true ? .pushNotificationExtension : .foregroundApp
37+
let isNotificationExtension = Bundle.main.bundleIdentifier?.lowercased().contains("notification") == true
38+
return isNotificationExtension ? .pushNotificationExtension : .foregroundApp
2939
}
3040

3141
// {Team ID}.{Keychain Group}
32-
static let keychainGroup = "KYH47R284B.to.bitkit" // TODO: needs to change for regtest/mainnet so we don't use same group
33-
34-
#if targetEnvironment(simulator)
35-
static let isSim = true
36-
#else
37-
static let isSim = false
38-
#endif
39-
40-
#if DEBUG
41-
static let isDebug = true
42-
#else
43-
static let isDebug = false
44-
#endif
42+
/// Returns the keychain access group based on the current network
43+
static var keychainGroup: String {
44+
let base = "KYH47R284B.to.bitkit"
45+
let networkSuffix = networkName(network)
46+
return networkSuffix == "bitcoin" ? base : "\(base).\(networkSuffix)"
47+
}
4548

4649
// MARK: wallet services
4750

48-
static let network: LDKNode.Network = .regtest
51+
static let network: LDKNode.Network = (isE2E || isUnitTest) ? .regtest : .bitcoin
52+
static let ldkLogLevel = LDKNode.LogLevel.trace
53+
4954
static let walletSyncIntervalSecs: UInt64 = 10 // TODO: play around with this
5055

5156
/// Converts the LDKNode.Network to BitkitCore.Network for use with bitkitcore functions
5257
static var bitkitCoreNetwork: BitkitCore.Network {
5358
switch network {
54-
case .bitcoin:
55-
return .bitcoin
56-
case .testnet:
57-
return .testnet
58-
case .signet:
59-
return .signet
60-
case .regtest:
61-
return .regtest
59+
case .bitcoin: .bitcoin
60+
case .testnet: .testnet
61+
case .signet: .signet
62+
case .regtest: .regtest
63+
}
64+
}
65+
66+
/// Returns the lowercase name of the network (e.g., "bitcoin", "testnet", "signet", "regtest")
67+
private static func networkName(_ network: LDKNode.Network) -> String {
68+
switch network {
69+
case .bitcoin: "bitcoin"
70+
case .testnet: "testnet"
71+
case .signet: "signet"
72+
case .regtest: "regtest"
6273
}
6374
}
6475

@@ -74,27 +85,10 @@ enum Env {
7485
}
7586

7687
switch network {
77-
case .bitcoin:
78-
return "ssl://35.187.18.233:8900"
79-
case .signet:
80-
fatalError("Signet network not implemented")
81-
case .testnet:
82-
return "ssl://electrum.blockstream.info:60002"
83-
case .regtest:
84-
return "tcp://34.65.252.32:18483"
85-
}
86-
}
87-
88-
static var esploraServerUrl: String {
89-
switch network {
90-
case .regtest:
91-
return "https://bitkit.stag0.blocktank.to/electrs"
92-
case .bitcoin:
93-
fatalError("Bitcoin network not implemented")
94-
case .testnet:
95-
fatalError("Testnet network not implemented")
96-
case .signet:
97-
fatalError("Signet network not implemented")
88+
case .bitcoin: return "ssl://fulcrum.bitkit.blocktank.to:8900"
89+
case .signet: return "ssl://mempool.space:60602"
90+
case .testnet: return "ssl://electrum.blockstream.info:60002"
91+
case .regtest: return "ssl://fulcrum.bitkit.stag0.blocktank.to:18484"
9892
}
9993
}
10094

@@ -112,83 +106,50 @@ enum Env {
112106
}
113107

114108
static func ldkStorage(walletIndex: Int) -> URL {
115-
switch network {
116-
case .regtest:
117-
return
118-
appStorageUrl
119-
.appendingPathComponent("regtest")
120-
.appendingPathComponent("wallet\(walletIndex)/ldk")
121-
case .bitcoin:
122-
return
123-
appStorageUrl
124-
.appendingPathComponent("bitcoin")
125-
.appendingPathComponent("wallet\(walletIndex)/ldk")
126-
case .testnet:
127-
fatalError("Testnet network not implemented")
128-
case .signet:
129-
fatalError("Signet network not implemented")
130-
}
109+
appStorageUrl
110+
.appendingPathComponent(networkName(network))
111+
.appendingPathComponent("wallet\(walletIndex)/ldk")
131112
}
132113

133114
static func bitkitCoreStorage(walletIndex: Int) -> URL {
134-
switch network {
135-
case .regtest:
136-
return
137-
appStorageUrl
138-
.appendingPathComponent("regtest")
139-
.appendingPathComponent("wallet\(walletIndex)/core")
140-
case .bitcoin:
141-
return
142-
appStorageUrl
143-
.appendingPathComponent("bitcoin")
144-
.appendingPathComponent("wallet\(walletIndex)/core")
145-
case .testnet:
146-
fatalError("Testnet network not implemented")
147-
case .signet:
148-
fatalError("Signet network not implemented")
149-
}
115+
appStorageUrl
116+
.appendingPathComponent(networkName(network))
117+
.appendingPathComponent("wallet\(walletIndex)/core")
150118
}
151119

152120
static var ldkRgsServerUrl: String? {
153121
switch network {
154-
case .regtest:
155-
return "https://bitkit.stag0.blocktank.to/rgs/snapshot"
156-
case .bitcoin:
157-
return "https://rgs.blocktank.to/snapshot"
158-
case .testnet:
159-
return "https://rapidsync.lightningdevkit.org/testnet/snapshot"
160-
case .signet:
161-
return nil
122+
case .bitcoin: "https://rgs.blocktank.to/snapshot"
123+
case .signet: "https://rapidsync.lightningdevkit.org/signet/snapshot"
124+
case .testnet: "https://rapidsync.lightningdevkit.org/testnet/snapshot"
125+
case .regtest: "https://bitkit.stag0.blocktank.to/rgs/snapshot"
162126
}
163127
}
164128

165129
// TODO: remove this to load from BT API instead
166130
static var trustedLnPeers: [LnPeer] {
167131
switch network {
168-
case .regtest:
132+
case .bitcoin:
169133
return [
170-
// Staging Blocktank node
171-
.init(nodeId: "028a8910b0048630d4eb17af25668cdd7ea6f2d8ae20956e7a06e2ae46ebcb69fc", host: "34.65.86.104", port: 9400),
134+
.init(nodeId: "039b8b4dd1d88c2c5db374290cda397a8f5d79f312d6ea5d5bfdfc7c6ff363eae3", host: "34.65.111.104", port: 9735),
135+
.init(nodeId: "03816141f1dce7782ec32b66a300783b1d436b19777e7c686ed00115bd4b88ff4b", host: "34.65.191.64", port: 9735),
136+
.init(nodeId: "02a371038863605300d0b3fc9de0cf5ccb57728b7f8906535709a831b16e311187", host: "34.65.186.40", port: 9735),
172137
]
173-
case .bitcoin:
138+
case .signet:
174139
return []
175140
case .testnet:
176141
return []
177-
case .signet:
178-
return []
142+
case .regtest:
143+
return [
144+
.init(nodeId: "028a8910b0048630d4eb17af25668cdd7ea6f2d8ae20956e7a06e2ae46ebcb69fc", host: "34.65.86.104", port: 9400),
145+
]
179146
}
180147
}
181148

182149
static var blocktankBaseUrl: String {
183150
switch network {
184-
case .regtest:
185-
return "https://api.stag0.blocktank.to"
186-
case .bitcoin:
187-
fatalError("Bitcoin network not implemented")
188-
case .testnet:
189-
fatalError("Testnet network not implemented")
190-
case .signet:
191-
fatalError("Signet network not implemented")
151+
case .bitcoin: "https://api1.blocktank.to/api"
152+
default: "https://api.stag0.blocktank.to/"
192153
}
193154
}
194155

@@ -197,11 +158,19 @@ enum Env {
197158
}
198159

199160
static var blocktankClientServer: String {
200-
"\(blocktankBaseUrl)/blocktank/api/v2"
161+
switch network {
162+
case .bitcoin: "\(blocktankBaseUrl)"
163+
default: "\(blocktankBaseUrl)/blocktank/api/v2"
164+
}
201165
}
202166

203167
static var btcRatesServer: String {
204-
"https://bitkit.stag0.blocktank.to/fx/rates/btc" // TODO: switch to prod when available
168+
switch network {
169+
case .bitcoin: "https://blocktank.synonym.to/fx/rates/btc"
170+
case .signet: "https://bitkit.stag0.blocktank.to/fx/rates/btc"
171+
case .testnet: "https://bitkit.stag0.blocktank.to/fx/rates/btc"
172+
case .regtest: "https://bitkit.stag0.blocktank.to/fx/rates/btc"
173+
}
205174
}
206175

207176
static let fxRateRefreshInterval: TimeInterval = 2 * 60 // 2 minutes
@@ -217,45 +186,39 @@ enum Env {
217186
.wakeToTimeout,
218187
]
219188

189+
static var vssStoreIdPrefix: String {
190+
"bitkit_v1_\(networkName(network))"
191+
}
192+
220193
static var vssServerUrl: String {
221194
switch network {
222-
case .bitcoin:
223-
fatalError("Bitcoin network not implemented")
224-
default:
225-
return "https://bitkit.stag0.blocktank.to/vss_rs_auth"
195+
case .bitcoin: "https://bitkit.to/vss_rs_auth"
196+
default: "https://bitkit.stag0.blocktank.to/vss_rs_auth"
226197
}
227198
}
228199

229-
static var vssStoreIdPrefix: String {
200+
static var lnurlAuthServerUrl: String {
230201
switch network {
231-
case .bitcoin:
232-
fatalError("Bitcoin network not implemented")
233-
case .regtest:
234-
return "bitkit_v1_regtest"
235-
case .testnet:
236-
return "bitkit_v1_testnet"
237-
case .signet:
238-
return "bitkit_v1_signet"
202+
case .bitcoin: "https://bitkit.to/lnurl_auth/auth"
203+
default: "https://bitkit.stag0.blocktank.to/lnurl_auth/auth"
239204
}
240205
}
241206

242-
static var lnurlAuthServerUrl: String {
207+
static var blockExplorerUrl: String {
243208
switch network {
244-
case .bitcoin:
245-
fatalError("LNURL-auth server not implemented for mainnet")
246-
default:
247-
return "https://bitkit.stag0.blocktank.to/lnurl_auth/auth"
209+
case .bitcoin: "https://mempool.space"
210+
case .signet: "https://mutinynet.com"
211+
case .testnet: "https://mempool.space/testnet"
212+
case .regtest: "https://mempool.bitkit.stag0.blocktank.to"
248213
}
249214
}
250215

251216
static var logDirectory: String {
252-
return appStorageUrl.appendingPathComponent("logs").path
253-
}
254-
255-
static var ldkLogLevel: LDKNode.LogLevel {
256-
return .trace
217+
appStorageUrl.appendingPathComponent("logs").path
257218
}
258219

220+
static let dustLimit = 547
221+
static let msatsPerSat: UInt64 = 1000
259222
static let appStoreUrl = "https://apps.apple.com/app/bitkit-wallet/id6502440655"
260223
static let playStoreUrl = "https://play.google.com/store/apps/details?id=to.bitkit"
261224
static let githubUrl = "https://www.github.com/synonymdev/bitkit"

Bitkit/MainNavView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ struct MainNavView: View {
389389

390390
// Dev settings
391391
case .blocktankRegtest: BlocktankRegtestView()
392+
case .ldkDebug: LdkDebugScreen()
392393
case .orders: ChannelOrders()
393394
case .logs: LogView()
394395
}

Bitkit/Services/BackupService.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class BackupService {
8585

8686
guard shouldStart == true else { return }
8787

88-
try? await vssBackupClient.setup()
8988
Logger.debug("Start observing backup statuses and data store changes", context: "BackupService")
9089
startBackupStatusObservers()
9190
startDataStoreListeners()
@@ -130,8 +129,6 @@ class BackupService {
130129
}
131130

132131
do {
133-
try await vssBackupClient.setup()
134-
135132
let data = try await getBackupDataBytes(category: category)
136133
let _ = try await vssBackupClient.putObject(key: category.rawValue, data: data)
137134

Bitkit/Services/CoreService.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,6 @@ class ActivityService {
241241

242242
func removeAll() async throws {
243243
try await ServiceQueue.background(.core) {
244-
// Only allow removing on regtest for now
245-
guard Env.network == .regtest else {
246-
throw AppError(message: "Regtest only", debugMessage: nil)
247-
}
248-
249244
// Get all activities and delete them one by one
250245
let activities = try getActivities(
251246
filter: .all, txType: nil, tags: nil, search: nil, minDate: nil, maxDate: nil, limit: nil, sortDirection: nil

0 commit comments

Comments
 (0)