Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ This app integrates with:
```bash
# Standard build - Open Bitkit.xcodeproj in Xcode and build

# E2E test build (uses local Electrum backend)
# E2E test build (uses local Electrum backend by default)
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
-scheme Bitkit \
-configuration Debug \
SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited) E2E_BUILD' \
build

# E2E test build with network Electrum and regtest (Info.plist build setting)
E2E_BACKEND=network E2E_NETWORK=regtest \
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
-scheme Bitkit \
-configuration Debug \
SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited) E2E_BUILD' \
build
```

### Code Formatting
Expand Down Expand Up @@ -197,7 +205,7 @@ New feature (`TransferTrackingManager`) tracks pending transfers to handle edge
- The app currently runs on **regtest only** (see `LightningService.swift:92` guard)
- VSS (Versioned Storage Service) authentication is not yet implemented
- Electrum/Esplora server URLs are configurable via `Env`
- E2E builds use local Electrum backend via `E2E_BUILD` compilation flag
- E2E builds use local Electrum backend via `E2E_BUILD` compilation flag (override with `E2E_BACKEND`/`E2E_NETWORK` build settings)

### Error Handling

Expand Down
39 changes: 37 additions & 2 deletions Bitkit/Constants/Env.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ enum Env {
#endif
}

private static func infoPlistValue(_ key: String) -> String? {
let value = Bundle.main.object(forInfoDictionaryKey: key) as? String
let trimmed = value?.trimmingCharacters(in: .whitespacesAndNewlines)
return trimmed?.isEmpty == false ? trimmed : nil
}

private static var e2eBackend: String {
(infoPlistValue("E2E_BACKEND") ?? "local").lowercased()
}

private static var e2eNetwork: LDKNode.Network {
switch (infoPlistValue("E2E_NETWORK") ?? "regtest").lowercased() {
case "bitcoin", "mainnet":
return .bitcoin
case "testnet":
return .testnet
case "signet":
return .signet
default:
return .regtest
}
}

static var isGeoblockingEnabled: Bool {
#if CHECK_GEOBLOCK
return true
Expand All @@ -48,7 +71,19 @@ enum Env {

// MARK: wallet services

static let network: LDKNode.Network = (isDebug || isUnitTest || isE2E) ? .regtest : .bitcoin
static let network: LDKNode.Network = {
if isUnitTest {
return .regtest
}
if isE2E {
return e2eNetwork
}
if isDebug {
return .regtest
}
return .bitcoin
}()

static let ldkLogLevel = LDKNode.LogLevel.trace

static let walletSyncIntervalSecs: UInt64 = 10 // TODO: play around with this
Expand Down Expand Up @@ -80,7 +115,7 @@ enum Env {
// MARK: Server URLs

static var electrumServerUrl: String {
if isE2E {
if isE2E, e2eBackend == "local" {
return "tcp://127.0.0.1:60001"
}

Expand Down
4 changes: 4 additions & 0 deletions Bitkit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
</array>
</dict>
</array>
<key>E2E_BACKEND</key>
<string>$(E2E_BACKEND)</string>
<key>E2E_NETWORK</key>
<string>$(E2E_NETWORK)</string>
<key>NSFaceIDUsageDescription</key>
<string>Bitkit uses Face ID to securely authenticate access to your wallet and protect your Bitcoin.</string>
<key>UIAppFonts</key>
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The app automatically selects the network based on the build configuration:

### Building for E2E tests

To produce an E2E build (uses the local Electrum backend), pass the `E2E_BUILD` compilation flag:
To produce an E2E build (uses the local Electrum backend by default), pass the `E2E_BUILD` compilation flag:

```bash
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
Expand All @@ -36,6 +36,26 @@ xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
build
```

You can also set the backend/network at build time via Info.plist substitutions:

```bash
# Use network Electrum with regtest
E2E_BACKEND=network E2E_NETWORK=regtest \
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
-scheme Bitkit \
-configuration Debug \
SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited) E2E_BUILD' \
build

# Use network Electrum with mainnet
E2E_BACKEND=network E2E_NETWORK=bitcoin \
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
-scheme Bitkit \
-configuration Debug \
SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited) E2E_BUILD' \
build
```

## Localization

### Pulling Translations
Expand Down
Loading