Skip to content

feat: add trezor onchain event watcher#976

Open
coreyphillips wants to merge 4 commits into
masterfrom
feat/onchain-event-watcher
Open

feat: add trezor onchain event watcher#976
coreyphillips wants to merge 4 commits into
masterfrom
feat/onchain-event-watcher

Conversation

@coreyphillips
Copy link
Copy Markdown
Contributor

@coreyphillips coreyphillips commented May 29, 2026

Adds an Event Watcher section to the (dev-only) Trezor screen that consumes the new bitkit-core on-chain xpub watcher. Enter or populate an extended key, start/stop a live watcher, and observe streaming balance, transactions, connection status, and an event log.

Depends on bitkit-core 0.1.65

Description

  • New WatcherSection composable: extended-key + gap-limit inputs, populate-from-xpub, start/stop controls, and a live view of balance, transactions, connection status, and an event log.
  • TrezorViewModel:
    • Collects WatcherEvents from the repo and maps them into a new TrezorWatcherState (balance, transactions, tx count, block height, account type, connection status, event log).
    • Generates a per-session watcherId, validates the xpub/gap-limit inputs, and surfaces errors via toasts.
    • Stops the active watcher in onCleared() so no watcher thread is leaked.
  • TrezorRepo: exposes a buffered watcherEvents SharedFlow bridged from a core EventListener, plus startWatcher / stopWatcher / stopAllWatchers returning Result<Unit>.
  • TrezorService: thin wrappers over onchainStartWatcher / onchainStopWatcher / onchainStopAllWatchers.
  • Bumped bitkit-core to 0.1.65 in libs.versions.toml.

QA Notes

  • Build resolves bitkit-core 0.1.65.
  • Dev Settings → Trezor → Event Watcher:
    • Populate from xpub (or paste an extended key), set a gap limit, and start the watcher; confirm status goes STARTING → CONNECTED and the initial balance/transactions populate.
    • Send a tx to the watched xpub and confirm the balance/tx list and event log update live.
    • Drop the network and confirm DISCONNECTED → CONNECTED transitions with a "Reconnected" log entry.
    • Stop the watcher and confirm state clears; leave/return to the screen and confirm no leaked watcher (stops on onCleared).
    • Invalid input (blank key, non-numeric gap limit) shows an error toast and does not start a watcher.
  • Tests run: ./gradlew compileDevDebugKotlin, ./gradlew testDevDebugUnitTest --tests TrezorViewModelTest --tests TrezorRepoTest, ./gradlew detekt — all pass.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4fd96a304

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread app/src/main/java/to/bitkit/ui/screens/trezor/TrezorViewModel.kt
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.

1 participant