Skip to content

feat: persist hardware activities - #1044

Open
ovitrif wants to merge 6 commits into
masterfrom
refactor/core-hww-activities-1029
Open

feat: persist hardware activities#1044
ovitrif wants to merge 6 commits into
masterfrom
refactor/core-hww-activities-1029

Conversation

@ovitrif

@ovitrif ovitrif commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Closes #1029
Refs #998

Description

This PR:

  1. Persists hardware-wallet watcher activities and Electrum transaction details in bitkit-core under the wallet ID already derived and stored by master.
  2. Uses the current bitkit-core activity model and the existing HwWalletId/KnownDevice identity path across watcher events, navigation, detail loading, tags, seen state, boost relationships, and deletion.
  3. Returns app and paired hardware-wallet activity through one sorted Core list while retaining wallet-scoped row identity, detail lookup, transaction lookup, tags, and UI keys.
  4. Reconciles each hardware watcher snapshot with Core, keeps live watcher state visible during persistence recovery, and emits received-transaction notifications after successful persistence.
  5. Preserves Transfer To Spending metadata on the hardware wallet activity so one blue Transfer / From Savings row represents the funding transaction.
  6. Deletes the removed device's Core activity scope and rebuilds that wallet's visible history from the watcher after re-pairing.

Preview

No visual redesign. Home, All Activity, Activity Detail, tag filtering, and Explore now render the wallet-scoped hardware activities supplied by bitkit-core.

QA Notes

Manual Tests

  • 1. Settings → Advanced → Dev Settings → Trezor → pair the Bridge emulator: Home shows the connected hardware wallet tile, balance, and blue hardware activities.
  • 2. Fund two hardware addresses with distinct amounts → mine a block → Home → Show All: both blue received rows appear once in the unified activity list.
  • 3. Blue hardware receive → Activity Detail → add a tag → back → reopen → Explore: the tag persists and Inputs plus Outputs contain the Electrum transaction details.
  • 4. All Activity → tag filter → select the hardware tag: the tagged blue row remains and untagged rows are absent.
  • 5. Hardware wallet → Transfer To Spending → 25% → Continue → Open Trezor Connect → approve Recipient, Amount, Locktime, and Summary → Continue Using Bitkit: Home shows exactly one new blue Transfer / From Savings row and its detail shows TO SPENDING.
  • 6. All Activity → switch Sent, Received, Other, and All: received hardware rows appear under Received, the hardware Transfer appears under Other, and All restores the combined list without a default-wallet duplicate.
  • 7. Settings → Hardware Wallets → remove the paired device → re-pair the same wallet: its scoped activity disappears on removal and rebuilds without duplicate rows after pairing.
  • 8. regression: app on-chain and LN activity → Activity Detail, tags, Explore, and wallet-specific lists: behavior matches master.

Automated Checks

  • Unit tests updated:
    • coverage active watcher ownership, Core snapshot persistence, persistence recovery, wallet removal, transfer metadata, and activity/transaction ID collisions across wallet scopes: HwWalletRepoTest.kt, ActivityRepoTest.kt, and TransferRepoTest.kt
    • coverage for scoped detail/tag calls, global unified listing, scoped navigation, hardware notification routing, and Transfer To Spending ownership: ActivityDetailViewModelTest.kt, ActivityListViewModelTest.kt, AppViewModelSendFlowTest.kt, and TransferViewModelTest.kt
    • retain default-wallet behavior with the scoped repository API: NotifyPaymentReceivedHandlerTest.kt and BoostTransactionViewModelTest.kt
  • Hardware-wallet journeys updated:
    • activity-blue-icons.xml and transfer-to-spending.xml; activity-detail-hw-tags.xml adds persisted tag and inputs/outputs coverage.
  • Functional verification:
    • Android 17 emulator and deterministic T2T1 Bridge emulator completed pairing, two confirmed hardware receives, persisted tags, tag filtering, Core inputs/outputs, all activity-tab assertions, four-step device signing, and one wallet-scoped pending transfer row.
  • Local checks:
    • just compile, just test, and just lint passed; all hardware-wallet journey XML files passed xmllint.

