6 Commits

Author SHA1 Message Date
2b011d6ee2 fix windows build 2026-03-19 10:09:18 -05:00
M
d77088c1f2 Fix macOS Sequoia build with GCC 15 and update README
- Update compiler references from gcc-8 to gcc-15 across build system
  (build-mac.sh, darwin.mk, Makefile_custom)
- Use system Rust (rustup) instead of bundled Rust 1.32.0 for librustzcash
  to fix rlib linker incompatibility on macOS Sequoia
- Replace deprecated std::random_shuffle with std::shuffle (net.cpp,
  transaction_builder.cpp, wallet.cpp)
- Fix -std=gnu17 -> -std=gnu++17 for C++ targets (libzcash, libhush)
- Fix nodiscard warning in glibcxx_sanity.cpp
- Replace deprecated OSMemoryBarrier with std::atomic_thread_fence in LevelDB
- Add -Wno-error=deprecated-declarations to CXXFLAGS for third-party headers
- Fix REMAINING_ARGS unbound variable in build.sh
- Add --disable-tests handling to build-mac.sh
- Update README with correct macOS build dependencies and instructions
2026-03-19 09:30:50 -05:00
faa3e925cd fix windows bootstrap script, add mirror fallback 2026-03-17 18:37:40 -05:00
ddd851dc11 Bump version to 1.0.2 2026-03-17 04:11:32 -05:00
752590348b Fix sapling pool persistence and add subsidy/fees to getblock RPC
Lower SPROUT_VALUE_VERSION and SAPLING_VALUE_VERSION constants in
chain.h from upstream Zcash values (1001400/1010100) to 1000000.
When DragonX was rebranded from HUSH3, CLIENT_VERSION was reset from
3.10.5 to 1.0.0, falling below these thresholds. This caused
nSaplingValue to silently skip serialization, so the sapling pool
total reset to 0 on every node restart. Explorer nodes should reindex
once after upgrading.

Add subsidy and fees fields to the getblock RPC response so explorers
can display the correct 3 DRGX block reward separately from fees,
instead of showing the combined coinbase output as the reward.
2026-03-15 16:07:16 -05:00
f0cb958cac Fix fresh sync failure at diff reset height 2838976
Fresh-syncing nodes rejected the on-chain min-diff block at the
RANDOMX_VALIDATION activation height (2838976) because GetNextWorkRequired
computed the expected nBits from the preceding normal-difficulty blocks,
producing 469847994 instead of the on-chain 0x200f0f0f (HUSH_MINDIFF_NBITS).
This caused all seed nodes to be banned with "Incorrect diffbits" and the
node could never sync past that height.

Two changes:

1. GetNextWorkRequired (pow.cpp): Return nProofOfWorkLimit at the exact
   RANDOMX_VALIDATION activation height, matching the on-chain diff reset.

2. ContextualCheckBlockHeader (main.cpp): Raise DragonX daaForkHeight to
   RANDOMX_VALIDATION + 62000, covering the window where nBits was never
   validated (diff reset at 2838976 through the attack at ~2879907).

Tested by invalidating block 2838975 and reconsidering — node re-validated
through the diff reset and attack window, syncing back to tip with zero
bad-diffbits rejections.

Bump version to 1.0.1.
2026-03-12 01:25:21 -05:00
25 changed files with 408 additions and 52 deletions

1
.gitignore vendored
View File

@@ -175,3 +175,4 @@ src/dragonx-tx
src/dragonxd.exe src/dragonxd.exe
src/dragonx-cli.exe src/dragonx-cli.exe
src/dragonx-tx.exe src/dragonx-tx.exe
doc/relnotes/

View File

@@ -106,19 +106,32 @@ apt-get install -y gcc-7 g++-7 && \
# Build on Mac # Build on Mac
``` Install Xcode Command Line Tools and [Homebrew](https://brew.sh/), then install dependencies:
sudo port update
sudo port upgrade outdated ```sh
sudo port install qt5 xcode-select --install
brew install gcc autoconf automake pkgconf libtool cmake curl
# Install Rust (needed for librustzcash on macOS Sequoia+)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
# clone git repo # clone git repo
git clone https://git.hush.is/hush/hush3 git clone https://git.hush.is/hush/hush3
cd hush3 cd hush3
# Build # Build (uses 3 build processes, you need 2GB of RAM for each)
# This uses 3 build processes, you need 2GB of RAM for each. # Make sure libtool gnubin and cargo are on PATH
export PATH="$HOME/.cargo/bin:/usr/local/opt/libtool/libexec/gnubin:$PATH"
./build.sh -j3 ./build.sh -j3
``` ```
For a release build:
```sh
export PATH="$HOME/.cargo/bin:/usr/local/opt/libtool/libexec/gnubin:$PATH"
./build.sh --mac-release -j$(sysctl -n hw.ncpu)
```
# Installing Hush binaries # Installing Hush binaries
1. [Download the release](https://git.hush.is/hush/hush3/releases) with a .deb file extension. 1. [Download the release](https://git.hush.is/hush/hush3/releases) with a .deb file extension.

View File

@@ -6,7 +6,7 @@
set -eu -o pipefail set -eu -o pipefail
VERSION="1.0.0" VERSION="1.0.2"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RELEASE_DIR="$SCRIPT_DIR/release" RELEASE_DIR="$SCRIPT_DIR/release"
@@ -80,8 +80,12 @@ package_release() {
echo "Packaging release for $platform..." echo "Packaging release for $platform..."
mkdir -p "$release_subdir" mkdir -p "$release_subdir"
# Copy bootstrap script # Copy bootstrap script (platform-appropriate)
cp "$SCRIPT_DIR/util/bootstrap-dragonx.sh" "$release_subdir/" if [ "$platform" = "win64" ]; then
cp "$SCRIPT_DIR/util/bootstrap-dragonx.bat" "$release_subdir/"
else
cp "$SCRIPT_DIR/util/bootstrap-dragonx.sh" "$release_subdir/"
fi
# Copy common files # Copy common files
cp "$SCRIPT_DIR/contrib/asmap/asmap.dat" "$release_subdir/" 2>/dev/null || true cp "$SCRIPT_DIR/contrib/asmap/asmap.dat" "$release_subdir/" 2>/dev/null || true
@@ -171,21 +175,21 @@ if [ $BUILD_LINUX_COMPAT -eq 1 ] || [ $BUILD_LINUX_RELEASE -eq 1 ] || [ $BUILD_W
if [ $BUILD_LINUX_RELEASE -eq 1 ]; then if [ $BUILD_LINUX_RELEASE -eq 1 ]; then
echo "=== Building Linux release ===" echo "=== Building Linux release ==="
clean_for_platform linux clean_for_platform linux
./util/build.sh --disable-tests "${REMAINING_ARGS[@]}" ./util/build.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"}
package_release linux-amd64 package_release linux-amd64
fi fi
if [ $BUILD_WIN_RELEASE -eq 1 ]; then if [ $BUILD_WIN_RELEASE -eq 1 ]; then
echo "=== Building Windows release ===" echo "=== Building Windows release ==="
clean_for_platform windows clean_for_platform windows
./util/build-win.sh --disable-tests "${REMAINING_ARGS[@]}" ./util/build-win.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"}
package_release win64 package_release win64
fi fi
if [ $BUILD_MAC_RELEASE -eq 1 ]; then if [ $BUILD_MAC_RELEASE -eq 1 ]; then
echo "=== Building macOS release ===" echo "=== Building macOS release ==="
clean_for_platform macos clean_for_platform macos
./util/build-mac.sh --disable-tests "${REMAINING_ARGS[@]}" ./util/build-mac.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"}
package_release macos package_release macos
fi fi
@@ -197,11 +201,11 @@ fi
# Standard build (auto-detect OS) # Standard build (auto-detect OS)
if [[ "$OSTYPE" == "linux-gnu"* ]]; then if [[ "$OSTYPE" == "linux-gnu"* ]]; then
./util/build.sh --disable-tests "${REMAINING_ARGS[@]}" ./util/build.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"}
elif [[ "$OSTYPE" == "darwin"* ]]; then elif [[ "$OSTYPE" == "darwin"* ]]; then
./util/build-mac.sh --disable-tests "${REMAINING_ARGS[@]}" ./util/build-mac.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"}
elif [[ "$OSTYPE" == "msys"* ]]; then elif [[ "$OSTYPE" == "msys"* ]]; then
./util/build-win.sh --disable-tests "${REMAINING_ARGS[@]}" ./util/build-win.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"}
else else
echo "Unable to detect your OS. What are you using?" echo "Unable to detect your OS. What are you using?"
fi fi

View File

@@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 1) define(_CLIENT_VERSION_MAJOR, 1)
dnl Must be kept in sync with src/clientversion.h , ugh! dnl Must be kept in sync with src/clientversion.h , ugh!
define(_CLIENT_VERSION_MINOR, 0) define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_REVISION, 0) define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_BUILD, 50) define(_CLIENT_VERSION_BUILD, 50)
define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50)))
define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1)))

View File

@@ -1,5 +1,5 @@
build_darwin_CC = gcc-8 build_darwin_CC = gcc-15
build_darwin_CXX = g++-8 build_darwin_CXX = g++-15
build_darwin_AR: = $(shell xcrun -f ar) build_darwin_AR: = $(shell xcrun -f ar)
build_darwin_RANLIB: = $(shell xcrun -f ranlib) build_darwin_RANLIB: = $(shell xcrun -f ranlib)
build_darwin_STRIP: = $(shell xcrun -f strip) build_darwin_STRIP: = $(shell xcrun -f strip)
@@ -10,8 +10,8 @@ build_darwin_SHA256SUM = shasum -a 256
build_darwin_DOWNLOAD = curl --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -L -f -o build_darwin_DOWNLOAD = curl --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -L -f -o
#darwin host on darwin builder. overrides darwin host preferences. #darwin host on darwin builder. overrides darwin host preferences.
darwin_CC= gcc-8 darwin_CC= gcc-15
darwin_CXX= g++-8 darwin_CXX= g++-15
darwin_AR:=$(shell xcrun -f ar) darwin_AR:=$(shell xcrun -f ar)
darwin_RANLIB:=$(shell xcrun -f ranlib) darwin_RANLIB:=$(shell xcrun -f ranlib)
darwin_STRIP:=$(shell xcrun -f strip) darwin_STRIP:=$(shell xcrun -f strip)

View File

@@ -2,8 +2,8 @@ OSX_MIN_VERSION=10.12
OSX_SDK_VERSION=10.12 OSX_SDK_VERSION=10.12
OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk
LD64_VERSION=253.9 LD64_VERSION=253.9
darwin_CC=gcc-8 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) darwin_CC=gcc-15 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION)
darwin_CXX=g++-8 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) darwin_CXX=g++-15 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION)
darwin_CFLAGS=-pipe darwin_CFLAGS=-pipe
darwin_CXXFLAGS=$(darwin_CFLAGS) darwin_CXXFLAGS=$(darwin_CFLAGS)

View File

@@ -40,9 +40,15 @@ define $(package)_preprocess_cmds
cat $($(package)_patch_dir)/cargo.config | sed 's|CRATE_REGISTRY|$(host_prefix)/$(CRATE_REGISTRY)|' > .cargo/config cat $($(package)_patch_dir)/cargo.config | sed 's|CRATE_REGISTRY|$(host_prefix)/$(CRATE_REGISTRY)|' > .cargo/config
endef endef
ifeq ($(build_os),darwin)
define $(package)_build_cmds
CARGO=$(HOME)/.cargo/bin/cargo RUSTC=$(HOME)/.cargo/bin/rustc $(HOME)/.cargo/bin/cargo build --package librustzcash $($(package)_build_opts)
endef
else
define $(package)_build_cmds define $(package)_build_cmds
$(host_prefix)/native/bin/cargo build --package librustzcash $($(package)_build_opts) $(host_prefix)/native/bin/cargo build --package librustzcash $($(package)_build_opts)
endef endef
endif
define $(package)_stage_cmds define $(package)_stage_cmds
mkdir $($(package)_staging_dir)$(host_prefix)/lib/ && \ mkdir $($(package)_staging_dir)$(host_prefix)/lib/ && \

8
depends/strip-rlib-metadata.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
# Strip rust.metadata.bin from .rlib archives for macOS linker compatibility
RLIB_DIR="$1"
if [ -d "$RLIB_DIR" ]; then
for rlib in "$RLIB_DIR"/*.rlib; do
[ -f "$rlib" ] && ar d "$rlib" rust.metadata.bin 2>/dev/null || true
done
fi

View File

@@ -594,7 +594,7 @@ libzcash_a_CPPFLAGS = -DMULTICORE -fopenmp -fPIC -DBOOST_SPIRIT_THREADSAFE -DHAV
#libzcash_a_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) #libzcash_a_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
#libzcash_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DMONTGOMERY_OUTPUT #libzcash_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DMONTGOMERY_OUTPUT
libzcash_a_CXXFLAGS = $(SAN_CXXFLAGS) $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing -std=gnu17 libzcash_a_CXXFLAGS = $(SAN_CXXFLAGS) $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing -std=gnu++17
libzcash_a_LDFLAGS = $(SAN_LDFLAGS) $(HARDENED_LDFLAGS) libzcash_a_LDFLAGS = $(SAN_LDFLAGS) $(HARDENED_LDFLAGS)
libzcash_a_CPPFLAGS += -DMONTGOMERY_OUTPUT libzcash_a_CPPFLAGS += -DMONTGOMERY_OUTPUT
@@ -636,7 +636,7 @@ libhush_a_SOURCES = \
libhush_a_CPPFLAGS = -DMULTICORE -fopenmp -fPIC -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS $(HARDENED_CPPFLAGS) -pipe -O1 -g -Wstack-protector -fstack-protector-all -fPIE -fvisibility=hidden -DSTATIC $(BITCOIN_INCLUDES) libhush_a_CPPFLAGS = -DMULTICORE -fopenmp -fPIC -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS $(HARDENED_CPPFLAGS) -pipe -O1 -g -Wstack-protector -fstack-protector-all -fPIE -fvisibility=hidden -DSTATIC $(BITCOIN_INCLUDES)
libhush_a_CXXFLAGS = $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing -std=gnu17 libhush_a_CXXFLAGS = $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing -std=gnu++17
libhush_a_LDFLAGS = $(HARDENED_LDFLAGS) libhush_a_LDFLAGS = $(HARDENED_LDFLAGS)

View File

@@ -1,5 +1,5 @@
SHELL = /bin/sh SHELL = /bin/sh
CC_DARWIN = g++-8 CC_DARWIN = g++-15
CC_WIN = x86_64-w64-mingw32-gcc-posix CC_WIN = x86_64-w64-mingw32-gcc-posix
CC_AARCH64 = aarch64-linux-gnu-g++ CC_AARCH64 = aarch64-linux-gnu-g++
CFLAGS_DARWIN = -DBUILD_CUSTOMCC -std=c++11 -arch x86_64 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../leveldb/include -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib CFLAGS_DARWIN = -DBUILD_CUSTOMCC -std=c++11 -arch x86_64 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../leveldb/include -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib

BIN
src/cc/customcc.dylib Normal file

Binary file not shown.

View File

@@ -32,8 +32,12 @@ class CChainPower;
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
extern bool fZindex; extern bool fZindex;
static const int SPROUT_VALUE_VERSION = 1001400; // These version thresholds control whether nSproutValue/nSaplingValue are
static const int SAPLING_VALUE_VERSION = 1010100; // serialized in the block index. They must be <= CLIENT_VERSION or the
// values will never be persisted, causing nChainSaplingValue to reset
// to 0 after node restart. DragonX CLIENT_VERSION is 1000250 (v1.0.2.50).
static const int SPROUT_VALUE_VERSION = 1000000;
static const int SAPLING_VALUE_VERSION = 1000000;
extern int32_t ASSETCHAINS_LWMAPOS; extern int32_t ASSETCHAINS_LWMAPOS;
extern char SMART_CHAIN_SYMBOL[65]; extern char SMART_CHAIN_SYMBOL[65];
extern uint64_t ASSETCHAINS_NOTARY_PAY[]; extern uint64_t ASSETCHAINS_NOTARY_PAY[];

View File

@@ -30,7 +30,7 @@
// Must be kept in sync with configure.ac , ugh! // Must be kept in sync with configure.ac , ugh!
#define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 0 #define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_BUILD 50 #define CLIENT_VERSION_BUILD 50
//! Set to true for release, false for prerelease or test build //! Set to true for release, false for prerelease or test build

View File

@@ -47,7 +47,7 @@ bool sanity_test_range_fmt()
{ {
std::string test; std::string test;
try { try {
test.at(1); (void)test.at(1);
} catch (const std::out_of_range&) { } catch (const std::out_of_range&) {
return true; return true;
} catch (...) { } catch (...) {

View File

@@ -51,8 +51,9 @@ namespace port {
// Mac OS // Mac OS
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
#include <atomic>
inline void MemoryBarrier() { inline void MemoryBarrier() {
OSMemoryBarrier(); std::atomic_thread_fence(std::memory_order_seq_cst);
} }
#define LEVELDB_HAVE_MEMORY_BARRIER #define LEVELDB_HAVE_MEMORY_BARRIER

BIN
src/libcc.dylib Normal file

Binary file not shown.

View File

@@ -5107,7 +5107,14 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
assert(pindexPrev); assert(pindexPrev);
int daaForkHeight = GetArg("-daaforkheight", 450000); // For HUSH3, nBits validation starts above the original DAA fork height (450000).
// For DragonX, nBits was never validated before the standalone binary, so the
// chain contains blocks with incorrect nBits during the vulnerable window
// (diff reset at RANDOMX_VALIDATION height through the attack at ~2879907).
// Set daaForkHeight past that window so fresh sync accepts historical blocks.
bool isdragonx = strncmp(SMART_CHAIN_SYMBOL, "DRAGONX", 7) == 0;
int defaultDaaForkHeight = isdragonx ? ASSETCHAINS_RANDOMX_VALIDATION + 62000 : 450000;
int daaForkHeight = GetArg("-daaforkheight", defaultDaaForkHeight);
int nHeight = pindexPrev->GetHeight()+1; int nHeight = pindexPrev->GetHeight()+1;
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
// Check Proof-of-Work difficulty // Check Proof-of-Work difficulty

View File

@@ -33,6 +33,8 @@
#include "crypto/common.h" #include "crypto/common.h"
#include "hush/utiltls.h" #include "hush/utiltls.h"
#include <random.h> #include <random.h>
#include <random>
#include <limits>
#ifdef _WIN32 #ifdef _WIN32
#include <string.h> #include <string.h>
#else #else
@@ -2004,7 +2006,7 @@ void ThreadMessageHandler()
// Randomize the order in which we process messages from/to our peers. // Randomize the order in which we process messages from/to our peers.
// This prevents attacks in which an attacker exploits having multiple // This prevents attacks in which an attacker exploits having multiple
// consecutive connections in the vNodes list. // consecutive connections in the vNodes list.
random_shuffle(vNodesCopy.begin(), vNodesCopy.end(), GetRandInt); std::shuffle(vNodesCopy.begin(), vNodesCopy.end(), std::mt19937(GetRand(std::numeric_limits<uint32_t>::max())));
BOOST_FOREACH(CNode* pnode, vNodesCopy) BOOST_FOREACH(CNode* pnode, vNodesCopy)
{ {
@@ -2516,7 +2518,7 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss)
// We always round down, except when we have only 1 connection // We always round down, except when we have only 1 connection
auto newSize = (vNodes.size() / 2) == 0 ? 1 : (vNodes.size() / 2); auto newSize = (vNodes.size() / 2) == 0 ? 1 : (vNodes.size() / 2);
random_shuffle( vRelayNodes.begin(), vRelayNodes.end(), GetRandInt ); std::shuffle( vRelayNodes.begin(), vRelayNodes.end(), std::mt19937(GetRand(std::numeric_limits<uint32_t>::max())) );
vRelayNodes.resize(newSize); vRelayNodes.resize(newSize);
if (HUSH_TESTNODE==1 && vNodes.size() == 0) { if (HUSH_TESTNODE==1 && vNodes.size() == 0) {

View File

@@ -315,6 +315,16 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
if (pindexLast == NULL ) if (pindexLast == NULL )
return nProofOfWorkLimit; return nProofOfWorkLimit;
// DragonX difficulty reset at the RANDOMX_VALIDATION activation height.
// The chain transitioned to a new binary at this height and difficulty was
// reset to minimum (powLimit). Without this, fresh-syncing nodes compute
// a different nBits from GetNextWorkRequired (based on pre-reset blocks)
// and reject the on-chain min-diff block, banning all seed nodes.
if (ASSETCHAINS_RANDOMX_VALIDATION > 0 && pindexLast->GetHeight() + 1 == ASSETCHAINS_RANDOMX_VALIDATION) {
LogPrintf("%s: difficulty reset to powLimit at height %d\n", __func__, ASSETCHAINS_RANDOMX_VALIDATION);
return nProofOfWorkLimit;
}
//{ //{
// Comparing to pindexLast->nHeight with >= because this function // Comparing to pindexLast->nHeight with >= because this function
// returns the work required for the block after pindexLast. // returns the work required for the block after pindexLast.

View File

@@ -322,6 +322,15 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
result.push_back(Pair("anchor", blockindex->hashFinalSproutRoot.GetHex())); result.push_back(Pair("anchor", blockindex->hashFinalSproutRoot.GetHex()));
result.push_back(Pair("blocktype", "mined")); result.push_back(Pair("blocktype", "mined"));
// Report block subsidy and fees separately so explorers don't have to
// reimplement the reward schedule to display them.
CAmount nSubsidy = GetBlockSubsidy(blockindex->GetHeight(), Params().GetConsensus());
CAmount nCoinbase = block.vtx[0].GetValueOut();
CAmount nFees = nCoinbase - nSubsidy;
if (nFees < 0) nFees = 0; // block 1 has premine, avoid negative
result.push_back(Pair("subsidy", ValueFromAmount(nSubsidy)));
result.push_back(Pair("fees", ValueFromAmount(nFees)));
UniValue valuePools(UniValue::VARR); UniValue valuePools(UniValue::VARR);
valuePools.push_back(ValuePoolDesc("sapling", blockindex->nChainSaplingValue, blockindex->nSaplingValue)); valuePools.push_back(ValuePoolDesc("sapling", blockindex->nChainSaplingValue, blockindex->nSaplingValue));
result.push_back(Pair("valuePools", valuePools)); result.push_back(Pair("valuePools", valuePools));

View File

@@ -11,6 +11,8 @@
#include <boost/optional/optional_io.hpp> #include <boost/optional/optional_io.hpp>
#include <librustzcash.h> #include <librustzcash.h>
#include "zcash/Note.hpp" #include "zcash/Note.hpp"
#include <random>
#include <limits>
extern bool fZDebug; extern bool fZDebug;
SpendDescriptionInfo::SpendDescriptionInfo( SpendDescriptionInfo::SpendDescriptionInfo(
@@ -66,7 +68,7 @@ void TransactionBuilder::AddSaplingOutput(
void TransactionBuilder::ShuffleOutputs() void TransactionBuilder::ShuffleOutputs()
{ {
LogPrintf("%s: Shuffling %d zouts\n", __func__, outputs.size() ); LogPrintf("%s: Shuffling %d zouts\n", __func__, outputs.size() );
random_shuffle( outputs.begin(), outputs.end(), GetRandInt ); std::shuffle( outputs.begin(), outputs.end(), std::mt19937(GetRand(std::numeric_limits<uint32_t>::max())) );
} }
void TransactionBuilder::AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value, uint32_t _nSequence) void TransactionBuilder::AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value, uint32_t _nSequence)

View File

@@ -39,6 +39,8 @@
#include "coins.h" #include "coins.h"
#include "wallet/asyncrpcoperation_saplingconsolidation.h" #include "wallet/asyncrpcoperation_saplingconsolidation.h"
#include "wallet/asyncrpcoperation_sweep.h" #include "wallet/asyncrpcoperation_sweep.h"
#include <random>
#include <limits>
#include "zcash/zip32.h" #include "zcash/zip32.h"
#include "cc/CCinclude.h" #include "cc/CCinclude.h"
#include <assert.h> #include <assert.h>
@@ -3416,7 +3418,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
vector<pair<CAmount, pair<const CWalletTx*,unsigned int> > > vValue; vector<pair<CAmount, pair<const CWalletTx*,unsigned int> > > vValue;
CAmount nTotalLower = 0; CAmount nTotalLower = 0;
random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); std::shuffle(vCoins.begin(), vCoins.end(), std::mt19937(GetRand(std::numeric_limits<uint32_t>::max())));
BOOST_FOREACH(const COutput &output, vCoins) BOOST_FOREACH(const COutput &output, vCoins)
{ {

264
util/bootstrap-dragonx.bat Normal file
View File

@@ -0,0 +1,264 @@
@echo off
REM Copyright 2024 The Hush Developers
REM Copyright 2024 The DragonX Developers
REM Released under the GPLv3
REM
REM Download and apply a DRAGONX blockchain bootstrap on Windows.
REM Safely preserves wallet.dat and configuration files.
setlocal enabledelayedexpansion
set "BOOTSTRAP_BASE_URL=https://bootstrap.dragonx.is"
set "BOOTSTRAP_FALLBACK_URL=https://bootstrap2.dragonx.is"
set "BOOTSTRAP_FILE=DRAGONX.zip"
set "CHAIN_NAME=DRAGONX"
REM Data directory on Windows
set "DATADIR=%APPDATA%\Hush\%CHAIN_NAME%"
REM Find dragonx-cli relative to this script
set "CLI="
set "SCRIPT_DIR=%~dp0"
if exist "%SCRIPT_DIR%dragonx-cli.exe" (
set "CLI=%SCRIPT_DIR%dragonx-cli.exe"
)
echo ============================================
echo DragonX Bootstrap Installer
echo ============================================
echo.
echo [INFO] Data directory: %DATADIR%
echo.
REM Step 1: Stop daemon if running
call :stop_daemon
if errorlevel 1 goto :error_exit
REM Step 2: Clean old chain data
call :clean_chain_data
if errorlevel 1 goto :error_exit
REM Step 3: Download bootstrap
call :download_bootstrap
if errorlevel 1 goto :error_exit
REM Step 4: Extract bootstrap
call :extract_bootstrap
if errorlevel 1 goto :error_exit
echo.
echo [INFO] Bootstrap installation complete!
echo [INFO] You can now start DragonX with: dragonxd.exe
echo.
goto :EOF
REM ============================================
REM Stop daemon if running
REM ============================================
:stop_daemon
if "%CLI%"=="" (
echo [WARN] dragonx-cli.exe not found next to this script.
echo [WARN] Please make sure the DragonX daemon is stopped before continuing.
set /p "ANSWER=Is the DragonX daemon stopped? (y/N): "
if /i not "!ANSWER!"=="y" (
echo [ERROR] Please stop the daemon first and run this script again.
exit /b 1
)
exit /b 0
)
"%CLI%" getinfo >nul 2>&1
if errorlevel 1 (
echo [INFO] Daemon is not running.
exit /b 0
)
echo [INFO] Stopping DragonX daemon...
"%CLI%" stop >nul 2>&1
set "TRIES=0"
:wait_loop
"%CLI%" getinfo >nul 2>&1
if errorlevel 1 goto :daemon_stopped
timeout /t 2 /nobreak >nul
set /a TRIES+=1
if %TRIES% geq 60 (
echo [ERROR] Daemon did not stop after 120 seconds. Please stop it manually and retry.
exit /b 1
)
goto :wait_loop
:daemon_stopped
echo [INFO] Daemon stopped.
exit /b 0
REM ============================================
REM Clean blockchain data, preserving wallet and config
REM ============================================
:clean_chain_data
if not exist "%DATADIR%" (
echo [INFO] Data directory does not exist yet, creating it.
mkdir "%DATADIR%"
exit /b 0
)
echo [INFO] Cleaning blockchain data from %DATADIR% ...
REM Preserve wallet.dat and config
set "TMPDIR=%TEMP%\dragonx-bootstrap-%RANDOM%"
mkdir "%TMPDIR%" 2>nul
for %%F in (wallet.dat DRAGONX.conf peers.dat) do (
if exist "%DATADIR%\%%F" (
copy /y "%DATADIR%\%%F" "%TMPDIR%\%%F" >nul
)
)
REM Remove blockchain directories and files
for %%D in (blocks chainstate notarizations komodo) do (
if exist "%DATADIR%\%%D" (
rmdir /s /q "%DATADIR%\%%D" 2>nul
)
)
for %%F in (db.log debug.log fee_estimates.dat banlist.dat) do (
if exist "%DATADIR%\%%F" (
del /f /q "%DATADIR%\%%F" 2>nul
)
)
REM Restore preserved files
for %%F in (wallet.dat DRAGONX.conf peers.dat) do (
if exist "%TMPDIR%\%%F" (
copy /y "%TMPDIR%\%%F" "%DATADIR%\%%F" >nul
)
)
rmdir /s /q "%TMPDIR%" 2>nul
echo [INFO] Blockchain data cleaned.
exit /b 0
REM ============================================
REM Download bootstrap (with fallback)
REM ============================================
:download_bootstrap
echo [INFO] Downloading bootstrap from %BOOTSTRAP_BASE_URL% ...
echo [INFO] This may take a while depending on your connection speed.
REM Try primary URL
call :do_download "%BOOTSTRAP_BASE_URL%"
if not errorlevel 1 goto :download_verify
echo [WARN] Primary download failed, trying fallback %BOOTSTRAP_FALLBACK_URL% ...
call :do_download "%BOOTSTRAP_FALLBACK_URL%"
if errorlevel 1 (
echo [ERROR] Download failed from both primary and fallback servers.
exit /b 1
)
:download_verify
echo [INFO] Bootstrap download complete.
REM Verify SHA256 checksum
echo [INFO] Verifying checksum...
pushd "%DATADIR%"
REM Read expected hash from the .sha256 file (format: "hash filename" or "hash *filename")
set "EXPECTED_HASH="
for /f "tokens=1" %%A in (%BOOTSTRAP_FILE%.sha256) do (
set "EXPECTED_HASH=%%A"
)
if "%EXPECTED_HASH%"=="" (
echo [WARN] Could not read expected checksum, skipping verification.
goto :verify_done
)
REM Use certutil to compute SHA256
certutil -hashfile "%BOOTSTRAP_FILE%" SHA256 > "%TEMP%\dragonx_hash.tmp" 2>nul
if errorlevel 1 (
echo [WARN] certutil not available, skipping checksum verification.
goto :verify_done
)
REM certutil outputs hash on the second line
set "ACTUAL_HASH="
set "LINE_NUM=0"
for /f "skip=1 tokens=*" %%H in (%TEMP%\dragonx_hash.tmp) do (
if not defined ACTUAL_HASH (
set "ACTUAL_HASH=%%H"
)
)
REM Remove spaces from certutil output
set "ACTUAL_HASH=!ACTUAL_HASH: =!"
del /f /q "%TEMP%\dragonx_hash.tmp" 2>nul
if /i "!ACTUAL_HASH!"=="!EXPECTED_HASH!" (
echo [INFO] SHA256 checksum verified.
) else (
echo [ERROR] SHA256 checksum verification failed! The download may be corrupted.
echo [ERROR] Expected: !EXPECTED_HASH!
echo [ERROR] Got: !ACTUAL_HASH!
popd
exit /b 1
)
:verify_done
REM Clean up checksum files
del /f /q "%BOOTSTRAP_FILE%.md5" 2>nul
del /f /q "%BOOTSTRAP_FILE%.sha256" 2>nul
popd
exit /b 0
REM ============================================
REM Download files from a given base URL
REM Usage: call :do_download "base_url"
REM ============================================
:do_download
set "BASE=%~1"
REM Use PowerShell to download (available on all modern Windows)
echo [INFO] Downloading %BASE%/%BOOTSTRAP_FILE% ...
powershell -NoProfile -Command ^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; try { (New-Object Net.WebClient).DownloadFile('%BASE%/%BOOTSTRAP_FILE%', '%DATADIR%\%BOOTSTRAP_FILE%') } catch { exit 1 }"
if errorlevel 1 exit /b 1
echo [INFO] Downloading checksums...
powershell -NoProfile -Command ^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; try { (New-Object Net.WebClient).DownloadFile('%BASE%/%BOOTSTRAP_FILE%.md5', '%DATADIR%\%BOOTSTRAP_FILE%.md5') } catch { exit 1 }"
if errorlevel 1 exit /b 1
powershell -NoProfile -Command ^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; try { (New-Object Net.WebClient).DownloadFile('%BASE%/%BOOTSTRAP_FILE%.sha256', '%DATADIR%\%BOOTSTRAP_FILE%.sha256') } catch { exit 1 }"
if errorlevel 1 exit /b 1
exit /b 0
REM ============================================
REM Extract bootstrap zip
REM ============================================
:extract_bootstrap
echo [INFO] Extracting bootstrap...
pushd "%DATADIR%"
REM Use PowerShell to extract zip, excluding wallet.dat and .conf files
powershell -NoProfile -Command ^
"Add-Type -AssemblyName System.IO.Compression.FileSystem; $zip = [System.IO.Compression.ZipFile]::OpenRead('%DATADIR%\%BOOTSTRAP_FILE%'); foreach ($entry in $zip.Entries) { if ($entry.Name -eq 'wallet.dat' -or $entry.Name -like '*.conf') { continue } $dest = Join-Path '%DATADIR%' $entry.FullName; if ($entry.FullName.EndsWith('/')) { New-Item -ItemType Directory -Force -Path $dest | Out-Null } else { $parent = Split-Path $dest -Parent; if (-not (Test-Path $parent)) { New-Item -ItemType Directory -Force -Path $parent | Out-Null } [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $dest, $true) } }; $zip.Dispose()"
if errorlevel 1 (
echo [ERROR] Extraction failed.
popd
exit /b 1
)
echo [INFO] Bootstrap extracted successfully.
REM Clean up archive
del /f /q "%BOOTSTRAP_FILE%" 2>nul
echo [INFO] Removed downloaded archive to save disk space.
popd
exit /b 0
:error_exit
echo.
echo [ERROR] Bootstrap installation failed.
exit /b 1

View File

@@ -9,6 +9,7 @@
set -euo pipefail set -euo pipefail
BOOTSTRAP_BASE_URL="https://bootstrap.dragonx.is" BOOTSTRAP_BASE_URL="https://bootstrap.dragonx.is"
BOOTSTRAP_FALLBACK_URL="https://bootstrap2.dragonx.is"
BOOTSTRAP_FILE="DRAGONX.zip" BOOTSTRAP_FILE="DRAGONX.zip"
CHAIN_NAME="DRAGONX" CHAIN_NAME="DRAGONX"
@@ -118,35 +119,49 @@ clean_chain_data() {
info "Blockchain data cleaned." info "Blockchain data cleaned."
} }
# Download a file via wget or curl # Download a file via wget or curl (returns non-zero on failure)
download_file() { download_file() {
local url="$1" local url="$1"
local outfile="$2" local outfile="$2"
if command -v wget &>/dev/null; then if command -v wget &>/dev/null; then
wget --progress=bar:force -O "$outfile" "$url" || error "Download failed: $url" wget --progress=bar:force -O "$outfile" "$url"
elif command -v curl &>/dev/null; then elif command -v curl &>/dev/null; then
curl -L --progress-bar -o "$outfile" "$url" || error "Download failed: $url" curl -L --progress-bar -o "$outfile" "$url"
else else
error "Neither wget nor curl found. Please install one and retry." error "Neither wget nor curl found. Please install one and retry."
fi fi
} }
# Try downloading from a given base URL; returns non-zero on failure
download_from() {
local base_url="$1"
local outfile="$DATADIR/$BOOTSTRAP_FILE"
local md5file="$DATADIR/${BOOTSTRAP_FILE}.md5"
local sha256file="$DATADIR/${BOOTSTRAP_FILE}.sha256"
info "Downloading bootstrap from $base_url ..."
info "This may take a while depending on your connection speed."
download_file "$base_url/$BOOTSTRAP_FILE" "$outfile" || return 1
info "Bootstrap download complete."
info "Downloading checksums..."
download_file "$base_url/${BOOTSTRAP_FILE}.md5" "$md5file" || return 1
download_file "$base_url/${BOOTSTRAP_FILE}.sha256" "$sha256file" || return 1
return 0
}
# Download the bootstrap and verify checksums # Download the bootstrap and verify checksums
download_bootstrap() { download_bootstrap() {
local outfile="$DATADIR/$BOOTSTRAP_FILE" local outfile="$DATADIR/$BOOTSTRAP_FILE"
local md5file="$DATADIR/${BOOTSTRAP_FILE}.md5" local md5file="$DATADIR/${BOOTSTRAP_FILE}.md5"
local sha256file="$DATADIR/${BOOTSTRAP_FILE}.sha256" local sha256file="$DATADIR/${BOOTSTRAP_FILE}.sha256"
info "Downloading bootstrap from $BOOTSTRAP_BASE_URL ..." if ! download_from "$BOOTSTRAP_BASE_URL"; then
info "This may take a while depending on your connection speed." warn "Primary download failed, trying fallback $BOOTSTRAP_FALLBACK_URL ..."
download_from "$BOOTSTRAP_FALLBACK_URL" || error "Download failed from both primary and fallback servers."
download_file "$BOOTSTRAP_BASE_URL/$BOOTSTRAP_FILE" "$outfile" fi
info "Bootstrap download complete."
info "Downloading checksums..."
download_file "$BOOTSTRAP_BASE_URL/${BOOTSTRAP_FILE}.md5" "$md5file"
download_file "$BOOTSTRAP_BASE_URL/${BOOTSTRAP_FILE}.sha256" "$sha256file"
# Verify checksums # Verify checksums
info "Verifying checksums..." info "Verifying checksums..."

View File

@@ -3,8 +3,8 @@
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
export CC=gcc-8 export CC=gcc-15
export CXX=g++-8 export CXX=g++-15
export LIBTOOL=libtool export LIBTOOL=libtool
export AR=ar export AR=ar
export RANLIB=ranlib export RANLIB=ranlib
@@ -34,16 +34,24 @@ fi
# If --enable-lcov is the first argument, enable lcov coverage support: # If --enable-lcov is the first argument, enable lcov coverage support:
LCOV_ARG='' LCOV_ARG=''
HARDENING_ARG='--disable-hardening' HARDENING_ARG='--disable-hardening'
TEST_ARG=''
if [ "x${1:-}" = 'x--enable-lcov' ] if [ "x${1:-}" = 'x--enable-lcov' ]
then then
LCOV_ARG='--enable-lcov' LCOV_ARG='--enable-lcov'
HARDENING_ARG='--disable-hardening' HARDENING_ARG='--disable-hardening'
shift shift
elif [ "x${1:-}" = 'x--disable-tests' ]
then
TEST_ARG='--enable-tests=no'
shift
fi fi
TRIPLET=`./depends/config.guess` TRIPLET=`./depends/config.guess`
PREFIX="$(pwd)/depends/$TRIPLET" PREFIX="$(pwd)/depends/$TRIPLET"
# Ensure system Rust is in PATH for modern macOS compatibility
export PATH="$HOME/.cargo/bin:$PATH"
make "$@" -C ./depends/ V=1 NO_QT=1 make "$@" -C ./depends/ V=1 NO_QT=1
#BUILD CCLIB #BUILD CCLIB
@@ -68,7 +76,7 @@ cd $WD
./autogen.sh ./autogen.sh
CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -Wl,-no_pie" \ CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -Wl,-no_pie" \
CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc\@8/8.3.0/include/c++/8.3.0/ -I$PREFIX/include -fwrapv -fno-strict-aliasing -Wno-builtin-declaration-mismatch -Werror -g -Wl,-undefined -Wl,dynamic_lookup' \ CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc/15.2.0_1/include/c++/15/ -I$PREFIX/include -fwrapv -fno-strict-aliasing -Wno-builtin-declaration-mismatch -Werror -Wno-error=deprecated-declarations -g -Wl,-undefined -Wl,dynamic_lookup' \
./configure --prefix="${PREFIX}" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG" ./configure --prefix="${PREFIX}" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG" $TEST_ARG
make "$@" V=1 NO_GTEST=1 STATIC=1 make "$@" V=1 NO_GTEST=1 STATIC=1