@echo off powershell -NoProfile -ExecutionPolicy Bypass -Command "Get-Content -LiteralPath '%~f0' | Select-Object -Skip 3 | Out-String | Invoke-Expression" exit /b $RpcUser = "memcoin" $RpcPassword = "memcoinrpc" $RpcPort = 9332 $NodeZipUrl = "https://github.com/RouteToCoast/memcoin/releases/download/v1.0.0/memcoin-v1.0.0-win64.zip" $BaseDir = "$env:USERPROFILE\Memcoin" $NodeDir = "$BaseDir\node" $ConfigDir = "$env:APPDATA\Memcoin" $ConfigFile = "$ConfigDir\memcoin.conf" $ErrorActionPreference = "Stop" Write-Host "==== Downloading Memcoin node ====" -ForegroundColor Cyan New-Item -ItemType Directory -Force -Path $NodeDir | Out-Null $zipPath = Join-Path $NodeDir "memcoin-v1.0.0-win64.zip" if (-not (Test-Path $zipPath)) { Invoke-WebRequest -Uri $NodeZipUrl -OutFile $zipPath -UseBasicParsing } Expand-Archive -Path $zipPath -DestinationPath $NodeDir -Force $nodeExe = Get-ChildItem -Path $NodeDir -Filter "memcoind.exe" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 if (-not $nodeExe) { Write-Host "memcoind.exe not found in the extracted folder." -ForegroundColor Red exit 1 } Write-Host "==== Writing config file ====" -ForegroundColor Cyan New-Item -ItemType Directory -Force -Path $ConfigDir | Out-Null @" rpcuser=$RpcUser rpcpassword=$RpcPassword listen=1 mempoolminvalue=100000 addnode=8.229.76.9:9333 addnode=34.133.1.193:9333 "@ | Out-File -Encoding ascii $ConfigFile -Force Write-Host "==== Starting node ====" -ForegroundColor Cyan $nodeDirPath = $nodeExe.DirectoryName Start-Process powershell -ArgumentList @( "-NoExit", "-Command", "cd '$nodeDirPath'; .\$($nodeExe.Name)" ) Write-Host "Waiting for sync (up to 20 min)..." $rpcUri = "http://127.0.0.1:$RpcPort/" $authHeader = @{ Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$RpcUser`:$RpcPassword")) } $body = '{"jsonrpc":"1.0","id":"setup","method":"getblockchaininfo","params":[]}' $elapsed = 0 Start-Sleep -Seconds 5 while ($elapsed -lt 1200) { try { $resp = Invoke-RestMethod -Uri $rpcUri -Method Post -Headers $authHeader -Body $body -ContentType "application/json" -TimeoutSec 5 Write-Host " block $($resp.result.blocks) syncing: $($resp.result.initialblockdownload)" if ($resp.result.initialblockdownload -eq $false) { break } } catch { Write-Host " node not ready yet... ($elapsed s)" } Start-Sleep -Seconds 10 $elapsed += 10 } Write-Host "Node setup complete. Keep the node window open to keep it running." -ForegroundColor Green