Files
Pay2Gateway/testPending.ts

28 lines
1.0 KiB
TypeScript

import { Client } from 'pg';
import { Connection, PublicKey } from '@solana/web3.js';
async function checkAllPending() {
const client = new Client({ connectionString: process.env.DATABASE_URL });
await client.connect();
const res = await client.query("SELECT * FROM transactions WHERE status = 'pending'");
console.log(`Found ${res.rows.length} pending transactions`);
const connection = new Connection('https://api.devnet.solana.com', 'confirmed');
for (const tx of res.rows) {
const wallets = tx.metadata?.wallets || {};
const solWallet = wallets['SOLANA'];
if (solWallet && solWallet.address) {
try {
const b = await connection.getBalance(new PublicKey(solWallet.address));
console.log(`TX ${tx.id} | Amount: ${tx.amount} TRY | Address: ${solWallet.address} | SOL Balance: ${b / 1e9}`);
} catch(e) {
console.log(`Error on TX ${tx.id}`);
}
}
}
await client.end();
}
checkAllPending().catch(console.error);