@echo off
setlocal

echo.
echo   Malairte Blockchain Node -- Windows Setup
echo.

if "%~1"=="" (
    set /p MINER_KEY="  Enter your miner private key (hex): "
) else (
    set MINER_KEY=%~1
)

if "%MINER_KEY%"=="" (
    echo Error: Miner key cannot be empty.
    pause
    exit /b 1
)

echo.
echo   Downloading setup script...
powershell -ExecutionPolicy Bypass -Command "Invoke-WebRequest -Uri 'https://explorer.malairtebitcoin.com/downloads/setup-windows.ps1' -OutFile '%TEMP%\malairte-setup.ps1'"

if not exist "%TEMP%\malairte-setup.ps1" (
    echo Error: Failed to download setup script. Check your internet connection.
    pause
    exit /b 1
)

powershell -ExecutionPolicy Bypass -File "%TEMP%\malairte-setup.ps1" -MinerKey %MINER_KEY%

del "%TEMP%\malairte-setup.ps1" >nul 2>&1
