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
11 changes: 10 additions & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ if [ "$(uname -s)" = "Darwin" ]; then
MINER_FILENAME="rustchain_mac_miner_v2.5.py"
MINER_URL="${REPO_RAW}/miners/macos/${MINER_FILENAME}"
FINGERPRINT_URL="${REPO_RAW}/miners/macos/fingerprint_checks.py"
MINER_CRYPTO_URL="${REPO_RAW}/miners/macos/miner_crypto.py"
else
MINER_FILENAME="rustchain_linux_miner.py"
MINER_URL="${REPO_RAW}/miners/linux/rustchain_linux_miner.py"
Expand Down Expand Up @@ -602,7 +603,15 @@ CFGEOF

# --- Generate miner ID ---
local miner_id
miner_id=$(echo -n "${wallet}-${arch}-$(hostname)" | sha256sum 2>/dev/null | cut -c1-16 || echo "${wallet}")
if command -v sha256sum &>/dev/null; then
miner_id=$(printf '%s-%s-%s' "$wallet" "$arch" "$(hostname)" | sha256sum | cut -c1-16)
elif command -v shasum &>/dev/null; then
miner_id=$(printf '%s-%s-%s' "$wallet" "$arch" "$(hostname)" | shasum -a 256 | cut -c1-16)
elif command -v python3 &>/dev/null; then
miner_id=$(python3 -c 'import sys, hashlib; print(hashlib.sha256(f"{sys.argv[1]}-{sys.argv[2]}-{sys.argv[3]}".encode()).hexdigest()[:16])' "$wallet" "$arch" "$(hostname)" 2>/dev/null || echo "$wallet")
else
miner_id="${wallet}"
fi

# --- Create service ---
echo ""
Expand Down
16 changes: 16 additions & 0 deletions tests/test_macos_installer_compatibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
INSTALLER = ROOT / "scripts" / "install.sh"


def test_installer_defines_miner_crypto_url_for_macos():
script = INSTALLER.read_text(encoding="utf-8")
darwin_block = script.split('if [ "$(uname -s)" = "Darwin" ]; then')[1].split("else")[0]
assert "MINER_CRYPTO_URL=" in darwin_block


def test_installer_uses_portable_sha256_for_miner_id():
script = INSTALLER.read_text(encoding="utf-8")
assert "shasum -a 256" in script
assert "hashlib.sha256" in script