satd-events-client
Async Rust client SDK for the satd Streaming Consumption API (satd.events.v1).
It wraps the generated tonic client with a
typed event model, per-call auth metadata, cursor capture/persistence,
reconnect-with-backoff, Lagged auto-resume, replay-truncation detection, and a
privacy-preserving prefix-watch local re-filter — so a consumer writes against
StreamClient instead of hand-rolling channels, metadata, and protobuf
unwrapping.
- Typed events & watches —
Eventis a flat enum over the protooneof;WatchHandlehas a typed helper for every watch kind (scripts withmin_valuefloors, outpoints, txid lifecycle, depth alarms, descriptors, prefixes). - Durable firehose —
resilient_subscribereconnects with backoff and persists the resume cursor through aCursorStore, so a process restart resumes from the stored height;Laggedrecovers automatically and a server-side replay clamp surfaces as a syntheticEvent::ReplayGap. - Native TLS / mTLS —
tls()/tls_ca_pem()/tls_client_identity()/tls_domain()encrypt the transport (ring rustls provider) so a bearer token is never sent in cleartext. - No server-dependency leak — wire types live in the thin
satd-events-protocrate, so this SDK pulls none of thenode/RocksDB server stack.
Install
Pre-publish: this crate is not yet on crates.io. Depend on it via git until the published release lands:
[]
= { = "https://github.com/epochbtc/satd", = "master" }
Once published, cargo add satd-events-client.
To read the API docs before publication, generate them locally:
Quickstart
use ;
async
Over a plaintext http:// endpoint a bearer token travels in cleartext — enable
TLS (below), restrict bearer auth to loopback, or front the node with a
TLS-terminating proxy.
# use StreamClient;
# async
Feature flags
| Feature | Default | Effect |
|---|---|---|
bitcoin |
on | Typed bitcoin helpers + the PrefixWatcher prefix-watch re-filter (pulls bitcoin/secp256k1). |
tls |
on | Native TLS / mTLS via tonic's rustls integration (ring provider; no aws-lc-rs / C toolchain). |
For a minimal, plaintext-only build: default-features = false.
Examples
Runnable examples live in examples/ — firehose_tail,
resilient_tail, watch_outpoints, descriptor_wallet, lifecycle_alarms,
prefix_privacy, tls_tail, mtls_tail:
Stability & versioning
The crate version is the satd version it shipped with, and it follows semver. Use an SDK whose minor version is at or below your node's; newer nodes only add fields and event kinds within the same schema.
Each time a stream opens, the SDK compares the node's advertised version
(satd-version response header) with its own:
- same or newer node: silent;
- one minor version behind: a
tracingwarning (targetsatd_events_client::compat) once per node version, which means upgrade the node; - two or more minor versions, or a major version, behind:
StreamError::NodeTooOld, unless the client was built withallow_old_node(), which turns it into the warning; - a different event schema:
StreamError::SchemaMismatch, always.
A node older than 0.6.0 sends no header and counts as 0.5.
StreamClient::node_version() reports what the node advertised. The rule is
written down in
STABILITY_POLICY.md.
MSRV is 1.93 (an MSRV bump is a minor-version change).
More
- Operator Manual — Rust SDK chapter: https://epochbtc.github.io/satd/rust-sdk.html
- Wire / streaming spec:
docs/api/streaming.md
License
MIT — see LICENSE.