Skip to content

Commit 771737a

Browse files
committed
fix: remove geoblock restrictions from inbound and outbound calculation
1 parent 191db39 commit 771737a

File tree

3 files changed

+2
-65
lines changed

3 files changed

+2
-65
lines changed

Bitkit/Services/LightningService.swift

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,8 @@ class LightningService {
368368
return false
369369
}
370370

371-
// When geoblocked, only count non-LSP channels
372-
let isGeoblocked = GeoService.shared.isGeoBlocked
373-
let channelsToUse = isGeoblocked ? getNonLspChannels() : channels
374-
375371
let totalNextOutboundHtlcLimitSats =
376-
channelsToUse
372+
channels
377373
.filter(\.isUsable)
378374
.map(\.nextOutboundHtlcLimitMsat)
379375
.reduce(0, +) / 1000
@@ -436,16 +432,6 @@ class LightningService {
436432
throw AppError(serviceError: .nodeNotSetup)
437433
}
438434

439-
// When geoblocked, verify we have external (non-LSP) peers
440-
let isGeoblocked = GeoService.shared.isGeoBlocked
441-
if isGeoblocked && !hasExternalPeers() {
442-
Logger.error("Cannot send Lightning payment when geoblocked without external peers")
443-
throw AppError(
444-
message: "Lightning send unavailable",
445-
debugMessage: "You need channels with non-Blocktank nodes to send Lightning payments."
446-
)
447-
}
448-
449435
Logger.info("Paying bolt11: \(bolt11)")
450436

451437
do {
@@ -657,31 +643,6 @@ extension LightningService {
657643
try node.getAddressBalance(addressStr: address)
658644
}
659645
}
660-
661-
/// Returns LSP (Blocktank) peer node IDs
662-
func getLspPeerNodeIds() -> [String] {
663-
return Env.trustedLnPeers.map(\.nodeId)
664-
}
665-
666-
/// Checks if there are connected peers other than LSP peers
667-
/// Used for geoblocking to determine if Lightning operations can proceed
668-
func hasExternalPeers() -> Bool {
669-
guard let peers else { return false }
670-
let lspNodeIds = Set(getLspPeerNodeIds())
671-
return peers.contains { peer in
672-
!lspNodeIds.contains(peer.nodeId)
673-
}
674-
}
675-
676-
/// Filters channels to exclude LSP channels
677-
/// Used for geoblocking to only allow operations through non-Blocktank channels
678-
func getNonLspChannels() -> [ChannelDetails] {
679-
guard let channels else { return [] }
680-
let lspNodeIds = Set(getLspPeerNodeIds())
681-
return channels.filter { channel in
682-
!lspNodeIds.contains(channel.counterpartyNodeId)
683-
}
684-
}
685646
}
686647

687648
// MARK: Events

Bitkit/ViewModels/WalletViewModel.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -544,31 +544,10 @@ class WalletViewModel: ObservableObject {
544544
return capacity
545545
}
546546

547-
/// Total inbound Lightning capacity excluding LSP (Blocktank) channels
548-
/// Used when geoblocked to show only non-Blocktank receiving capacity
549-
var totalNonLspInboundLightningSats: UInt64? {
550-
let nonLspChannels = lightningService.getNonLspChannels()
551-
guard !nonLspChannels.isEmpty else {
552-
return nil
553-
}
554-
555-
var capacity: UInt64 = 0
556-
for channel in nonLspChannels {
557-
capacity += channel.inboundCapacityMsat / 1000
558-
}
559-
return capacity
560-
}
561-
562547
var hasUsableChannels: Bool {
563548
return channels?.contains(where: \.isChannelReady) ?? false
564549
}
565550

566-
/// Check if there are non-LSP (non-Blocktank) channels available
567-
/// Used for geoblocking to determine if Lightning operations can proceed
568-
func hasNonLspChannels() -> Bool {
569-
return !lightningService.getNonLspChannels().isEmpty
570-
}
571-
572551
func refreshBip21(forceRefreshBolt11: Bool = false) async throws {
573552
// Get old payment ID and tags before refreshing (which may change payment ID)
574553
let oldPaymentId = await paymentId()

Bitkit/Views/Wallets/Receive/ReceiveEdit.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,7 @@ struct ReceiveEdit: View {
177177
private func needsAdditionalCjit() -> Bool {
178178
let isGeoBlocked = GeoService.shared.isGeoBlocked
179179
let minimumAmount = blocktank.minCjitSats ?? 0
180-
// When geoblocked, only count non-LSP inbound capacity
181-
let inboundCapacity = isGeoBlocked
182-
? (wallet.totalNonLspInboundLightningSats ?? 0)
183-
: (wallet.totalInboundLightningSats ?? 0)
180+
let inboundCapacity = wallet.totalInboundLightningSats ?? 0
184181
let invoiceAmount = amountViewModel.amountSats
185182

186183
// Calculate maxClientBalance using TransferViewModel

0 commit comments

Comments
 (0)