54 lines
1.9 KiB
JavaScript
54 lines
1.9 KiB
JavaScript
|
|
const { Client } = require('pg');
|
|
const { Connection, PublicKey } = require('@solana/web3.js');
|
|
|
|
async function debugSolanaPayments() {
|
|
const client = new Client({ connectionString: process.env.DATABASE_URL });
|
|
await client.connect();
|
|
|
|
const connection = new Connection('https://api.devnet.solana.com', 'confirmed');
|
|
|
|
const res = await client.query(`
|
|
SELECT id, source_ref_id, amount, currency, metadata
|
|
FROM transactions
|
|
WHERE source_ref_id IN ('TEST_ORDER_999', 'TEST_ORDER_1000')
|
|
`);
|
|
|
|
console.log(`Found ${res.rows.length} transactions for debugging.\n`);
|
|
|
|
for (const tx of res.rows) {
|
|
const solAddr = tx.metadata?.wallets?.SOLANA?.address;
|
|
console.log(`TX: ${tx.id} | Ref: ${tx.source_ref_id}`);
|
|
console.log(`Amount: ${tx.amount} ${tx.currency}`);
|
|
|
|
if (!solAddr) {
|
|
console.log("❌ No Solana wallet found in metadata.");
|
|
continue;
|
|
}
|
|
|
|
console.log(`Wallet Address: ${solAddr}`);
|
|
|
|
try {
|
|
const pubKey = new PublicKey(solAddr);
|
|
const balance = await connection.getBalance(pubKey);
|
|
console.log(`Balance: ${balance / 1e9} SOL`);
|
|
|
|
// Also check common tokens
|
|
const USDT_MINT = 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'; // Placeholder for USDT on mainnet/devnet logic
|
|
// Since this is a check, let's just see transactions on that address
|
|
const signatures = await connection.getSignaturesForAddress(pubKey);
|
|
console.log(`Recent Activity: ${signatures.length} signatures found.`);
|
|
if (signatures.length > 0) {
|
|
console.log(`Latest Sig: ${signatures[0].signature}`);
|
|
}
|
|
} catch (err) {
|
|
console.error(`Error checking address: ${err.message}`);
|
|
}
|
|
console.log("-" . repeat(40));
|
|
}
|
|
|
|
await client.end();
|
|
}
|
|
|
|
debugSolanaPayments();
|