aboutsummaryrefslogtreecommitdiff
path: root/start-monzero-miner.sh
diff options
context:
space:
mode:
authorMonzero Build System <builds@monzero.org>2026-08-15 21:14:26 +0100
committerMonzero Build System <builds@monzero.org>2026-08-15 21:14:26 +0100
commit28f1919249465d3230f45ed21686c5a836d56df0 (patch)
tree948fe5e7052c45c366c24a82b485ae9d1d38e39b /start-monzero-miner.sh
parent4f92268d7c16741cfb41e5bbe2aa46cc260a9ea5 (diff)
downloadmonzero-core-28f1919249465d3230f45ed21686c5a836d56df0.tar.gz
monzero-core-28f1919249465d3230f45ed21686c5a836d56df0.tar.xz
monzero-core-28f1919249465d3230f45ed21686c5a836d56df0.zip
Establish Monzero Phase 0 and inactive assets baselinemonzero-phase0-assets-prototype-20260815
Diffstat (limited to 'start-monzero-miner.sh')
-rwxr-xr-xstart-monzero-miner.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/start-monzero-miner.sh b/start-monzero-miner.sh
new file mode 100755
index 000000000..45822762f
--- /dev/null
+++ b/start-monzero-miner.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+RPC_PORT="${MONZERO_RPC_PORT:-16175}"
+MINER_ADDRESS="${MONZERO_MINER_ADDRESS:-FR3j29tPrro5vdgMvFMyQr4W7VX41VzRHKjvhhNm5EB32MUFTiKFW21PCDrvUM5hvSQLYBom4jmY1AehUJKKtZbXH1uQ5u6}"
+THREADS="${1:-${MONZERO_MINER_THREADS:-1}}"
+RPC_URL="http://127.0.0.1:$RPC_PORT"
+
+if ! [[ "$THREADS" =~ ^[1-9][0-9]*$ ]]; then
+ printf 'Error: thread count must be a positive integer.\n' >&2
+ printf 'Usage: %s [threads]\n' "$0" >&2
+ exit 1
+fi
+
+if ! curl --silent --fail --max-time 2 \
+ --header 'Content-Type: application/json' \
+ --data '{}' "$RPC_URL/get_info" >/dev/null; then
+ printf 'Error: the Monzero daemon is not running at 127.0.0.1:%s.\n' "$RPC_PORT" >&2
+ printf 'Start it separately with ./start-monzerod.sh\n' >&2
+ exit 1
+fi
+
+response="$(curl --silent --show-error --fail --max-time 10 \
+ --header 'Content-Type: application/json' \
+ --data "{\"miner_address\":\"$MINER_ADDRESS\",\"threads_count\":$THREADS,\"do_background_mining\":false,\"ignore_battery\":true}" \
+ "$RPC_URL/start_mining")"
+
+python3 - "$response" "$THREADS" "$MINER_ADDRESS" <<'PY'
+import json
+import sys
+
+data = json.loads(sys.argv[1])
+status = data.get("status", "")
+if status != "OK":
+ raise SystemExit(f"Mining failed: {data.get('error_details') or status or data}")
+print(f"Mining started with {sys.argv[2]} thread(s).")
+print(f"Rewards address: {sys.argv[3]}")
+PY