Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build demand-cli binaries for Linux and macOS
name: Build demand-cli binaries

on:
push:
Expand Down
91 changes: 67 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 4 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "demand-cli"
version = "0.1.5"
version = "0.1.6"
edition = "2021"

[dependencies]
Expand All @@ -18,29 +18,12 @@ tracing-subscriber = { version = "*", features = ["env-filter"]}
tokio = {version="^1.36.0",features = ["full","tracing", "macros","rt-multi-thread"]}
key-utils = "1.0.0"
pid = { version = "4.0.0"}
clap = {version = "4.5.31", features = ["derive"]}
axum = {version = "0.8.1"}
clap = { version = "4.5.31", features = ["derive"]}
axum = { version = "0.8.1"}
serde = { version = "1.0.219", features = ["derive"] }
sysinfo = {version = "0.33.1"}
primitive-types = { version = "0.13.1" }
#roles_logic_sv2 = "1.2.1"
#sv1_api = "1.0.1"
#demand-sv2-connection = "0.0.3"
#framing_sv2 = "^2.0.0"
#binary_sv2 = "1.1.0"
#demand-share-accounting-ext = "0.0.10"

#noise_sv2 = "1.1.0"
#codec_sv2 = { version = "1.2.1", features = ["noise_sv2","with_buffer_pool"]}

#demand-share-accounting-ext = {path = "../demand-share-accounting-ext"}
#demand-sv2-connection = { path = "../demand-sv2-connection"}
#roles_logic_sv2 = { path = "../stratum/protocols/v2/roles-logic-sv2"}
#framing_sv2 = { path = "../stratum/protocols/v2/framing-sv2"}
#binary_sv2 = { path = "../stratum/protocols/v2/binary-sv2/binary-sv2"}
#noise_sv2 = {path ="../stratum/protocols/v2/noise-sv2"}
#codec_sv2 = {features = ["noise_sv2","with_buffer_pool"], path = "../stratum/protocols/v2/codec-sv2" }
#sv1_api = {path = "../stratum/protocols/v1" }
toml = { version = "0.8" }

