@@ -328,53 +328,6 @@ class WalletViewModel @Inject constructor(
328328 }
329329 }
330330
331- private suspend fun checkForOrphanedChannelMonitorRecovery () {
332- if (migrationService.isChannelRecoveryChecked()) return
333-
334- Logger .info(" Running one-time channel monitor recovery check" , context = TAG )
335-
336- val allMonitorsRetrieved = runCatching {
337- val allRetrieved = migrationService.fetchRNRemoteLdkData()
338- // don't overwrite channel manager, we only need the monitors for the sweep
339- val channelMigration = buildChannelMigrationIfAvailable()?.let {
340- ChannelDataMigration (channelManager = null , channelMonitors = it.channelMonitors)
341- }
342-
343- if (channelMigration == null ) {
344- Logger .info(" No channel monitors found on RN backup" , context = TAG )
345- return @runCatching allRetrieved
346- }
347-
348- Logger .info(
349- " Found ${channelMigration.channelMonitors.size} monitors on RN backup, attempting recovery" ,
350- context = TAG ,
351- )
352-
353- lightningRepo.stop().onFailure {
354- Logger .error(" Failed to stop node for channel recovery" , it, context = TAG )
355- }
356- delay(CHANNEL_RECOVERY_RESTART_DELAY_MS )
357- lightningRepo.start(channelMigration = channelMigration, shouldRetry = false )
358- .onSuccess {
359- migrationService.consumePendingChannelMigration()
360- walletRepo.syncNodeAndWallet()
361- walletRepo.syncBalances()
362- Logger .info(" Channel monitor recovery complete" , context = TAG )
363- }
364- .onFailure {
365- Logger .error(" Failed to restart node after channel recovery" , it, context = TAG )
366- }
367-
368- allRetrieved
369- }.getOrDefault(false )
370-
371- if (allMonitorsRetrieved) {
372- migrationService.markChannelRecoveryChecked()
373- } else {
374- Logger .warn(" Some monitors failed to download, will retry on next startup" , context = TAG )
375- }
376- }
377-
378331 fun stop () {
379332 if (! walletExists) return
380333
0 commit comments