Skip to content

Commit e1b205c

Browse files
committed
Merge hiveos-integration: HiveOS, MinerStat, RaveOS deploy templates
2 parents 407a53e + 5bc6892 commit e1b205c

9 files changed

Lines changed: 446 additions & 0 deletions

File tree

deploy/DEPLOY.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# c2pool Deployment — Mining OS Integration
2+
3+
Integration templates for HiveOS, MinerStat, and RaveOS.
4+
5+
c2pool is a **pool node**, not a standalone miner. It connects to a local Litecoin Core daemon and exposes a Stratum port for miners. The mining OS templates configure c2pool to talk to your litecoind.
6+
7+
## Prerequisites
8+
9+
On every machine running c2pool:
10+
- Litecoin Core (`litecoind`) running and synced
11+
- c2pool binary (build from source or download release)
12+
- For merged mining: Dogecoin Core (`dogecoind`) running
13+
14+
## HiveOS
15+
16+
### Quick Setup
17+
18+
1. Build c2pool and package it:
19+
```bash
20+
cd c2pool && mkdir build && cd build
21+
conan install .. --build=missing --settings=build_type=Release
22+
cmake .. --preset conan-release && cmake --build . --target c2pool -j$(nproc)
23+
24+
# Package for HiveOS
25+
mkdir -p /tmp/c2pool-pkg/c2pool
26+
cp src/c2pool/c2pool /tmp/c2pool-pkg/c2pool/
27+
cp ../deploy/hiveos/h-manifest.conf /tmp/c2pool-pkg/c2pool/
28+
cp ../deploy/hiveos/h-run.sh /tmp/c2pool-pkg/c2pool/
29+
cp ../deploy/hiveos/h-stats.sh /tmp/c2pool-pkg/c2pool/
30+
cp ../deploy/hiveos/h-config.sh /tmp/c2pool-pkg/c2pool/
31+
chmod +x /tmp/c2pool-pkg/c2pool/{h-run.sh,h-stats.sh,h-config.sh,c2pool}
32+
cd /tmp/c2pool-pkg && tar czf c2pool-1.0.0.tar.gz c2pool/
33+
```
34+
35+
2. Upload `c2pool-1.0.0.tar.gz` to a URL accessible from your HiveOS rigs.
36+
37+
3. Create a Flight Sheet:
38+
- **Miner**: Custom
39+
- **Installation URL**: `https://your-server/c2pool-1.0.0.tar.gz`
40+
- **Hash algorithm**: (leave blank)
41+
- **Wallet and worker template**: Your LTC address (e.g., `ltc1q...`)
42+
- **Pool URL**: litecoind RPC address (e.g., `127.0.0.1:9332`)
43+
- **Pass**: litecoind RPC credentials as `user:password`
44+
- **Extra config arguments** (optional):
45+
```
46+
--merged DOGE:98:127.0.0.1:44556:dogerpc:dogepass --fee 1.0
47+
```
48+
49+
### Flight Sheet Fields
50+
51+
| Field | Value | Example |
52+
|-------|-------|---------|
53+
| Pool URL | `litecoind_host:rpc_port` | `127.0.0.1:9332` |
54+
| Wallet | LTC payout address | `ltc1qkek8r3uymzqyajzezqgl99d2f948st5v67a5h3` |
55+
| Password | `rpc_user:rpc_password` | `litecoinrpc:mypassword` |
56+
| Extra config | Additional c2pool CLI flags | `--merged DOGE:98:...` |
57+
58+
### Merged Mining (LTC+DOGE)
59+
60+
Add to **Extra config arguments**:
61+
```
62+
--merged DOGE:98:DOGE_RPC_HOST:DOGE_RPC_PORT:DOGE_RPC_USER:DOGE_RPC_PASS
63+
```
64+
65+
Example:
66+
```
67+
--merged DOGE:98:127.0.0.1:44556:dogerpc:dogepass
68+
```
69+
70+
### Monitoring
71+
72+
HiveOS dashboard shows:
73+
- Total hashrate (kH/s)
74+
- Accepted/rejected shares
75+
- Pool efficiency
76+
- Per-worker hashrate breakdown
77+
78+
Stats are scraped from c2pool's REST API on port 8080.
79+
80+
## MinerStat
81+
82+
### Setup
83+
84+
1. In MinerStat dashboard, add a **Custom Miner**.
85+
2. Upload the c2pool binary.
86+
3. Set the launch script to `deploy/minerstat/minerstat-config.sh`.
87+
4. Configure pool settings:
88+
89+
| Field | Value |
90+
|-------|-------|
91+
| Pool Host | `127.0.0.1` |
92+
| Pool Port | `9332` |
93+
| Wallet | Your LTC address |
94+
| Password | `rpc_user:rpc_password` |
95+
| Algorithm | `scrypt` |
96+
| Extra params | `--merged DOGE:98:...` (optional) |
97+
98+
## RaveOS
99+
100+
### Setup
101+
102+
1. Package c2pool for RaveOS:
103+
```bash
104+
mkdir -p /tmp/c2pool-raveos/RAVINOS
105+
cp c2pool /tmp/c2pool-raveos/
106+
cp deploy/raveos/manifest.json /tmp/c2pool-raveos/RAVINOS/
107+
cp deploy/raveos/start.sh /tmp/c2pool-raveos/RAVINOS/
108+
cp deploy/raveos/stats.sh /tmp/c2pool-raveos/RAVINOS/
109+
chmod +x /tmp/c2pool-raveos/RAVINOS/{start.sh,stats.sh} /tmp/c2pool-raveos/c2pool
110+
cd /tmp && zip -r c2pool-1.0.0.zip c2pool-raveos/
111+
```
112+
113+
2. Upload to RaveOS Custom Miner Manager.
114+
3. Configure pool settings same as HiveOS (host, port, wallet, password).
115+
116+
## Stratum Miner Configuration
117+
118+
Miners (ASICs, GPU rigs) connect to c2pool's Stratum port:
119+
120+
```
121+
stratum+tcp://C2POOL_HOST:9327
122+
```
123+
124+
### Worker Name Formats
125+
126+
| Format | Example | Description |
127+
|--------|---------|-------------|
128+
| `LTC_ADDR` | `ltc1q...` | LTC payout only |
129+
| `LTC_ADDR,DOGE_ADDR` | `ltc1q...,D...` | LTC + DOGE merged |
130+
| `LTC_ADDR\|DOGE_ADDR` | `ltc1q...\|D...` | Pipe separator (Vnish) |
131+
| `LTC_ADDR.worker` | `ltc1q....rig1` | With worker name |
132+
| `LTC_ADDR+1024` | `ltc1q...+1024` | Fixed difficulty |
133+
134+
### Ports
135+
136+
| Port | Protocol | Purpose |
137+
|------|----------|---------|
138+
| 9327 | Stratum (TCP) | Miner connections |
139+
| 8080 | HTTP (REST) | Dashboard + API |
140+
| 9326 | P2P (TCP) | Sharechain network |

