Compare commits

..

7 Commits

Author SHA1 Message Date
f9d6bcad5e extranonce 2026-05-20 11:14:46 -05:00
24232d72c3 Add top-level build.sh release script 2026-03-10 20:26:13 -05:00
7d22bc2bb5 Add dual SHA256D block check for pool mining mode
Pool sends block_target (full 256-bit network target) with each job.
Miner checks SHA256D(header + RandomX solution) for every hash against
the block target, enabling block detection at full hashrate instead of
only on submitted shares.
2026-03-09 23:52:34 -05:00
95d3ff2c4a Fixing miner issues
- Switch from full-block to header-only (140-byte) RandomX input
- Add 32-byte SoloNonce system for solo mining mode
- Compute proper difficulty target from compact bits field
- Add SHA256D dual-hash PoW check in CpuWorker for solo mining
- Raise RandomX dataset/scratchpad limits to 4GB/4MB
- Use standard RandomX share filtering in pool (stratum) mode
2026-03-05 06:00:55 -06:00
a27a1e327b cleanup 2026-02-28 00:33:09 -06:00
c94352d305 Prepare XMRig-HAC fork for public release
- Add DragonX coin and rx/hush algorithm support
- Update branding to XMRig-HAC / dragonx.is
- Update repository URLs to git.hush.is
- Replace example wallet addresses with placeholders
- Update .gitignore for build directories
- Document fork changes in README and CHANGELOG
2026-02-26 23:48:10 -06:00
fc8286800d HAC changes 2026-01-27 16:45:21 -06:00
8 changed files with 228 additions and 4 deletions

4
.gitignore vendored
View File

@@ -37,3 +37,7 @@ src/config.json
Thumbs.db
*.swp
*~
release/
build-linux/
build-windows/
deps-windows/

124
build.sh Executable file
View File

