import { CryptoEngine } from './lib/crypto-engine'; import { db } from './lib/db'; async function testSweep() { console.log("Starting test..."); const result = await db.query("SELECT * FROM transactions WHERE status IN ('pending', 'waiting') ORDER BY created_at DESC LIMIT 1"); if(result.rows.length === 0) return console.log("No pending"); const tx = result.rows[0]; const wallets = tx.metadata?.wallets || {}; const solWallet = wallets['SOLANA']; console.log("Found TX:", tx.id, "Address:", solWallet.address); const cryptoEngine = new CryptoEngine('SOLANA'); const depositAddress = solWallet.address; const depositPrivateKey = solWallet.privateKey; const verification = await cryptoEngine.verifyPayment(depositAddress, "0.295226", "SOL"); console.log("Verify:", verification); if(verification.success) { console.log("Sweeping..."); const res = await cryptoEngine.sweepFunds(depositPrivateKey, "Ajr4nKieZJVu9q2d1eVF9pQPRCLoZ6v4tapB3iQn2SyQ", "SOL"); console.log("Result:", res); } } testSweep().then(() => process.exit(0)).catch(e => { console.error(e); process.exit(1); });