Skip to content

Conversation

@ovitrif
Copy link
Collaborator

@ovitrif ovitrif commented Oct 31, 2025

Roadmap: Backup & Restore

Description

This PR implements the remaining wallet (meta) data backups, namely the backup categories:

  • connections (just ui model representing the real-time status of ldk-node's backup timestamp)
  • blocktank (connection receipts)
  • activity (transaction log)
  • wallet (boosts & transfers)
  • metadata (tags)

It also comments out SLASHTAGS/contacts backup category to reflect its out-of-scope status for v1 release.

Aside

This PR also refactors bip21 state management, mainly to make the code easier to reason about and to make intentions more explicit in the code, most notable changes:

  • don't reset bip21 details (amount, description) on ChannelReady & ChannelClosed events, instead only mutate bolt11 as needed:
    • on ChannelReady add bolt11 if transitioning from cannot-receive → can-receive
    • on ChannelClosed remove bolt11 if transitioning from can-receive → cannot-receive
  • refactor refreshBip21 and call it only when the intention is to run all its operations
  • on PaymentReceived only refreshAddressIfNeeded and updateBip21Url, do not reset amount or description.

Note

Restoring blocktank data (orders, cjits, info) is handled in PR: #45.

Preview

QA Notes

2 Tests:

  • backup Test by doing different activities in the app related to the different backup categories
    • verify logs for entries covering each category like: Backup starting for: 'ACTIVITY', etc
  • restore Test doing a transfer to savings (don't mine), reset & restore wallet
    • verify in logs there is an entry for each category like: Restore success for: 'ACTIVITY' - BackupRepo, etc
    • expect savings balance to show the incoming transfer from the transfer-to-savings done before the reset & restore.

@jvsena42 jvsena42 requested a review from Copilot October 31, 2025 16:38
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 implements the remaining wallet data backup categories to complete the backup system for v1. The main purpose is to back up all wallet metadata and activity data to enable full wallet restoration from the cloud.

  • Implements 4 new backup categories: WALLET, METADATA, BLOCKTANK, ACTIVITY, and LIGHTNING_CONNECTIONS (display-only)
  • Renames LDK_ACTIVITY to ACTIVITY and comments out SLASHTAGS/contacts for v1 scope
  • Uses JSON serialization with versioned payloads for maintainability and cross-version compatibility

Reviewed Changes

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

Show a summary per file
File Description
app/src/main/java/to/bitkit/models/BackupPayloads.kt New versioned payload data classes for serialization
app/src/main/java/to/bitkit/repositories/BackupRepo.kt Core backup/restore implementation for all categories with change detection
app/src/main/java/to/bitkit/repositories/ActivityRepo.kt Adds activity change notifications and upsert functionality
app/src/main/java/to/bitkit/models/BackupStatus.kt Updates backup category enum, comments out SLASHTAGS
app/src/main/java/to/bitkit/viewmodels/BackupsViewModel.kt Disables manual retry on from LIGHTNING_CONNECTIONS instead of ACTIVITY
app/src/main/java/to/bitkit/services/CoreService.kt Adds upsert method to ActivityService
app/src/main/java/to/bitkit/data/dao/TransferDao.kt Adds getAll() and observeAll() methods for backup
app/src/main/java/to/bitkit/data/dao/TagMetadataDao.kt Adds observeAll() method for change detection
app/src/main/java/to/bitkit/data/entities/TagMetadataEntity.kt Adds @serializable annotation
Minor files Test updates, formatting fixes, and documentation improvements

@ovitrif ovitrif force-pushed the feat/backup-categories branch from 81de443 to a8658c7 Compare October 31, 2025 16:59
@ovitrif ovitrif self-assigned this Nov 3, 2025
@ovitrif ovitrif requested a review from jvsena42 November 3, 2025 21:31
@ovitrif ovitrif enabled auto-merge November 3, 2025 22:13
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.

Very nice work!

Could considerr using IODispather on BackupRepository because of the network calls, DB reading and the amount of jobs (7 data listeners + 6 status observers)

@ovitrif ovitrif merged commit 94abebd into master Nov 5, 2025
18 of 19 checks passed
@ovitrif ovitrif deleted the feat/backup-categories branch November 5, 2025 11:43
@ovitrif
Copy link
Collaborator Author

ovitrif commented Nov 5, 2025

Very nice work!

Could considerr using IODispather on BackupRepository because of the network calls, DB reading and the amount of jobs (7 data listeners + 6 status observers)

Thank you sir 🙌🏻

Optimizing by using IODispatcher where applicable is also on my mind ever since our discussions yesterday, planning to do it in a new PR 🙏🏻

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