Skip to content

Conversation

@ovitrif
Copy link
Collaborator

@ovitrif ovitrif commented Nov 3, 2025

Completes Roadmap item: Backup & Restore

Description

This PR:

  • Implements blocktank state (info, orders, cjit entries) restore from backups and refactors all restore operations using lists to make use of bulk upsert APIs which are faster and more convenient.
  • Adds support to backup & restore closed channels from bitkit-core's activity db once the feature will be implemented to actually track those.
  • Implements correct latest backup time text on the last sheet in the backup flow.

Preview

I didn't include preview for test 1️⃣ because it takes 2 to 4 minutes to wait, but it worked for me successfully as described under 'QA Notes'.

lastBackupTime.mp4

QA Notes

1️⃣ Test restore BT state from backup

  • transfer to spending → on progress screen tap "Continue Using Bitkit" quickly
  • wipe & restore app
  • mine 1 block using slack bot /regtest mine
  • wait 2 minutes, ie. wait for logcat line: "Refreshing blocktank orders…"
  • expect paid order is recognized by app & app resumes the mechanism to open channel for it
  • expect channel opens shortly thereafter

2️⃣ Test last backup time

  • Settings > Back up… > Back up your wallet
  • Complete flow till last sheet
  • Note value for "Last backup time…"
  • Back home
  • Drawer > App Status
  • expect same value for "Latest Full Data Backup"

@ovitrif ovitrif changed the title feat: restore bitkit core data and use bulk upsert feat: restore activities and use bulk upsert Nov 3, 2025
@ovitrif ovitrif self-assigned this Nov 3, 2025
@ovitrif ovitrif changed the base branch from master to feat/backup-categories November 3, 2025 22:44
@ovitrif ovitrif changed the title feat: restore activities and use bulk upsert feat: restore blocktank state and use bulk upsert Nov 3, 2025
@ovitrif ovitrif changed the title feat: restore blocktank state and use bulk upsert feat: restore blocktank state and use bulk upsert apis Nov 3, 2025
@ovitrif ovitrif changed the title feat: restore blocktank state and use bulk upsert apis feat: restore lsp data and use bulk upsert apis Nov 3, 2025
@ovitrif ovitrif changed the title feat: restore lsp data and use bulk upsert apis feat: restore LSP data and use bulk upsert apis Nov 3, 2025
@ovitrif ovitrif changed the title feat: restore LSP data and use bulk upsert apis feat: restore LSP data and use bulk upsert APIs Nov 3, 2025
@ovitrif ovitrif marked this pull request as ready for review November 4, 2025 16:42
@ovitrif ovitrif requested review from Copilot and jvsena42 November 4, 2025 16:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the bitkit-core-android dependency to version 0.1.22 and adds support for closed channels in backup/restore operations. The changes improve error handling consistency and add missing data structures.

Key changes:

  • Upgraded bitkit-core-android from 0.1.18 to 0.1.22
  • Added closed channels support to activity backup/restore flow
  • Improved error logging consistency in TransferViewModel
  • Added backup state management to BackupNavSheetViewModel with proper health check integration

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
gradle/libs.versions.toml Upgrades bitkit-core-android dependency to 0.1.22
app/src/main/java/to/bitkit/viewmodels/TransferViewModel.kt Refactors error logging to use consistent pattern with .also
app/src/main/java/to/bitkit/ui/settings/backups/MetadataScreen.kt Adds null safety for lastBackupTimeMs and error handling with fallback display
app/src/main/java/to/bitkit/ui/settings/backups/BackupNavSheetViewModel.kt Implements backup state collection from HealthRepo and CacheStore
app/src/main/java/to/bitkit/ui/screens/wallets/activity/utils/PreviewItems.kt Adds boostTxIds field to preview items
app/src/main/java/to/bitkit/ui/screens/wallets/activity/components/ActivityIcon.kt Adds boostTxIds field to preview items
app/src/main/java/to/bitkit/ui/screens/wallets/activity/ActivityExploreScreen.kt Adds boostTxIds field to preview items
app/src/main/java/to/bitkit/ui/screens/wallets/activity/ActivityDetailScreen.kt Adds boostTxIds field to preview items
app/src/main/java/to/bitkit/services/CoreService.kt Adds closed channel methods, batch operations, and removes Random.Default usage
app/src/main/java/to/bitkit/repositories/BlocktankRepo.kt Adds restoreFromBackup method for Blocktank data restoration
app/src/main/java/to/bitkit/repositories/BackupRepo.kt Refactors restore operations to use batch methods and handle closed channels
app/src/main/java/to/bitkit/repositories/ActivityRepo.kt Adds closed channels support and restoreFromBackup method
app/src/main/java/to/bitkit/models/BackupPayloads.kt Adds closedChannels field to ActivityBackupV1
app/src/main/java/to/bitkit/data/dao/TransferDao.kt Adds batch upsert method for transfers
app/src/main/java/to/bitkit/data/dao/TagMetadataDao.kt Adds batch upsert method for tag metadata
Comments suppressed due to low confidence (2)

app/src/main/java/to/bitkit/repositories/BackupRepo.kt:411

  • The Logger.debug call is missing the context parameter. It should include context = TAG for consistency with other logging statements in this file and to follow the project's logging pattern.
                Logger.debug("Restored caches and ${parsed.tagMetadata.size} tags metadata records", TAG)

app/src/main/java/to/bitkit/repositories/BackupRepo.kt:416

  • The Logger.debug call is passing TAG as the second positional parameter instead of using the named context parameter. It should be Logger.debug(\"...\", context = TAG) for consistency with the project's logging pattern.
                    Logger.debug("Restored ${parsed.orders.size} orders, ${parsed.cjitEntries.size} CJITs", TAG)

Base automatically changed from feat/backup-categories to master November 5, 2025 11:43
@ovitrif ovitrif removed the request for review from jvsena42 November 5, 2025 13:33
@ovitrif ovitrif enabled auto-merge November 5, 2025 13:58
@ovitrif ovitrif requested a review from jvsena42 November 5, 2025 14:51
Copy link
Member

@jvsena42 jvsena42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced test suggestions on emulator

@ovitrif ovitrif merged commit 8de3bf4 into master Nov 5, 2025
11 checks passed
@ovitrif ovitrif deleted the feat/backup-bulk-upserts branch November 5, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants