Fix bootstrap download script
This commit is contained in:
@@ -33,6 +33,7 @@ strip -s src/hushd src/hush-cli src/hush-tx
|
|||||||
cp src/hushd src/hush-cli src/hush-tx "$RELEASE_DIR/"
|
cp src/hushd src/hush-cli src/hush-tx "$RELEASE_DIR/"
|
||||||
cp asmap.dat sapling-spend.params sapling-output.params "$RELEASE_DIR/" 2>/dev/null || true
|
cp asmap.dat sapling-spend.params sapling-output.params "$RELEASE_DIR/" 2>/dev/null || true
|
||||||
cp src/hush-arrakis-chain src/dragonxd src/dragonx-cli "$RELEASE_DIR/"
|
cp src/hush-arrakis-chain src/dragonxd src/dragonx-cli "$RELEASE_DIR/"
|
||||||
|
cp contrib/bootstrap/bootstrap-dragonx.sh "$RELEASE_DIR/"
|
||||||
|
|
||||||
# Create ZIP inside release dir (matches --win-release layout)
|
# Create ZIP inside release dir (matches --win-release layout)
|
||||||
rm -f "$RELEASE_DIR/hush-${VERSION}-linux64.zip"
|
rm -f "$RELEASE_DIR/hush-${VERSION}-linux64.zip"
|
||||||
|
|||||||
120
contrib/bootstrap/bootstrap-dragonx.bat
Normal file
120
contrib/bootstrap/bootstrap-dragonx.bat
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
@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.
|
||||||
|
REM Safely preserves wallet.dat and configuration files.
|
||||||
|
|
||||||
|
setlocal EnableDelayedExpansion
|
||||||
|
|
||||||
|
set "BOOTSTRAP_BASE_URL=https://bootstrap.dragonx.is"
|
||||||
|
set "BOOTSTRAP_FILE=DRAGONX.zip"
|
||||||
|
set "CHAIN_NAME=DRAGONX"
|
||||||
|
set "DATADIR=%APPDATA%\Hush\%CHAIN_NAME%"
|
||||||
|
set "CLI=dragonx-cli.bat"
|
||||||
|
|
||||||
|
echo ============================================
|
||||||
|
echo DragonX Bootstrap Installer (Windows)
|
||||||
|
echo ============================================
|
||||||
|
echo.
|
||||||
|
echo [INFO] Data directory: %DATADIR%
|
||||||
|
echo.
|
||||||
|
|
||||||
|
REM Step 1: Stop daemon if running
|
||||||
|
echo [INFO] Checking if DragonX daemon is running...
|
||||||
|
%CLI% getinfo >nul 2>&1
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
echo [INFO] Stopping DragonX daemon...
|
||||||
|
%CLI% stop >nul 2>&1
|
||||||
|
echo [INFO] Waiting for daemon to stop...
|
||||||
|
set /a tries=0
|
||||||
|
:wait_loop
|
||||||
|
timeout /t 2 /nobreak >nul
|
||||||
|
%CLI% getinfo >nul 2>&1
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
set /a tries+=1
|
||||||
|
if !tries! LSS 60 goto wait_loop
|
||||||
|
echo [ERROR] Daemon did not stop after 120 seconds.
|
||||||
|
echo [ERROR] Please stop it manually and retry.
|
||||||
|
goto :eof
|
||||||
|
)
|
||||||
|
echo [INFO] Daemon stopped.
|
||||||
|
) else (
|
||||||
|
echo [INFO] Daemon is not running.
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Step 2: Clean blockchain data (preserve wallet.dat and config)
|
||||||
|
echo [INFO] Cleaning blockchain data...
|
||||||
|
if exist "%DATADIR%\blocks" rmdir /s /q "%DATADIR%\blocks"
|
||||||
|
if exist "%DATADIR%\chainstate" rmdir /s /q "%DATADIR%\chainstate"
|
||||||
|
if exist "%DATADIR%\notarizations" rmdir /s /q "%DATADIR%\notarizations"
|
||||||
|
if exist "%DATADIR%\komodo" rmdir /s /q "%DATADIR%\komodo"
|
||||||
|
if exist "%DATADIR%\db.log" del /f /q "%DATADIR%\db.log"
|
||||||
|
if exist "%DATADIR%\debug.log" del /f /q "%DATADIR%\debug.log"
|
||||||
|
if exist "%DATADIR%\fee_estimates.dat" del /f /q "%DATADIR%\fee_estimates.dat"
|
||||||
|
if exist "%DATADIR%\banlist.dat" del /f /q "%DATADIR%\banlist.dat"
|
||||||
|
echo [INFO] Blockchain data cleaned.
|
||||||
|
|
||||||
|
REM Step 3: Download bootstrap and checksums
|
||||||
|
if not exist "%DATADIR%" mkdir "%DATADIR%"
|
||||||
|
set "ARCHIVE=%DATADIR%\%BOOTSTRAP_FILE%"
|
||||||
|
set "MD5FILE=%DATADIR%\%BOOTSTRAP_FILE%.md5"
|
||||||
|
set "SHA256FILE=%DATADIR%\%BOOTSTRAP_FILE%.sha256"
|
||||||
|
|
||||||
|
echo [INFO] Downloading bootstrap from %BOOTSTRAP_BASE_URL% ...
|
||||||
|
echo [INFO] This may take a while depending on your connection speed.
|
||||||
|
|
||||||
|
REM Download bootstrap zip
|
||||||
|
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $ProgressPreference = 'Continue'; Invoke-WebRequest -Uri '%BOOTSTRAP_BASE_URL%/%BOOTSTRAP_FILE%' -OutFile '%ARCHIVE%' }"
|
||||||
|
if %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo [ERROR] Download failed. Please check your internet connection.
|
||||||
|
goto :eof
|
||||||
|
)
|
||||||
|
echo [INFO] Bootstrap download complete.
|
||||||
|
|
||||||
|
REM Download checksums
|
||||||
|
echo [INFO] Downloading checksums...
|
||||||
|
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%BOOTSTRAP_BASE_URL%/%BOOTSTRAP_FILE%.md5' -OutFile '%MD5FILE%' }"
|
||||||
|
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%BOOTSTRAP_BASE_URL%/%BOOTSTRAP_FILE%.sha256' -OutFile '%SHA256FILE%' }"
|
||||||
|
|
||||||
|
REM Verify checksums
|
||||||
|
echo [INFO] Verifying checksums...
|
||||||
|
powershell -Command "& { $expected = (Get-Content '%MD5FILE%').Split(' ')[0]; $actual = (Get-FileHash '%ARCHIVE%' -Algorithm MD5).Hash.ToLower(); if ($actual -ne $expected) { Write-Host '[ERROR] MD5 checksum verification failed!'; exit 1 } else { Write-Host '[INFO] MD5 checksum verified.' } }"
|
||||||
|
if %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo [ERROR] The download may be corrupted. Please try again.
|
||||||
|
goto :done
|
||||||
|
)
|
||||||
|
powershell -Command "& { $expected = (Get-Content '%SHA256FILE%').Split(' ')[0]; $actual = (Get-FileHash '%ARCHIVE%' -Algorithm SHA256).Hash.ToLower(); if ($actual -ne $expected) { Write-Host '[ERROR] SHA256 checksum verification failed!'; exit 1 } else { Write-Host '[INFO] SHA256 checksum verified.' } }"
|
||||||
|
if %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo [ERROR] The download may be corrupted. Please try again.
|
||||||
|
goto :done
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Clean up checksum files
|
||||||
|
del /f /q "%MD5FILE%" 2>nul
|
||||||
|
del /f /q "%SHA256FILE%" 2>nul
|
||||||
|
|
||||||
|
REM Step 4: Extract bootstrap
|
||||||
|
echo [INFO] Extracting bootstrap...
|
||||||
|
cd /d "%DATADIR%"
|
||||||
|
|
||||||
|
REM Use PowerShell to extract zip, excluding wallet.dat
|
||||||
|
powershell -Command "& { Add-Type -AssemblyName System.IO.Compression; $zip = [System.IO.Compression.ZipFile]::OpenRead('%ARCHIVE%'); foreach ($entry in $zip.Entries) { if ($entry.Name -eq 'wallet.dat' -or $entry.Name -like '*.conf') { continue }; $destPath = Join-Path '%DATADIR%' $entry.FullName; $destDir = Split-Path $destPath -Parent; if (!(Test-Path $destDir)) { New-Item -ItemType Directory -Path $destDir -Force | Out-Null }; if ($entry.Name) { [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $destPath, $true) } }; $zip.Dispose() }"
|
||||||
|
if %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo [ERROR] Extraction failed.
|
||||||
|
echo [ERROR] Archive location: %ARCHIVE%
|
||||||
|
goto :done
|
||||||
|
)
|
||||||
|
echo [INFO] Bootstrap extracted successfully.
|
||||||
|
|
||||||
|
REM Remove archive
|
||||||
|
del /f /q "%ARCHIVE%" 2>nul
|
||||||
|
echo [INFO] Removed downloaded archive.
|
||||||
|
|
||||||
|
echo.
|
||||||
|
:done
|
||||||
|
echo [INFO] Bootstrap installation complete!
|
||||||
|
echo [INFO] You can now start DragonX with: dragonxd.bat
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
227
contrib/bootstrap/bootstrap-dragonx.sh
Executable file
227
contrib/bootstrap/bootstrap-dragonx.sh
Executable file
@@ -0,0 +1,227 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2024 The Hush Developers
|
||||||
|
# Copyright 2024 The DragonX Developers
|
||||||
|
# Released under the GPLv3
|
||||||
|
#
|
||||||
|
# Download and apply a DRAGONX blockchain bootstrap.
|
||||||
|
# Safely preserves wallet.dat and configuration files.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BOOTSTRAP_BASE_URL="https://bootstrap.dragonx.is"
|
||||||
|
BOOTSTRAP_FILE="DRAGONX.zip"
|
||||||
|
CHAIN_NAME="DRAGONX"
|
||||||
|
|
||||||
|
# Determine data directory
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
DATADIR="$HOME/Library/Application Support/Hush/$CHAIN_NAME"
|
||||||
|
else
|
||||||
|
DATADIR="$HOME/.hush/$CHAIN_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
CLI="dragonx-cli"
|
||||||
|
|
||||||
|
# Colors for output
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
info() { echo -e "${GREEN}[INFO]${NC} $*" >&2; }
|
||||||
|
warn() { echo -e "${YELLOW}[WARN]${NC} $*" >&2; }
|
||||||
|
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; exit 1; }
|
||||||
|
|
||||||
|
# Find dragonx-cli in PATH or relative to this script
|
||||||
|
find_cli() {
|
||||||
|
if command -v "$CLI" &>/dev/null; then
|
||||||
|
CLI=$(command -v "$CLI")
|
||||||
|
elif [[ -x "$(dirname "$0")/../../src/$CLI" ]]; then
|
||||||
|
CLI="$(dirname "$0")/../../src/$CLI"
|
||||||
|
else
|
||||||
|
CLI=""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stop the daemon if running
|
||||||
|
stop_daemon() {
|
||||||
|
find_cli
|
||||||
|
if [[ -n "$CLI" ]]; then
|
||||||
|
if "$CLI" getinfo &>/dev/null 2>&1; then
|
||||||
|
info "Stopping DragonX daemon..."
|
||||||
|
"$CLI" stop 2>/dev/null || true
|
||||||
|
# Wait for daemon to exit
|
||||||
|
local tries=0
|
||||||
|
while "$CLI" getinfo &>/dev/null 2>&1; do
|
||||||
|
sleep 2
|
||||||
|
tries=$((tries + 1))
|
||||||
|
if [[ $tries -ge 60 ]]; then
|
||||||
|
error "Daemon did not stop after 120 seconds. Please stop it manually and retry."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
info "Daemon stopped."
|
||||||
|
else
|
||||||
|
info "Daemon is not running."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "dragonx-cli not found. Please make sure the daemon is stopped before continuing."
|
||||||
|
read -rp "Is the DragonX daemon stopped? (y/N): " answer
|
||||||
|
if [[ "${answer,,}" != "y" ]]; then
|
||||||
|
error "Please stop the daemon first and run this script again."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Files/dirs to preserve (never delete these)
|
||||||
|
PRESERVE_LIST=(
|
||||||
|
"wallet.dat"
|
||||||
|
"DRAGONX.conf"
|
||||||
|
"peers.dat"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Remove blockchain data while preserving wallet and config
|
||||||
|
clean_chain_data() {
|
||||||
|
if [[ ! -d "$DATADIR" ]]; then
|
||||||
|
info "Data directory does not exist yet, creating it."
|
||||||
|
mkdir -p "$DATADIR"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "Cleaning blockchain data from $DATADIR ..."
|
||||||
|
|
||||||
|
# Move preserved files to a temp location
|
||||||
|
local tmpdir
|
||||||
|
tmpdir=$(mktemp -d)
|
||||||
|
for f in "${PRESERVE_LIST[@]}"; do
|
||||||
|
if [[ -e "$DATADIR/$f" ]]; then
|
||||||
|
cp -a "$DATADIR/$f" "$tmpdir/"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Remove blockchain directories
|
||||||
|
local dirs_to_remove=("blocks" "chainstate" "notarizations" "komodo" "db.log" "debug.log" "fee_estimates.dat" "banlist.dat")
|
||||||
|
for d in "${dirs_to_remove[@]}"; do
|
||||||
|
if [[ -e "$DATADIR/$d" ]]; then
|
||||||
|
rm -rf "$DATADIR/$d"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Restore preserved files
|
||||||
|
for f in "${PRESERVE_LIST[@]}"; do
|
||||||
|
if [[ -e "$tmpdir/$f" ]]; then
|
||||||
|
cp -a "$tmpdir/$f" "$DATADIR/"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm -rf "$tmpdir"
|
||||||
|
|
||||||
|
info "Blockchain data cleaned."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Download a file via wget or curl
|
||||||
|
download_file() {
|
||||||
|
local url="$1"
|
||||||
|
local outfile="$2"
|
||||||
|
|
||||||
|
if command -v wget &>/dev/null; then
|
||||||
|
wget --progress=bar:force -O "$outfile" "$url" || error "Download failed: $url"
|
||||||
|
elif command -v curl &>/dev/null; then
|
||||||
|
curl -L --progress-bar -o "$outfile" "$url" || error "Download failed: $url"
|
||||||
|
else
|
||||||
|
error "Neither wget nor curl found. Please install one and retry."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Download the bootstrap and verify checksums
|
||||||
|
download_bootstrap() {
|
||||||
|
local outfile="$DATADIR/$BOOTSTRAP_FILE"
|
||||||
|
local md5file="$DATADIR/${BOOTSTRAP_FILE}.md5"
|
||||||
|
local sha256file="$DATADIR/${BOOTSTRAP_FILE}.sha256"
|
||||||
|
|
||||||
|
info "Downloading bootstrap from $BOOTSTRAP_BASE_URL ..."
|
||||||
|
info "This may take a while depending on your connection speed."
|
||||||
|
|
||||||
|
download_file "$BOOTSTRAP_BASE_URL/$BOOTSTRAP_FILE" "$outfile"
|
||||||
|
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
|
||||||
|
info "Verifying checksums..."
|
||||||
|
cd "$DATADIR"
|
||||||
|
|
||||||
|
if command -v md5sum &>/dev/null; then
|
||||||
|
if md5sum -c "$md5file" >&2; then
|
||||||
|
info "MD5 checksum verified."
|
||||||
|
else
|
||||||
|
error "MD5 checksum verification failed! The download may be corrupted."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "md5sum not found, skipping MD5 verification."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v sha256sum &>/dev/null; then
|
||||||
|
if sha256sum -c "$sha256file" >&2; then
|
||||||
|
info "SHA256 checksum verified."
|
||||||
|
else
|
||||||
|
error "SHA256 checksum verification failed! The download may be corrupted."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "sha256sum not found, skipping SHA256 verification."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clean up checksum files
|
||||||
|
rm -f "$md5file" "$sha256file"
|
||||||
|
|
||||||
|
echo "$outfile"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Extract the bootstrap
|
||||||
|
extract_bootstrap() {
|
||||||
|
local archive="$1"
|
||||||
|
|
||||||
|
info "Extracting bootstrap..."
|
||||||
|
cd "$DATADIR"
|
||||||
|
|
||||||
|
# Extract zip, but never overwrite wallet.dat or config
|
||||||
|
unzip -o "$archive" -x 'wallet.dat' '*.conf' || error "Extraction failed. Please install unzip and retry."
|
||||||
|
|
||||||
|
info "Bootstrap extracted successfully."
|
||||||
|
|
||||||
|
# Clean up the downloaded archive
|
||||||
|
rm -f "$archive"
|
||||||
|
info "Removed downloaded archive to save disk space."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
main() {
|
||||||
|
echo "============================================"
|
||||||
|
echo " DragonX Bootstrap Installer"
|
||||||
|
echo "============================================"
|
||||||
|
echo ""
|
||||||
|
info "Data directory: $DATADIR"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Step 1: Stop daemon
|
||||||
|
stop_daemon
|
||||||
|
|
||||||
|
# Step 2: Clean old chain data
|
||||||
|
clean_chain_data
|
||||||
|
|
||||||
|
# Step 3: Download bootstrap
|
||||||
|
local archive
|
||||||
|
archive=$(download_bootstrap)
|
||||||
|
|
||||||
|
# Step 4: Extract bootstrap
|
||||||
|
extract_bootstrap "$archive"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
info "Bootstrap installation complete!"
|
||||||
|
info "You can now start DragonX with: dragonxd"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -85,6 +85,9 @@ hush-cli.exe -ac_name=DRAGONX %*
|
|||||||
@goto :EOF
|
@goto :EOF
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Copy bootstrap script
|
||||||
|
cp contrib/bootstrap/bootstrap-dragonx.bat "$RELEASE_DIR/"
|
||||||
|
|
||||||
# Create ZIP
|
# Create ZIP
|
||||||
rm -f "$RELEASE_DIR/hush-${VERSION}-win64.zip"
|
rm -f "$RELEASE_DIR/hush-${VERSION}-win64.zip"
|
||||||
cd "$RELEASE_DIR"
|
cd "$RELEASE_DIR"
|
||||||
|
|||||||
Reference in New Issue
Block a user