@@ -0,0 +1,124 @@
#!/bin/bash
# XMRig-HAC Release Build Script
# Usage: ./build.sh [--linux-release] [--win-release]
set -e
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RELEASE_DIR="$ROOT_DIR/release"
VERSION=$(grep '#define APP_VERSION' "$ROOT_DIR/src/version.h" | sed 's/.*"\(.*\)"/\1/')
BUILD_LINUX=false
BUILD_WIN=false
for arg in "$@"; do
case "$arg" in
--linux-release) BUILD_LINUX=true ;;
--win-release) BUILD_WIN=true ;;
*)
echo "Usage: $0 [--linux-release] [--win-release]"
exit 1
;;
esac
done
if ! $BUILD_LINUX && ! $BUILD_WIN; then
echo "Usage: $0 [--linux-release] [--win-release]"
echo ""
echo "Flags:"
echo " --linux-release Build Linux x86_64 release"
echo " --win-release Build Windows x86_64 release (cross-compile with MinGW)"
exit 1
fi
echo "=== XMRig-HAC Release Builder v${VERSION} ==="
mkdir -p "$RELEASE_DIR"
build_linux() {
echo ""
echo "========================================="
echo " Building Linux x86_64 Release"
echo "========================================="
local BUILD_DIR="$ROOT_DIR/build-linux"
local DEPS_DIR="$ROOT_DIR/scripts/deps"
# Build dependencies if needed
if [ ! -f "$DEPS_DIR/lib/libuv.a" ] || [ ! -f "$DEPS_DIR/lib/libssl.a" ] || [ ! -f "$DEPS_DIR/lib/libhwloc.a" ]; then
echo "--- Building Linux dependencies ---"
cd "$ROOT_DIR/scripts"
bash build_deps.sh
fi
# Configure and build
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
cmake "$ROOT_DIR" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_STATIC=ON \
-DWITH_OPENCL=OFF \
-DWITH_CUDA=OFF \
-DXMRIG_DEPS="$DEPS_DIR"
make -j"$(nproc)"
strip xmrig
# Package
local PKG_NAME="xmrig-hac-${VERSION}-linux-x64"
local PKG_DIR="$RELEASE_DIR/$PKG_NAME"
rm -rf "$PKG_DIR"
mkdir -p "$PKG_DIR"
cp "$BUILD_DIR/xmrig" "$PKG_DIR/"
cp "$ROOT_DIR/src/config.example.json" "$PKG_DIR/config.json"
cp "$ROOT_DIR/README.md" "$PKG_DIR/"
cd "$RELEASE_DIR"
zip -r "${PKG_NAME}.zip" "$PKG_NAME"
rm -rf "$PKG_DIR"
echo ""
echo "Linux release: release/${PKG_NAME}.zip"
}
build_windows() {
echo ""
echo "========================================="
echo " Building Windows x86_64 Release"
echo "========================================="
# Delegate to the existing cross-compilation script
cd "$ROOT_DIR/scripts"
bash build_windows.sh
local BUILD_DIR="$ROOT_DIR/build-windows"
# Package
local PKG_NAME="xmrig-hac-${VERSION}-win-x64"
local PKG_DIR="$RELEASE_DIR/$PKG_NAME"
rm -rf "$PKG_DIR"
mkdir -p "$PKG_DIR"
cp "$BUILD_DIR/xmrig.exe" "$PKG_DIR/"
cp "$ROOT_DIR/bin/WinRing0/WinRing0x64.sys" "$PKG_DIR/"
cp "$ROOT_DIR/src/config.example.json" "$PKG_DIR/config.json"
cp "$ROOT_DIR/README.md" "$PKG_DIR/"
cd "$RELEASE_DIR"
zip -r "${PKG_NAME}.zip" "$PKG_NAME"
rm -rf "$PKG_DIR"
echo ""
echo "Windows release: release/${PKG_NAME}.zip"
}
# Run selected builds
$BUILD_LINUX && build_linux
$BUILD_WIN && build_windows
echo ""
echo "========================================="
echo " Release artifacts in release/"
echo "========================================="
ls -lh "$RELEASE_DIR"/*.zip 2>/dev/null || true

View File

@@ -61,14 +61,14 @@ if [ ! -f "$DEPS_DIR/lib/libuv.a" ]; then
echo "=== Building libuv dependency ==="
cd "$DEPS_DIR"
if [ ! -d "libuv-v1.51.0" ]; then
if [ ! -d "libuv-1.51.0" ]; then
if [ ! -f "libuv.tar.gz" ]; then
curl -L -o libuv.tar.gz https://github.com/libuv/libuv/archive/refs/tags/v1.51.0.tar.gz
fi
tar -xzf libuv.tar.gz
fi
cd libuv-v1.51.0
cd libuv-1.51.0
mkdir -p build && cd build
cmake .. \
-DCMAKE_TOOLCHAIN_FILE="$XMRIG_DIR/cmake/mingw-w64-toolchain.cmake" \

View File

@@ -436,6 +436,54 @@ void xmrig::CpuWorker<N>::start()
// Submit full 32-byte nonce + rx_hash as result
JobResults::submit(JobResult(job, current_solo_nonces + i * 32, m_hash + (i * 32)));
}
} else if (job.algorithm() == Algorithm::RX_HUSH && !m_job.isSoloMining()) {
// ── DRAGONX/HUSH pool mining: dual check ──
//
// DragonX uses dual PoW: the block hash is SHA256D(header + RandomX solution),
// NOT the RandomX hash itself. We must check SHA256D for EVERY hash to detect
// blocks, and also check the RandomX hash for share difficulty.
//
// Reconstruct the 140-byte header with the 4-byte nonce at offset 108.
// Bytes 112-139 come from the pool blob and may contain a per-client
// extraNonce1 (pool embeds it at offset 112 for nonce-space partitioning).
// We must preserve those bytes so pool-side re-verification matches.
uint8_t blob_for_header[140];
memcpy(blob_for_header, m_job.blob(), 140); // full blob incl. extraNonce
memcpy(blob_for_header + 108, &current_job_nonces[i], 4); // overwrite only bytes 108-111
bool submitted = false;
// Check SHA256D for block detection if pool sent block_target
if (job.hasBlockTarget()) {
alignas(8) uint8_t pow_hash[32];
dragonx_pow_hash(blob_for_header, m_hash + (i * 32), pow_hash);
// Compare pow_hash <= block_target (both in uint256 internal byte order)
// byte[31] is MSB (most significant in arith terms), compare from there down
bool isBlock = true;
for (int b = 31; b >= 0; --b) {
if (pow_hash[b] < job.blockTarget()[b]) {
break; // pow_hash < target → is a block
} else if (pow_hash[b] > job.blockTarget()[b]) {
isBlock = false;
break; // pow_hash > target → not a block
}
}
if (isBlock) {
// SHA256D meets block target — submit immediately
JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32), nullptr);
submitted = true;
}
}
// Also check RandomX hash for normal share difficulty (if not already submitted)
if (!submitted) {
const uint64_t value = *reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24);
if (value < job.target()) {
JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32), nullptr);
}
}
} else {
// ── Standard XMRig path (Monero, CryptoNight, etc.) ──
const uint64_t value = *reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24);

View File

@@ -418,6 +418,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value &params, int *code)
}
job.setSigKey(Json::getString(params, "sig_key"));
job.setBlockTarget(Json::getString(params, "block_target"));
m_job.setClientId(m_rpcId);

View File

@@ -115,6 +115,40 @@ bool xmrig::Job::setSeedHash(const char *hash)
}
bool xmrig::Job::setBlockTarget(const char *target)
{
if (!target) {
m_hasBlockTarget = false;
return false;
}
const size_t len = strlen(target);
if (len != 64) { // 32 bytes = 64 hex chars
m_hasBlockTarget = false;
return false;
}
// Parse 64-char hex string (display order) into uint256-compatible internal byte order.
// Display "00072f0f...000" → internal: data[31]=0x00, data[30]=0x07, data[29]=0x2f, ...
// This matches how Bitcoin/Zcash uint256 stores values (LSB at data[0], MSB at data[31]).
// Raw SHA256D output from OpenSSL also goes into uint256.data[] without reversal,
// so both hash and target are in the same internal byte order for comparison.
uint8_t tmp[32];
if (!Cvt::fromHex(tmp, sizeof(tmp), target, len)) {
m_hasBlockTarget = false;
return false;
}
// Reverse display order to internal byte order (LSB-first / little-endian uint256)
for (int i = 0; i < 32; ++i) {
m_blockTarget[i] = tmp[31 - i];
}
m_hasBlockTarget = true;
return true;
}
bool xmrig::Job::setTarget(const char *target)
{
static auto parse = [](const char *target, size_t size, const Algorithm &algorithm) -> uint64_t {
@@ -297,6 +331,9 @@ void xmrig::Job::copy(const Job &other)
# endif
m_hasMinerSignature = other.m_hasMinerSignature;
m_hasBlockTarget = other.m_hasBlockTarget;
m_isSoloMining = other.m_isSoloMining;
memcpy(m_blockTarget, other.m_blockTarget, sizeof(m_blockTarget));
}
@@ -353,6 +390,9 @@ void xmrig::Job::move(Job &&other)
# endif
m_hasMinerSignature = other.m_hasMinerSignature;
m_hasBlockTarget = other.m_hasBlockTarget;
m_isSoloMining = other.m_isSoloMining;
memcpy(m_blockTarget, other.m_blockTarget, sizeof(m_blockTarget));
}

View File

@@ -105,6 +105,11 @@ public:
inline bool isSoloMining() const { return m_isSoloMining; }
inline void setSoloMining(bool solo) { m_isSoloMining = solo; }
// DragonX block target for SHA256D PoW check (32 bytes, internal byte order)
inline bool hasBlockTarget() const { return m_hasBlockTarget; }
inline const uint8_t *blockTarget() const { return m_blockTarget; }
bool setBlockTarget(const char *target);
void setHushHeader(const uint8_t *header108);
# ifdef XMRIG_PROXY_PROJECT
@@ -172,6 +177,8 @@ private:
uint8_t m_blob[kMaxBlobSize]{ 0 };
uint8_t m_index = 0;
bool m_isSoloMining = false;
bool m_hasBlockTarget = false;
uint8_t m_blockTarget[32]{};
# ifdef XMRIG_PROXY_PROJECT
char m_rawBlob[kMaxBlobSize * 2 + 8]{};

View File

@@ -11,7 +11,7 @@
#define APP_ID "xmrig-hac"
#define APP_NAME "XMRig-HAC"
#define APP_DESC "XMRig miner"
#define APP_VERSION "6.25.0-hac"
#define APP_VERSION "6.25.1-hac"
#define APP_DOMAIN "dragonx.is"
#define APP_SITE "www.dragonx.is"
#define APP_COPYRIGHT "Copyright (C) 2026 dragonx.is"
@@ -19,7 +19,7 @@
#define APP_VER_MAJOR 6
#define APP_VER_MINOR 25
#define APP_VER_PATCH 0
#define APP_VER_PATCH 1
#ifdef _MSC_VER
# if (_MSC_VER >= 1950)