fix: migrate legacy backups missing wallet id on restore#1064
Merged
Conversation
Backups written before activity data became wallet-scoped have no wallet id on their activity, tag and pre-activity-metadata records. With bitkit-core 0.4.0 those records require a wallet id, so decoding such a backup fails before any repository migration can run. Before decoding a restored envelope, hand each Core-owned array to the matching bitkit-core migration helper (migrateBackupActivitiesJson, migrateBackupActivityTagsJson, migrateBackupPreActivityMetadataJson), which fills in the default wallet id for records that lack one and preserves any existing id. The app never edits Core model JSON itself, and current backups that already carry a wallet id are unaffected. Bumps bitkit-core to 0.4.0.
Greptile SummaryThis PR adds pre-decode migration for legacy Core backup data. The main changes are:
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| app/src/main/java/to/bitkit/repositories/BackupRepo.kt | Adds restore-time migration for Core-owned backup arrays before decoding metadata and activity payloads. |
| gradle/libs.versions.toml | Updates bitkit-core to 0.4.0 so the restore path can call the new migration helpers. |
Reviews (1): Last reviewed commit: "fix: migrate legacy backups missing wall..." | Re-trigger Greptile
This was referenced Jul 8, 2026
Collaborator
|
Build failure looks like a missing Maven artifact, not a code issue: bitkit-core Gradle Package for v0.4.0 is still running |
piotr-iohk
approved these changes
Jul 9, 2026
piotr-iohk
left a comment
Collaborator
There was a problem hiding this comment.
tACK
- In-place upgrade 2.3.1 → head : wallet state intact, Trezor pair + TO_SPENDING worked
- 2.3.1 VSS backup → wipe → restore on head: legacy wallet restored cleanly; logs show Full restore success, Restored 3 activities, 1 activity tags; balances/channel/order came back (on-chain + spending), Trezor pair + TO_SPENDING worked
- no issues in logs
Collaborator
|
Merging, my latest push only resolves the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #1062. Fixes the P1 raised by the Codex review there: legacy backups that predate wallet-scoped activity data fail to decode on restore because their activity, tag and pre-activity-metadata records have no wallet id, and with bitkit-core 0.4.0 those records require one. The decode throws before any repository migration can fill a default.
Approach
Before decoding a restored envelope, each Core-owned array (
activities,activityTags,tagMetadata) is handed to the matching bitkit-core migration helper as raw JSON:migrateBackupActivitiesJsonmigrateBackupActivityTagsJsonmigrateBackupPreActivityMetadataJsonCore fills in the default wallet id for records that lack one (or have it empty) and preserves any existing non-default id such as
trezor:{hash}. The app only extracts and reinserts the sub-arrays, so it never edits Core model JSON itself. The helpers are idempotent, so current backups that already carry a wallet id are unaffected.This is the app half of synonymdev/bitkit-core#113; the migration APIs it calls shipped in bitkit-core 0.4.0.
Changes
BackupRepo.kt: addmigrateCoreOwnedBackupFieldsand apply it at theMETADATAandACTIVITYrestore sites.Notes
feat/wallet-scoped-core-0.3.9(feat: bump core to 0.3.9 and hw reliability #1062), which introduces the wallet-scoped restore path this builds on. Retarget tomasteronce feat: bump core to 0.3.9 and hw reliability #1062 merges.