File tree Expand file tree Collapse file tree 7 files changed +21
-21
lines changed
androidTest/java/to/bitkit/services
test/java/to/bitkit/repositories Expand file tree Collapse file tree 7 files changed +21
-21
lines changed 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 @@ -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 @@ -584,7 +584,7 @@ class BlocktankService(
584584 }
585585 }
586586
587- suspend fun cjitOrders (
587+ suspend fun cjitEntries (
588588 entryIds : List <String >? = null,
589589 filter : CJitStateEnum ? = null,
590590 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 ,
Original file line number Diff line number Diff line change @@ -44,8 +44,8 @@ class BlocktankRepoTest : BaseUnitTest() {
4444 wheneverBlocking { coreService.blocktank.orders(refresh = false ) }.thenReturn(emptyList())
4545 wheneverBlocking { coreService.blocktank.orders(refresh = true ) }.thenReturn(emptyList())
4646
47- wheneverBlocking { coreService.blocktank.cjitOrders (refresh = false ) }.thenReturn(emptyList())
48- wheneverBlocking { coreService.blocktank.cjitOrders (refresh = true ) }.thenReturn(emptyList())
47+ wheneverBlocking { coreService.blocktank.cjitEntries (refresh = false ) }.thenReturn(emptyList())
48+ wheneverBlocking { coreService.blocktank.cjitEntries (refresh = true ) }.thenReturn(emptyList())
4949 }
5050
5151 private fun createSut (): BlocktankRepo {
You can’t perform that action at this time.
0 commit comments