demand-share-accounting-ext = { git = "https://github.com/demand-open-source/share-accounting-ext"}
demand-sv2-connection = {git = "https://github.com/demand-open-source/demand-sv2-connection"}
Expand All @@ -52,9 +35,6 @@ codec_sv2 = { git = "https://github.com/demand-open-source/stratum", branch="Imp
sv1_api = { git = "https://github.com/demand-open-source/stratum", branch = "ImproveCoinbase",subdirectory = "protocols/v1"}





[dev-dependencies]
rand = "0.8.5"
sha2 = "0.10.8"
Expand Down
46 changes: 41 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
[![Forks](https://img.shields.io/github/forks/demand-open-source/demand-cli?style=social)](https://github.com/demand-open-source/demand-cli)
![Release](https://img.shields.io/github/v/release/demand-open-source/demand-cli)

**Demand CLI** is a proxy that let miners to connect to and mine with [Demand Pool](https://dmnd.work). It serves two primary purposes:
**Demand CLI** is a proxy that let miners to connect to and mine with [Demand Pool](https://dmnd.work). It serves three primary purposes:
1. Translation: Enables miners using StratumV1 to connect to the Demand Pool without requiring firmware updates. Sv1 messages gets translated to Sv2.
2. Job Declaration (JD): Allows miners to declare custom jobs to the pool using StratumV2.
3. Solo Mining: Skip pool entirely and mine solo


## Features
- **Stratum V2 Support**: Uses the secure and efficient Stratum V2 protocol for communication with the pool.
- **Job Declaration**: Enables miners to propose custom block templates to the pool. This helps make mining more decentralized by allowing miners to pick the transactions they want to include in a block.
- **Stratum V1 Translation**: Acts as a bridge, allowing StratumV1 miners to connect to the Demand Pool without firmware updates.
- **Solo Mining Mode**: Allows miners to mine independently without a pool.
- **Flexible Configuration**: Provides options for customization. This allows users to optimize the tool for their specific mining environment.
- **Monitoring API**: Provides HTTP endpoints to monitor proxy health, pool connectivity, miner performace, and system resource usage in real-time.

Expand Down Expand Up @@ -64,18 +66,32 @@ Before running the CLI, set up the necessary environment variables.
```
Note: if `TP_ADDRESS` id not set, job declaration is disabled, and the proxy uses templates provided by the pool.

### Config File (for Solo Mining)
Create config.toml with payout address, network and withhold.
Example config file:
```toml
payout_address = "bc1qn2ckg6c2329e3g7w8sqlwqrg7f0hgcrv2fp2hv"
withhold = false
network = "bitcoin"
```
- payout_address: Bitcoin address for coinbase output (where your reward will be sent)
- withhold: specifies whether or not to withhold mining rewards (default: false).
- network <NETWORK>: Bitcoin network (bitcoin, testnet, regtest, signet; default: bitcoin)

These can also be passed as CLI args. Supported script types include P2PKH, P2SH, P2WPKH, P2WSH, and P2TR

## Running the CLI

Depending on whether you built from source or downloaded a binary, the command to run the proxy is slightly different. There are also different options you can use.
Below are two example setups to get you started.
Below are 3 example setups to get you started.

#### Example 1: Built from Source with Job Declaration

This example assumes you’ve built `demand-cli` from source and want to enable job declaration.

```bash
export TOKEN=abc123xyz
export TP_ADDRESS=192.168.1.100:8442
export TP_ADDRESS=127.0.0.1:8442
./target/release/demand-cli -d 100T --loglevel debug --nc on
```

Expand All @@ -92,20 +108,31 @@ Set Environment Variable:

Point your Stratum V1 miners to <your_proxy_ip>:32767.

#### Example 3: Solo Mining (No Pool, No TOKEN)
```bash
export TP_ADDRESS=127.0.0.1:8442
./demand-cli-linux-x64 --solo --payout_address bc1qn2ckg6c2329e3g7w8sqlwqrg7f0hgcrv2fp2hv --network bitcoin
```
This runs in solo mode, you can specify the payout_address and network in `toml` file as pass its path with `-c path/to/config.toml`. if `config.toml` is the directory as your binary `-c` is not required. Ensure Bitcoin node is running.

Point your Stratum V1 miners to <your_proxy_ip>:32767

### Options

- **`--test`**: Connects to test endpoint
- **`-d`**: Expected downstream hashrate (e.g., `10T`, `2.5P`, `5E`). Default is `100TH/s` (100 Terahashes/second).
This helps the pool adjust to your hashrate.
- **`--loglevel`**: Logging verbosity (`info`, `debug`, `error`, `warn`). Default is `info`.
- **`--nc`**: Noise connection logging verbosity (`info`, `debug`, `error`, `warn`). Default is `off`.
- **`--solo`**: Enable solo mining mode. Requires `TP_ADDRESS` and a config file.
- **`-c, --config`**: Path to your solo mining config.toml. Default is config.toml


## Monitoring API:

The proxy exposes REST API enspoints to monitor its health, pool connectivity, connected mining devices performance and system resource usage. All endpoints are served on `http://0.0.0.0:3001` and return JSON responses in the format:
The proxy exposes REST API enspoints to monitor its health, pool connectivity, connected mining devices performance and system resource usage. All endpoints are served on `http://0.0.0.0:3001` by default and return JSON responses in the format:

```json
```
{
"success": boolean,
"message": string | null,
Expand Down Expand Up @@ -156,6 +183,15 @@ Point your Stratum V1 miners to <your_proxy_ip>:32767.
}
}
```
- **200 OK** (Solo mining):
```json
{
"success": true,
"data": {
"pool": "Not connected to pool. Mining solo :)",
}
}
```
- **400 NOT_FOUND** (Not connected to Pool):
```json
{ "success": true, "data": { "address": null, "latency": null } }
Expand Down
3 changes: 3 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
payout_address="bc1qn2ckg6c2329e3g7w8sqlwqrg7f0hgcrv2fp2hv"
network="bitcoin"
withhold=false
Loading