Skip to content

fix: migrate legacy backups missing wallet id on restore#1064

Merged
piotr-iohk merged 2 commits into
masterfrom
fix/backup-wallet-id-migration
Jul 9, 2026
Merged

fix: migrate legacy backups missing wallet id on restore#1064
piotr-iohk merged 2 commits into
masterfrom
fix/backup-wallet-id-migration

Conversation

@coreyphillips

Copy link
Copy Markdown
Contributor

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:

  • migrateBackupActivitiesJson
  • migrateBackupActivityTagsJson
  • migrateBackupPreActivityMetadataJson

Core 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: add migrateCoreOwnedBackupFields and apply it at the METADATA and ACTIVITY restore sites.
  • Bump bitkit-core to 0.4.0.

Notes

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-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds pre-decode migration for legacy Core backup data. The main changes are:

  • Migrates tagMetadata before metadata restore decoding.
  • Migrates activities and activityTags before activity restore decoding.
  • Adds a shared helper for patching Core-owned JSON array fields.
  • Bumps bitkit-core to 0.4.0 for the migration helpers.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The migrated fields match the current top-level backup payload shape.
  • The restore helper preserves the surrounding JSON object and only replaces array fields after migration output parses as JSON.

Important Files Changed

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

@piotr-iohk

Copy link
Copy Markdown
Collaborator

Build failure looks like a missing Maven artifact, not a code issue: Could not find com.synonym:bitkit-core-android:0.4.0.

bitkit-core Gradle Package for v0.4.0 is still running

Base automatically changed from feat/wallet-scoped-core-0.3.9 to master July 9, 2026 08:53

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

@piotr-iohk

Copy link
Copy Markdown
Collaborator

Merging, my latest push only resolves the libs.versions.toml conflict with master (paykit bump), with no further code changes.

@piotr-iohk piotr-iohk merged commit 6187a9f into master Jul 9, 2026
18 checks passed
@piotr-iohk piotr-iohk deleted the fix/backup-wallet-id-migration branch July 9, 2026 09:47
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.

2 participants