feat: add onchain event listener#94
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1d78cb646
ℹ️ 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".
ben-kaufman
left a comment
There was a problem hiding this comment.
Found two watcher issues in the review.
ben-kaufman
left a comment
There was a problem hiding this comment.
Found one small lifecycle edge in the second pass.
ben-kaufman
left a comment
There was a problem hiding this comment.
One small perf note from the BDK/electrum-client pass.
ben-kaufman
left a comment
There was a problem hiding this comment.
One design question about keeping the watcher descriptor-first.
ben-kaufman
left a comment
There was a problem hiding this comment.
One retry pacing note from the follow-up review.
ben-kaufman
left a comment
There was a problem hiding this comment.
One startup semantics question from the architecture pass.
ben-kaufman
left a comment
There was a problem hiding this comment.
One tip-height edge case from the architecture pass.
ben-kaufman
left a comment
There was a problem hiding this comment.
One small subscription nit.
ben-kaufman
left a comment
There was a problem hiding this comment.
LGTM, would be good to update to more descriptor focus architecture as a follow up.
|
I'll bump the version and rebuild.
|
Adds an on-chain transaction watcher for extended public keys. A caller starts a watcher for an xpub and receives typed
WatcherEvents via anEventListenercallback.Description
EventListenertrait (#[uniffi::export(with_foreign)]) for receiving typed callbacks, implementable from Swift/Kotlin/Python.onchain_start_watcher,onchain_stop_watcher,onchain_stop_all_watchers.WatcherParamsrecord:watcher_id,extended_key,electrum_url, optionalnetwork/account_type(auto-detected from the key prefix when omitted), and optionalgap_limit(defaults to 20).WatcherEventenum:TransactionsChanged { transactions, balance, tx_count, block_height, account_type },Error { message },Disconnected { message },Reconnected.src/modules/onchain/listener.rs):blockchain.scripthash.subscribefor detection; a short-timeoutping()drains pushed notifications off the socket without a fixed poll interval.!Send) on one dedicatedstdthread per watcher rather than occupying a Tokio blocking-pool slot for the watcher's lifetime.Disconnectedevent and an exponential-backoff reconnect (capped at 60s) that emitsReconnected; a failed resync is retried so a popped notification is never dropped.watcher_id.WatcherErrorvariant onAccountInfoError.0.1.65.QA Notes
cargo checkandcargo testpass.TransactionsChangedevent arrives with the current balance/history.TransactionsChangedupdate within seconds.DisconnectedthenReconnectedevents, and state resyncs afterward.onchain_stop_watcher/onchain_stop_all_watcherstear the watcher(s) down cleanly.watcher_idreturns aWatcherError.