Expand description
Opt-in Monero/Wownero mining library for application monetization.
Embeds background Monero or Wownero mining into any Rust application. Supports both solo mining (direct to a daemon’s RPC) and pool mining (via Stratum protocol), with automatic failover across a list of sources.
§Features
By default, this library mines Monero (via RandomX). Enable the
wownero feature to mine Wownero (via RandomWOW) instead.
§Quick start
Set MONERO_WALLET/MONERO_SOURCES (or WOWNERO_WALLET/WOWNERO_SOURCES)
at compile time, then:
ⓘ
let mut miner = opt_in_miner::mining_state!("my-app");
miner.start();§Builder API
For full control, use Miner::builder directly:
use opt_in_miner::{ConsentReply, Miner, Source, ConsentStatus, Persistence};
let mut miner = Miner::builder()
.wallet("your-monero-wallet-address")
.sources(&[
Source::node("node.moneroworld.com:18089"),
Source::pool("pool.hashvault.pro:3333"),
])
.cpu_fraction(0.25)
.consent_check(|| ConsentReply {
consent: ConsentStatus::Granted,
persistence: Persistence::Save,
})
.build();
miner.start();
// Mining runs in background threads. No-op if consent was denied.
miner.stop();Modules§
- compile_
env - Compile-time environment variables captured by the build script.
Macros§
- mining_
state - Creates a
MiningStatefrom compile-time environment variables.
Structs§
- Consent
Reply - The result of a consent check callback.
- Miner
- A background Monero miner with runtime-adjustable settings.
- Miner
Builder - Builder for configuring a
Minerinstance. - Mining
State - High-level wrapper around
Minerthat handles the common case of compile-time wallet/sources configuration via environment variables andOption<Miner>management. - Settings
- Persisted mining settings (consent, persistence mode, CPU usage, thread count).
- Throttle
- Thread-safe, runtime-adjustable CPU throttle for mining threads.
Enums§
- Consent
Status - Whether the user has granted or denied mining permission.
- Persistence
- Whether to persist mining settings across sessions.
- Source
- A mining source – either a Monero node (solo mining) or a pool (Stratum).
- Toggle
Result - Result of
MiningState::toggle.