stratum_apps/lib.rs
1//! # Stratum Apps - SV2 Application Utilities
2//!
3//! This crate consolidates the essential utilities needed for building Stratum V2 applications.
4//! It combines the functionality from the original separate utility crates into a single,
5//! well-organized library with feature-based compilation.
6//!
7//! ## Features
8//!
9//! ### Core Features
10//! - `network` - High-level networking utilities (enabled by default)
11//! - `fallback-coordinator` - Runtime fallback coordination helpers (enabled by default)
12//! - `config` - Configuration management helpers (enabled by default)
13//! - `payout` - Shared payout-mode parsing and coinbase-output distribution helpers
14//! - `monitoring` - HTTP and Prometheus monitoring helpers (optional)
15//! - `asic-rs-telemetry` - Optional miner telemetry helpers powered by `asic-rs`
16//! - `std` - Standard-library support for key and random utilities (enabled by default)
17//! - `core` - Re-export and enable `stratum-core`
18//! - `bitcoin-core-sv2` - Re-export and enable `bitcoin_core_sv2`
19//!
20//! ### Role-Specific Feature Bundles
21//! - `pool` - Everything needed for pool applications
22//! - `jd_client` - Everything needed for JD client applications
23//! - `jd_server` - Configuration helpers and Bitcoin Core IPC runtime APIs for JD server
24//! applications
25//! - `translator` - Everything needed for translator applications (includes SV1 and payout helpers)
26//! - `mining_device` - Configuration helpers for mining device applications
27//!
28//! ## Modules
29//!
30//! - [`network_helpers`] - High-level networking utilities for SV2 connections
31//! - [`config_helpers`] - Configuration management and parsing utilities
32//! - \[`payout`\] - Payout-mode parsing and coinbase-output construction/verification helpers
33
34/// Re-export all the modules from `stratum_core`
35#[cfg(feature = "core")]
36pub use stratum_core;
37
38/// Re-export all the modules from `bitcoin_core_sv2`
39#[cfg(feature = "bitcoin-core-sv2")]
40pub use bitcoin_core_sv2;
41
42/// Re-export `tokio_util`, for the [`tokio_util::sync::CancellationToken`] required by the
43/// networking helpers
44#[cfg(feature = "tokio-util")]
45pub use tokio_util;
46
47/// High-level networking utilities for SV2 connections
48///
49/// Provides connection management, encrypted streams, and protocol handling.
50/// Originally from the `network_helpers_sv2` crate.
51#[cfg(feature = "network")]
52pub mod network_helpers;
53
54/// Configuration management helpers
55///
56/// Utilities for parsing configuration files, handling coinbase outputs,
57/// and setting up logging. Originally from the `config_helpers_sv2` crate.
58#[cfg(feature = "config")]
59pub mod config_helpers;
60
61/// Key utilities for cryptographic operations
62///
63/// Provides Secp256k1 key management, serialization/deserialization, and signature services.
64/// Supports both standard and no_std environments.
65pub mod key_utils;
66
67/// Utility methods used in apps.
68pub mod utils;
69
70/// Channel monitoring - expose channel data via HTTP JSON APIs
71#[cfg(feature = "monitoring")]
72pub mod monitoring;
73
74// Task orchestrator used in SRI apps.
75pub mod task_manager;
76/// Template provider type
77///
78/// Provides the type of template provider that will be used.
79pub mod tp_type;
80
81/// Creates a CoinbaseOutputConstraints message from a list of coinbase outputs
82pub mod coinbase_output_constraints;
83
84/// Shared payout-mode parsing and coinbase-output distribution helpers.
85#[cfg(feature = "payout")]
86pub mod payout;
87
88/// Fallback coordinator
89#[cfg(feature = "fallback-coordinator")]
90pub mod fallback_coordinator;
91
92/// Share synchronous primitives
93pub mod sync;
94
95/// Shared async channel cleanup helpers.
96pub mod channel_utils;