@greptile-apps

This comment has been minimized.

greptile-apps[bot]

This comment was marked as resolved.

@ovitrif ovitrif self-assigned this Jun 24, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@ovitrif
ovitrif marked this pull request as draft June 24, 2026 22:22
@ovitrif ovitrif changed the title feat: integrate hardware wallet activities with core refactor: use scoped hw activities Jun 24, 2026
@ovitrif ovitrif changed the title refactor: use scoped hw activities refactor: use core hw-scoped activities Jun 25, 2026
@ovitrif ovitrif changed the title refactor: use core hw-scoped activities refactor: use core hw activities Jun 25, 2026
@ovitrif

This comment was marked as outdated.

@ovitrif
ovitrif force-pushed the refactor/core-hww-activities-1029 branch 2 times, most recently from f3f9a2c to 435d9b0 Compare July 4, 2026 19:35
@ovitrif

This comment was marked as outdated.

@ovitrif

This comment was marked as outdated.

@piotr-iohk

This comment was marked as outdated.

@ovitrif

This comment was marked as outdated.

@ovitrif ovitrif added this to the 2.5.0 milestone Jul 6, 2026
@ovitrif

This comment was marked as outdated.

github-advanced-security[bot]

This comment was marked as resolved.

@ovitrif
ovitrif changed the base branch from master to feat/wallet-scoped-core-0.3.9 July 7, 2026 12:13
@ovitrif
ovitrif force-pushed the refactor/core-hww-activities-1029 branch from 708cd21 to 794722a Compare July 7, 2026 12:13
Base automatically changed from feat/wallet-scoped-core-0.3.9 to master July 9, 2026 08:53
@ovitrif
ovitrif force-pushed the refactor/core-hww-activities-1029 branch from ea9a252 to 5ae816a Compare July 9, 2026 20:35
@ovitrif

This comment was marked as outdated.

@ovitrif
ovitrif marked this pull request as ready for review July 9, 2026 20:39
Comment thread app/src/main/java/to/bitkit/models/ActivityWalletType.kt Outdated
@ovitrif

This comment was marked as outdated.

@ovitrif
ovitrif force-pushed the refactor/core-hww-activities-1029 branch from 0d7d218 to 15b80fa Compare July 14, 2026 15:50
@jvsena42

This comment was marked as outdated.

@jvsena42
jvsena42 marked this pull request as draft July 15, 2026 09:35
@ovitrif
ovitrif force-pushed the refactor/core-hww-activities-1029 branch from 15b80fa to b4bbc26 Compare July 22, 2026 18:30
@ovitrif ovitrif changed the title refactor: use core hw activities feat: persist hardware activities Jul 22, 2026
@ovitrif

ovitrif commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Indeed, most of these changes were already implemented

I rebuilt the branch from current master and retained the missing bitkit-core persistence and unified activity integration. The Trezor lifecycle, wallet identity, watcher APIs, and hardware-wallet foundation now come directly from master; the branch-local type and identity implementations are removed. The full repository checks and Bridge-backed hardware journeys pass on the reconstructed head.

Resolved in b4bbc26

@ovitrif
ovitrif marked this pull request as ready for review July 22, 2026 18:31
@synonymdev synonymdev deleted a comment from chatgpt-codex-connector Bot Jul 22, 2026
@ovitrif
ovitrif requested review from jvsena42 and piotr-iohk July 22, 2026 21:04
@piotr-iohk

Copy link
Copy Markdown
Collaborator

There are some conflicts that would be good to resolve before testing.

@ovitrif
ovitrif force-pushed the refactor/core-hww-activities-1029 branch from 29f2195 to 64cf108 Compare July 23, 2026 17:52
@ovitrif

ovitrif commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

There are some conflicts that would be good to resolve before testing.

I rebased this branch onto current origin/master (fe0ae42af), resolved the notification-handler test against the new presentation lifecycle, and reran just compile, just test, and just lint.

Resolved in 64cf108

@ovitrif
ovitrif removed the request for review from piotr-iohk July 27, 2026 14:19
Comment thread app/src/main/java/to/bitkit/repositories/HwWalletRepo.kt Outdated
Comment thread app/src/main/java/to/bitkit/repositories/HwWalletRepo.kt Outdated
Comment thread app/src/main/java/to/bitkit/services/CoreService.kt
Comment thread app/src/main/java/to/bitkit/repositories/HwWalletRepo.kt Outdated

@jvsena42 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review — wallet-scoped hardware activity

Reviewed the diff and ran the feature end-to-end on a Pixel 9 / Android 17 AVD with the deterministic T2T1 Bridge emulator (TREZOR_BRIDGE=true TREZOR_BRIDGE_URL=http://10.0.2.2:21325), against the staging regtest backend.

The design holds up. Verified working on device:

Check Result
Pairing → home tile, balance, blue rows
Two receives with distinct amounts (12 345 / 5 712) ✅ each rendered once
Same txid in both scopes (trezor:… Received + bitkit Sent) ✅ both rows, no collision
Tag on a hardware activity, persists across re-navigation activity_tags row written with wallet_id = trezor:8df6…
Explore → INPUT + OUTPUTS(2) ✅ 46 transaction_details rows persisted in the HW scope
Tag filter in All Activity ✅ only the tagged blue row survives
Sent / Received / Other / All tabs
Transfer To Spending (25% → 4 device approvals) ✅ exactly one blue Transfer / From Savings, detail shows TO SPENDING
Restart with device disconnected ✅ history + balance restored from Core, no duplicates (GROUP BY wallet_id, tx_id HAVING count>1 → empty)

Not exercised: device removal → re-pair (covered by unit tests), CJIT/boost paths.

One blocker, in TransferRepo.markActivityAsTransfer — the new search = txid lookup can never match, which silently kills transfer-marking for the default wallet as well as hardware. Details and evidence in the inline thread. Two 🟠 items (backup tag asymmetry, emit under mutex) are worth resolving before merge; the rest are follow-ups or nits.

Conventions are otherwise clean: the runSuspendCatching migration, the System.currentTimeMillis()nowTimestamp() swap, quoted log parameters, @Stable on ActivityDetailUiState, and extracting reconcileWatchers/toWatcherSpecs out of the nested collect are all improvements. Test coverage is genuinely good — the only visible gap maps exactly to the blocker.

Comment thread app/src/main/java/to/bitkit/repositories/TransferRepo.kt Outdated
Comment thread app/src/main/java/to/bitkit/repositories/ActivityRepo.kt
Comment thread app/src/main/java/to/bitkit/repositories/ActivityRepo.kt
Comment thread app/src/main/java/to/bitkit/repositories/ActivityRepo.kt Outdated
Comment thread app/src/main/java/to/bitkit/repositories/HwWalletRepo.kt Outdated
Comment thread app/src/main/java/to/bitkit/repositories/HwWalletRepo.kt Outdated
Comment thread app/src/main/java/to/bitkit/services/CoreService.kt
Comment thread app/src/main/java/to/bitkit/services/CoreService.kt Outdated
Comment thread app/src/main/java/to/bitkit/viewmodels/ActivityDetailViewModel.kt Outdated
Comment thread app/src/main/java/to/bitkit/viewmodels/ActivityDetailViewModel.kt Outdated
@ovitrif
ovitrif force-pushed the refactor/core-hww-activities-1029 branch from b8ef428 to e22a8d3 Compare July 30, 2026 14:50
@ovitrif
ovitrif requested a review from jvsena42 July 30, 2026 15:16
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.

Bitkit Core support for hardware wallet activities

4 participants