44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
const { Client } = require('pg');
|
|
const { Connection, PublicKey } = require('@solana/web3.js');
|
|
|
|
async function debugLatest() {
|
|
const client = new Client({ connectionString: process.env.DATABASE_URL });
|
|
await client.connect();
|
|
|
|
const res = await client.query(`
|
|
SELECT id, source_ref_id, amount, currency, metadata, status, created_at
|
|
FROM transactions
|
|
ORDER BY created_at DESC LIMIT 5
|
|
`);
|
|
|
|
console.log("=== LAST 5 TRANSACTIONS ===");
|
|
|
|
for (const tx of res.rows) {
|
|
console.log(`\n--- TX: ${tx.id} ---`);
|
|
console.log(`Status: ${tx.status} | Amount: ${tx.amount} ${tx.currency} | Created: ${tx.created_at}`);
|
|
|
|
const wallets = tx.metadata?.wallets || {};
|
|
const solWallet = wallets['SOLANA'];
|
|
|
|
if (solWallet) {
|
|
console.log(`Checking SOL Address: ${solWallet.address}`);
|
|
try {
|
|
const connection = new Connection('https://api.devnet.solana.com', 'confirmed');
|
|
const pubKey = new PublicKey(solWallet.address);
|
|
const balance = await connection.getBalance(pubKey);
|
|
console.log(`Devnet Balance: ${balance / 1e9} SOL`);
|
|
|
|
const connectionMain = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');
|
|
const balanceMain = await connectionMain.getBalance(pubKey);
|
|
console.log(`Mainnet Balance: ${balanceMain / 1e9} SOL`);
|
|
} catch(e) {
|
|
console.log("Error fetching balance:", e.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
await client.end();
|
|
}
|
|
|
|
debugLatest().catch(console.error);
|