@@ -24,8 +24,8 @@ import to.bitkit.models.blocktank.BlocktankNotificationType.incomingHtlc
2424import to.bitkit.models.blocktank.BlocktankNotificationType.mutualClose
2525import to.bitkit.models.blocktank.BlocktankNotificationType.orderPaymentConfirmed
2626import to.bitkit.models.blocktank.BlocktankNotificationType.wakeToTimeout
27+ import to.bitkit.repositories.LightningRepository
2728import to.bitkit.services.CoreService
28- import to.bitkit.services.LightningService
2929import to.bitkit.ui.pushNotification
3030import to.bitkit.utils.Logger
3131import to.bitkit.utils.withPerformanceLogging
@@ -36,7 +36,7 @@ class WakeNodeWorker @AssistedInject constructor(
3636 @Assisted private val appContext : Context ,
3737 @Assisted private val workerParams : WorkerParameters ,
3838 private val coreService : CoreService ,
39- private val lightningService : LightningService ,
39+ private val lightningRepo : LightningRepository ,
4040) : CoroutineWorker(appContext, workerParams) {
4141 private val self = this
4242
@@ -63,10 +63,8 @@ class WakeNodeWorker @AssistedInject constructor(
6363
6464 try {
6565 withPerformanceLogging {
66- // TODO: Only start node if it's not running or implement & use StateLocker
67- lightningService.setup(walletIndex = 0 )
68- lightningService.start(timeout) { event -> handleLdkEvent(event) }
69- lightningService.connectToTrustedPeers()
66+ lightningRepo.start(walletIndex = 0 , timeout= timeout) { event -> handleLdkEvent(event) }
67+ lightningRepo.connectToTrustedPeers()
7068
7169 // Once node is started, handle the manual channel opening if needed
7270 if (self.notificationType == orderPaymentConfirmed) {
@@ -136,7 +134,7 @@ class WakeNodeWorker @AssistedInject constructor(
136134 self.bestAttemptContent?.title = " Payment received"
137135 self.bestAttemptContent?.body = " Via new channel"
138136
139- lightningService.channels ?.find { it.channelId == event.channelId }?.let { channel ->
137+ lightningRepo.getChannels() ?.find { it.channelId == event.channelId }?.let { channel ->
140138 val sats = channel.outboundCapacityMsat / 1000u
141139 self.bestAttemptContent?.title = " Received ⚡ $sats sats"
142140 // Save for UI to pick up
@@ -185,7 +183,7 @@ class WakeNodeWorker @AssistedInject constructor(
185183 }
186184
187185 private suspend fun deliver () {
188- lightningService .stop()
186+ lightningRepo .stop()
189187
190188 bestAttemptContent?.run {
191189 pushNotification(title, body, context = appContext)
0 commit comments