deploy/hiveos/h-config.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
# HiveOS config generator for c2pool
3+
#
4+
# Flight sheet fields mapping:
5+
# CUSTOM_URL → litecoind RPC address (host:port), e.g. "127.0.0.1:9332"
6+
# CUSTOM_TEMPLATE → payout address(es), e.g. "LTC_ADDR" or "LTC_ADDR,DOGE_ADDR"
7+
# CUSTOM_PASS → litecoind RPC credentials as "user:password"
8+
# CUSTOM_USER_CONFIG → extra c2pool flags (optional)
9+
#
10+
# Example flight sheet:
11+
# Pool URL: 127.0.0.1:9332
12+
# Wallet: tltc1qkek8r3uymzqyajzezqgl99d2f948st5v67a5h3
13+
# Password: litecoinrpc:myrpcpassword
14+
# Extra config: --merged DOGE:98:127.0.0.1:44556:dogerpc:dogepass
15+
16+
[[ -z $CUSTOM_URL ]] && echo "ERROR: Pool URL (litecoind RPC host:port) not set" && exit 1
17+
[[ -z $CUSTOM_TEMPLATE ]] && echo "ERROR: Wallet address not set" && exit 1
18+
19+
# Parse RPC host:port from CUSTOM_URL
20+
# Strip protocol prefix if present
21+
RPC_URL="${CUSTOM_URL#stratum+tcp://}"
22+
RPC_URL="${RPC_URL#http://}"
23+
RPC_URL="${RPC_URL#https://}"
24+
25+
RPC_HOST="${RPC_URL%%:*}"
26+
RPC_PORT="${RPC_URL##*:}"
27+
[[ "$RPC_HOST" == "$RPC_PORT" ]] && RPC_PORT="9332" # default if no port
28+
29+
# Parse RPC user:password from CUSTOM_PASS
30+
RPC_USER="${CUSTOM_PASS%%:*}"
31+
RPC_PASSWORD="${CUSTOM_PASS#*:}"
32+
[[ -z "$RPC_USER" ]] && RPC_USER="litecoinrpc"
33+
[[ "$RPC_USER" == "$RPC_PASSWORD" ]] && RPC_PASSWORD=""
34+
35+
# Build c2pool command line
36+
CONF="--integrated --net litecoin"
37+
CONF+=" --coind-address $RPC_HOST --coind-rpc-port $RPC_PORT"
38+
CONF+=" --address $CUSTOM_TEMPLATE"
39+
CONF+=" --web-port $MINER_API_PORT"
40+
41+
[[ -n "$RPC_USER" ]] && CONF+=" --rpcuser $RPC_USER"
42+
[[ -n "$RPC_PASSWORD" ]] && CONF+=" --rpcpassword $RPC_PASSWORD"
43+
44+
# Log to HiveOS standard location
45+
[[ -n "$CUSTOM_LOG_BASENAME" ]] && CONF+=" --log-file ${CUSTOM_LOG_BASENAME}.log"
46+
47+
# Append any extra user-supplied flags
48+
[[ -n "$CUSTOM_USER_CONFIG" ]] && CONF+=" $CUSTOM_USER_CONFIG"
49+
50+
echo "$CONF" > "$MINER_DIR/$CUSTOM_MINER/config.txt"

