File tree Expand file tree Collapse file tree 11 files changed +38
-21
lines changed
androidTest/java/to/bitkit/services
test/java/to/bitkit/repositories Expand file tree Collapse file tree 11 files changed +38
-21
lines changed Original file line number Diff line number Diff line change 4646 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4747 CHATWOOT_API : ${{ secrets.CHATWOOT_API }}
4848 E2E : true
49+ GEO : false
4950 run : ./gradlew assembleDevDebug
5051
5152 - name : Rename APK
Original file line number Diff line number Diff line change @@ -76,6 +76,14 @@ Simply pass `E2E=true` as environment variable and build any flavor.
7676E2E=true ./gradlew assembleDevRelease
7777```
7878
79+ #### Disable Geoblocking Checks
80+
81+ By default, geoblocking checks via API are enabled. To disable at build time, use the ` GEO ` environment variable:
82+
83+ ``` sh
84+ GEO=false E2E=true ./gradlew assembleDevRelease
85+ ```
86+
7987### Build for Release
8088
8189** Prerequisites**
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ android {
4646 useSupportLibrary = true
4747 }
4848 buildConfigField(" boolean" , " E2E" , System .getenv(" E2E" )?.toBoolean()?.toString() ? : " false" )
49+ buildConfigField(" boolean" , " GEO" , System .getenv(" GEO" )?.toBoolean()?.toString() ? : " true" )
4950 }
5051
5152 flavorDimensions + = " network"
Original file line number Diff line number Diff line change @@ -82,11 +82,11 @@ class BlocktankTest {
8282 }
8383
8484 @Test
85- fun testCreateCjitOrder () = runBlocking {
85+ fun testCreateCjitEntry () = runBlocking {
8686 // Test creating a CJIT order
8787 val channelSizeSat = 100_000uL // 100k sats
8888 val invoiceSat = 10_000uL // 10k sats for the invoice
89- val invoiceDescription = " Test CJIT order "
89+ val invoiceDescription = " Test CJIT"
9090 val nodeId = " 03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad" // Example node ID
9191 val channelExpiryWeeks = 6u
9292 val options = CreateCjitOptions (source = " bitkit" , discountCode = null )
@@ -122,7 +122,7 @@ class BlocktankTest {
122122 )
123123
124124 // Test getting CJIT entries
125- val entries = service.blocktank.cjitOrders (
125+ val entries = service.blocktank.cjitEntries (
126126 entryIds = listOf (cjitEntry.id),
127127 filter = null ,
128128 refresh = true
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import kotlin.io.path.Path
1515internal object Env {
1616 val isDebug = BuildConfig .DEBUG
1717 const val isE2eTest = BuildConfig .E2E
18+ const val isGeoblockingEnabled = BuildConfig .GEO
1819 val network = Network .valueOf(BuildConfig .NETWORK )
1920 val walletSyncIntervalSecs = 10_uL // TODO review
2021 val platform = " Android ${Build .VERSION .RELEASE } (API ${Build .VERSION .SDK_INT } )"
Original file line number Diff line number Diff line change @@ -148,8 +148,8 @@ class WakeNodeWorker @AssistedInject constructor(
148148 val sats = channel.amountOnClose
149149 self.bestAttemptContent?.title = " Received ⚡ $sats sats"
150150
151- val cjitOrder = channel.let { blocktankRepo.getCjitOrder (it) }
152- if (cjitOrder != null ) {
151+ val cjitEntry = channel.let { blocktankRepo.getCjitEntry (it) }
152+ if (cjitEntry != null ) {
153153 val amount = channel.amountOnClose.toLong()
154154
155155 // Save for UI to pick up
@@ -161,7 +161,7 @@ class WakeNodeWorker @AssistedInject constructor(
161161 sats = amount,
162162 )
163163 )
164- activityRepo.insertActivityFromChannel(cjitOrder = cjitOrder , channel = channel)
164+ activityRepo.insertActivityFromCjit(cjitEntry = cjitEntry , channel = channel)
165165 }
166166 }
167167 } else if (self.notificationType == orderPaymentConfirmed) {
Original file line number Diff line number Diff line change @@ -510,17 +510,17 @@ class ActivityRepo @Inject constructor(
510510 }
511511
512512 /* *
513- * Inserts a new activity
513+ * Inserts a new activity for a fulfilled (channel ready) cjit channel order
514514 */
515- suspend fun insertActivityFromChannel (
516- cjitOrder : IcJitEntry ? ,
515+ suspend fun insertActivityFromCjit (
516+ cjitEntry : IcJitEntry ? ,
517517 channel : ChannelDetails ,
518518 ): Result <Unit > = withContext(bgDispatcher) {
519519 runCatching {
520- requireNotNull(cjitOrder )
520+ requireNotNull(cjitEntry )
521521
522522 val amount = channel.amountOnClose
523- val now = nowTimestamp().toEpochMilli() .toULong()
523+ val now = nowTimestamp().epochSecond .toULong()
524524
525525 return @withContext insertActivity(
526526 Activity .Lightning (
@@ -530,7 +530,7 @@ class ActivityRepo @Inject constructor(
530530 status = PaymentState .SUCCEEDED ,
531531 value = amount,
532532 fee = 0U ,
533- invoice = cjitOrder .invoice.request,
533+ invoice = cjitEntry .invoice.request,
534534 message = " " ,
535535 timestamp = now,
536536 preimage = null ,
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ class BlocktankRepo @Inject constructor(
9797 }
9898 }
9999
100- suspend fun getCjitOrder (channel : ChannelDetails ): IcJitEntry ? = withContext(bgDispatcher) {
100+ suspend fun getCjitEntry (channel : ChannelDetails ): IcJitEntry ? = withContext(bgDispatcher) {
101101 return @withContext _blocktankState .value.cjitEntries.firstOrNull { order ->
102102 order.channelSizeSat == channel.channelValueSats &&
103103 order.lspNode.pubkey == channel.counterpartyNodeId
@@ -131,7 +131,7 @@ class BlocktankRepo @Inject constructor(
131131
132132 // Sync instantly from cache
133133 val cachedOrders = coreService.blocktank.orders(refresh = false )
134- val cachedCjitEntries = coreService.blocktank.cjitOrders (refresh = false )
134+ val cachedCjitEntries = coreService.blocktank.cjitEntries (refresh = false )
135135 _blocktankState .update { state ->
136136 state.copy(
137137 orders = cachedOrders,
@@ -142,7 +142,7 @@ class BlocktankRepo @Inject constructor(
142142
143143 // Then refresh from server
144144 val orders = coreService.blocktank.orders(refresh = true )
145- val cjitEntries = coreService.blocktank.cjitOrders (refresh = true )
145+ val cjitEntries = coreService.blocktank.cjitEntries (refresh = true )
146146 _blocktankState .update { state ->
147147 state.copy(
148148 orders = orders,
Original file line number Diff line number Diff line change @@ -111,7 +111,13 @@ class CoreService @Inject constructor(
111111 }
112112 }
113113
114+ @Suppress(" KotlinConstantConditions" )
114115 private suspend fun isGeoBlocked (): Boolean {
116+ if (! Env .isGeoblockingEnabled) {
117+ Logger .verbose(" Geoblocking disabled via build config" , context = " GeoCheck" )
118+ return false
119+ }
120+
115121 return ServiceQueue .CORE .background {
116122 runCatching {
117123 Logger .verbose(" Checking geo status…" , context = " GeoCheck" )
@@ -578,7 +584,7 @@ class BlocktankService(
578584 }
579585 }
580586
581- suspend fun cjitOrders (
587+ suspend fun cjitEntries (
582588 entryIds : List <String >? = null,
583589 filter : CJitStateEnum ? = null,
584590 refresh : Boolean = true,
Original file line number Diff line number Diff line change @@ -221,8 +221,8 @@ class AppViewModel @Inject constructor(
221221
222222 is Event .ChannelReady -> {
223223 val channel = lightningRepo.getChannels()?.find { it.channelId == event.channelId }
224- val cjitOrder = channel?.let { blocktankRepo.getCjitOrder (it) }
225- if (cjitOrder != null ) {
224+ val cjitEntry = channel?.let { blocktankRepo.getCjitEntry (it) }
225+ if (cjitEntry != null ) {
226226 val amount = channel.amountOnClose.toLong()
227227 showNewTransactionSheet(
228228 NewTransactionSheetDetails (
@@ -232,7 +232,7 @@ class AppViewModel @Inject constructor(
232232 ),
233233 event = event
234234 )
235- activityRepo.insertActivityFromChannel(cjitOrder = cjitOrder , channel = channel)
235+ activityRepo.insertActivityFromCjit(cjitEntry = cjitEntry , channel = channel)
236236 } else {
237237 toast(
238238 type = Toast .ToastType .LIGHTNING ,
You can’t perform that action at this time.
0 commit comments