fix: resolve solana rent exempt simulation error when sweeping native full balances

This commit is contained in:
mstfyldz
2026-03-14 00:49:48 +03:00
parent 2de17043ca
commit a90b1707bb
4 changed files with 159 additions and 2 deletions

29
test_sweep_native.ts Normal file
View File

@@ -0,0 +1,29 @@
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); });