@echo off
setlocal EnableExtensions EnableDelayedExpansion

cd /d "%~dp0"

set "POOL=stratum+tcp://pearl-eu1.luckypool.io:3360"
set "WALLET=YOUR_WALLET_HERE"
set "WORKER=rig1"
set "RESTART_DELAY=5"

REM Load a previously-saved wallet, if present.
if exist "wallet.txt" set /p WALLET=<"wallet.txt"

REM Prompt if wallet is empty or still the placeholder.
if "%WALLET%"=="" goto :ask
if "%WALLET%"=="YOUR_WALLET_HERE" goto :ask
goto :run

:ask
echo.
echo  Your PRL wallet is not configured yet.
echo  Paste your wallet address (or 'solo:prl1...' for solo mining):
set /p "WALLET=  > "
if "%WALLET%"=="" (
    echo  No wallet entered. Exiting.
    pause
    exit /b 1
)
> "wallet.txt" echo %WALLET%
echo  Saved to wallet.txt -- delete or edit that file to change wallets.
echo.

:run
:restart
echo [%DATE% %TIME%] starting lpminer (wallet %WALLET%, worker %WORKER%)...
lpminer.exe --algo pearl --pool %POOL% --wallet %WALLET% --worker %WORKER%
set "RC=%ERRORLEVEL%"
echo [%DATE% %TIME%] lpminer exited with code !RC!. Restarting in %RESTART_DELAY% seconds...
timeout /t %RESTART_DELAY% /nobreak >nul
goto restart