deploy/hiveos/h-manifest.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
# HiveOS custom miner manifest for c2pool
3+
# https://github.com/frstrtr/c2pool
4+
5+
MINER_NAME=c2pool
6+
MINER_LOG_BASENAME=/var/log/miner/c2pool/c2pool
7+
MINER_API_PORT=8080
8+
MINER_LATEST_VER=1.0.0

deploy/hiveos/h-run.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
# HiveOS miner launcher for c2pool
3+
4+
cd "$(dirname "$0")"
5+
6+
# Source manifest for MINER_API_PORT etc.
7+
. h-manifest.conf
8+
9+
# Generate config from flight sheet variables
10+
. h-config.sh
11+
12+
# Read generated config
13+
CONF=$(cat config.txt 2>/dev/null)
14+
15+
if [[ -z "$CONF" ]]; then
16+
echo "ERROR: No config generated. Check flight sheet settings."
17+
exit 1
18+
fi
19+
20+
# Ensure log directory exists
21+
mkdir -p /var/log/miner/c2pool
22+
23+
# Launch c2pool
24+
# shellcheck disable=SC2086
25+
exec ./c2pool $CONF 2>&1

deploy/hiveos/h-stats.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env bash
2+
# HiveOS stats reporter for c2pool
3+
#
4+
# Must set two variables:
5+
# khs — total hashrate in kilohashes/second
6+
# stats — JSON object with hs, temp, fan, uptime, ar, algo, ver
7+
#
8+
# Queries c2pool's REST API on MINER_API_PORT (default 8080).
9+
10+
cd "$(dirname "$0")"
11+
. h-manifest.conf
12+
13+
API="http://127.0.0.1:${MINER_API_PORT}"
14+
15+
# Fetch stats from c2pool API (with timeout to avoid hanging)
16+
local_stats=$(curl -s --max-time 5 "${API}/local_stats" 2>/dev/null)
17+
stratum_stats=$(curl -s --max-time 5 "${API}/stratum_stats" 2>/dev/null)
18+
uptime_val=$(curl -s --max-time 5 "${API}/uptime" 2>/dev/null)
19+
20+
if [[ -z "$local_stats" || "$local_stats" == "null" ]]; then
21+
# Miner not yet responding — report zero
22+
khs=0
23+
stats='{}'
24+
return 0 2>/dev/null || exit 0
25+
fi
26+
27+
# Extract total hashrate (H/s) from all miners, convert to kH/s
28+
# local_stats.miner_hash_rates is {address: hashrate_hs, ...}
29+
total_hs=$(echo "$local_stats" | jq -r '
30+
[.miner_hash_rates // {} | to_entries[] | .value] | add // 0
31+
')
32+
khs=$(echo "$total_hs" | awk '{printf "%.2f", $1 / 1000}')
33+
34+
# Extract accepted/rejected from stratum_stats
35+
# stratum_stats.workers is {worker_name: {accepted: N, rejected: N, ...}, ...}
36+
accepted=$(echo "$stratum_stats" | jq -r '
37+
[.workers // {} | to_entries[] | .value.accepted // 0] | add // 0
38+
')
39+
rejected=$(echo "$stratum_stats" | jq -r '
40+
[.workers // {} | to_entries[] | .value.rejected // 0] | add // 0
41+
')
42+
43+
# Per-worker hashrates for HiveOS hs[] array (in H/s)
44+
hs_array=$(echo "$local_stats" | jq -c '
45+
[.miner_hash_rates // {} | to_entries[] | .value] // [0]
46+
')
47+
48+
# Uptime in seconds
49+
up=$(echo "$uptime_val" | jq -r '. // 0' 2>/dev/null)
50+
[[ -z "$up" || "$up" == "null" ]] && up=0
51+
52+
# Pool efficiency
53+
efficiency=$(echo "$local_stats" | jq -r '.efficiency // 0')
54+
55+
# Shares info
56+
total_shares=$(echo "$local_stats" | jq -r '.shares.total // 0')
57+
orphan_shares=$(echo "$local_stats" | jq -r '.shares.orphan // 0')
58+
dead_shares=$(echo "$local_stats" | jq -r '.shares.dead // 0')
59+
60+
# Build stats JSON
61+
# HiveOS expects: hs (array), hs_units, temp (array), fan (array),
62+
# uptime, ar (array [accepted, rejected]), algo, ver
63+
stats=$(jq -n \
64+
--argjson hs "$hs_array" \
65+
--arg hs_units "hs" \
66+
--argjson uptime "$up" \
67+
--argjson accepted "$accepted" \
68+
--argjson rejected "$rejected" \
69+
--arg ver "$MINER_LATEST_VER" \
70+
--argjson total_shares "$total_shares" \
71+
--argjson orphan_shares "$orphan_shares" \
72+
--argjson dead_shares "$dead_shares" \
73+
--argjson efficiency "$efficiency" \
74+
'{
75+
hs: $hs,
76+
hs_units: $hs_units,
77+
temp: [],
78+
fan: [],
79+
uptime: $uptime,
80+
ar: [$accepted, $rejected],
81+
algo: "scrypt",
82+
ver: $ver,
83+
"total_shares": $total_shares,
84+
"orphan_shares": $orphan_shares,
85+
"dead_shares": $dead_shares,
86+
"efficiency": $efficiency
87+
}')
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
# MinerStat custom miner launch script for c2pool
3+
#
4+
# MinerStat Flight Sheet mapping:
5+
# Pool Host → litecoind RPC host
6+
# Pool Port → litecoind RPC port (default 9332)
7+
# Worker/Wallet → LTC payout address (optionally comma-separated with DOGE)
8+
# Password → litecoind RPC user:password
9+
# Algorithm → scrypt
10+
# Extra Parameters→ additional c2pool CLI flags
11+
#
12+
# Example msOS setup:
13+
# Pool host: 127.0.0.1
14+
# Pool port: 9332
15+
# Wallet: tltc1qkek8r3uymzqyajzezqgl99d2f948st5v67a5h3
16+
# Password: litecoinrpc:myrpcpassword
17+
# Extra params: --merged DOGE:98:127.0.0.1:44556:dogerpc:dogepass
18+
19+
# MinerStat provides these variables:
20+
# $POOL_HOST, $POOL_PORT, $WALLET, $WORKER, $PASSWORD, $ALGORITHM, $EXTRA_PARAMS
21+
22+
POOL_HOST="${POOL_HOST:-127.0.0.1}"
23+
POOL_PORT="${POOL_PORT:-9332}"
24+
25+
# Parse RPC credentials from password field
26+
RPC_USER="${PASSWORD%%:*}"
27+
RPC_PASSWORD="${PASSWORD#*:}"
28+
[[ "$RPC_USER" == "$RPC_PASSWORD" ]] && RPC_PASSWORD=""
29+
[[ -z "$RPC_USER" ]] && RPC_USER="litecoinrpc"
30+
31+
# Build address: wallet + optional worker suffix
32+
ADDRESS="$WALLET"
33+
[[ -n "$WORKER" && "$WORKER" != "default" ]] && ADDRESS="${ADDRESS}.${WORKER}"
34+
35+
# Build command
36+
CMD="./c2pool --integrated --net litecoin"
37+
CMD+=" --coind-address $POOL_HOST --coind-rpc-port $POOL_PORT"
38+
CMD+=" --rpcuser $RPC_USER --rpcpassword $RPC_PASSWORD"
39+
CMD+=" --address $ADDRESS"
40+
CMD+=" --web-port 8080"
41+
42+
[[ -n "$EXTRA_PARAMS" ]] && CMD+=" $EXTRA_PARAMS"
43+
44+
echo "Starting c2pool: $CMD"
45+
exec $CMD 2>&1

deploy/raveos/manifest.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"package": "c2pool",
3+
"name": "C2Pool",
4+
"version": "1.0.0",
5+
"description": "Decentralized P2Pool mining (Litecoin + merged DOGE)",
6+
"maintainer": "c2pool",
7+
"platforms": ["cpu"],
8+
"dual_coin": true,
9+
"algo": ["scrypt"],
10+
"executable": ["c2pool"],
11+
"rev": 1
12+
}

0 commit comments

Comments
 (0)