Skip to content

Commit b489af0

Browse files
committed
fix: don't prevent the user from using purchased channels when geoblocked
1 parent 384aad9 commit b489af0

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

Bitkit/ViewModels/WalletViewModel.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,7 @@ class WalletViewModel: ObservableObject {
591591

592592
let amountSats = invoiceAmountSats > 0 ? invoiceAmountSats : nil
593593

594-
// When geoblocked, only create Lightning invoice if we have non-LSP channels
595-
let isGeoblocked = GeoService.shared.isGeoBlocked
596-
let hasUsableChannels: Bool = if isGeoblocked {
597-
hasNonLspChannels()
598-
} else {
599-
channels?.count ?? 0 > 0
600-
}
594+
let hasUsableChannels = channels?.contains(where: \.isChannelReady) ?? false
601595

602596
if hasUsableChannels {
603597
if forceRefreshBolt11 || bolt11.isEmpty {

Bitkit/Views/Wallets/Receive/ReceiveQr.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ struct ReceiveQr: View {
4343
}
4444

4545
private var hasUsableChannels: Bool {
46-
if GeoService.shared.isGeoBlocked {
47-
return wallet.hasNonLspChannels()
48-
} else {
49-
return wallet.channelCount != 0
50-
}
46+
return wallet.channels?.contains(where: \.isChannelReady) ?? false
5147
}
5248

5349
private var availableTabItems: [TabItem<ReceiveTab>] {
@@ -67,12 +63,7 @@ struct ReceiveQr: View {
6763
}
6864

6965
var showingCjitOnboarding: Bool {
70-
// Show CJIT onboarding when:
71-
// 1. No channels at all, OR
72-
// 2. Geoblocked with only Blocktank channels (treat as no usable channels)
73-
let hasNoUsableChannels = (wallet.channelCount == 0) ||
74-
(GeoService.shared.isGeoBlocked && !wallet.hasNonLspChannels())
75-
return hasNoUsableChannels && cjitInvoice == nil && selectedTab == .spending
66+
return !hasUsableChannels && cjitInvoice == nil && selectedTab == .spending
7667
}
7768

7869
var body: some View {
@@ -109,7 +100,7 @@ struct ReceiveQr: View {
109100
.foregroundColor(.purpleAccent),
110101
isDisabled: wallet.nodeLifecycleState != .running
111102
) {
112-
if GeoService.shared.isGeoBlocked && !wallet.hasNonLspChannels() {
103+
if GeoService.shared.isGeoBlocked && !hasUsableChannels {
113104
navigationPath.append(.cjitGeoBlocked)
114105
} else {
115106
navigationPath.append(.cjitAmount)

0 commit comments

Comments
 (0)