-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_env.js
More file actions
94 lines (78 loc) · 3.2 KB
/
Copy pathdebug_env.js
File metadata and controls
94 lines (78 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require('dotenv').config();
const { Client } = require('ssh2');
const fs = require('fs');
const path = require('path');
function sshExec(conn, cmd, timeout = 60000) {
return new Promise((resolve) => {
const timer = setTimeout(() => resolve('[TIMEOUT]'), timeout);
conn.exec(cmd, (err, stream) => {
if (err) { clearTimeout(timer); return resolve('ERROR: ' + err.message); }
let out = '';
stream.on('data', d => { out += d.toString(); process.stdout.write(d); });
stream.stderr.on('data', d => { out += d.toString(); process.stderr.write(d); });
stream.on('close', () => { clearTimeout(timer); resolve(out.trim()); });
});
});
}
function sftpUpload(conn, localPath, remotePath) {
return new Promise((resolve, reject) => {
conn.sftp((err, sftp) => {
if (err) return reject(err);
sftp.fastPut(localPath, remotePath, (err) => {
if (err) return reject(err);
resolve();
});
});
});
}
async function run() {
const conn = new Client();
const host = process.env.PI_HOST || '192.168.1.78';
const port = parseInt(process.env.PI_PORT || '22', 10);
const username = process.env.PI_USER || 'ed';
const password = process.env.PI_PASSWORD;
if (!password) {
console.error('❌ Error: PI_PASSWORD environment variable is not set.');
process.exit(1);
}
conn.on('ready', async () => {
console.log('✅ Connected to Pi 5\n');
// Test using the MarginFi SDK directly
const testScript = `
const { Connection, PublicKey } = require('@solana/web3.js');
const RPC = 'https://mainnet.helius-rpc.com/?api-key=0629a755-e1c9-442a-8a19-02f9b7c04e3d';
const conn = new Connection(RPC, 'confirmed');
const MARGINFI = new PublicKey('MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA');
async function test() {
console.log('RPC:', RPC.replace(/api-key=.*/, 'api-key=***'));
// Try different common account sizes for MarginFi v2
const sizes = [1856, 2048, 2560, 2656, 3232, 3296, 3360, 1544, 752, 512, 376, 288, 264, 248, 200, 176, 168, 160, 136];
for (const size of sizes) {
try {
const accounts = await conn.getProgramAccounts(MARGINFI, {
dataSlice: { offset: 0, length: 8 },
filters: [{ dataSize: size }],
});
if (accounts.length > 0) {
console.log('SIZE', size, '-> Found', accounts.length, 'accounts ✅');
}
} catch(e) {
// ignore errors, just scanning
}
}
console.log('\\nDone scanning.');
}
test();
`;
const tmpPath = path.join(__dirname, '_tmp_test3.js');
fs.writeFileSync(tmpPath, testScript);
await sftpUpload(conn, tmpPath, '/home/ed/radar/test_marginfi3.js');
fs.unlinkSync(tmpPath);
console.log('🧪 Scanning for MarginFi account sizes on Helius...');
await sshExec(conn, 'cd /home/ed/radar && node test_marginfi3.js', 90000);
conn.end();
});
conn.on('error', (err) => console.error('❌ SSH Error:', err.message));
conn.connect({ host, port, username, password, readyTimeout: 10000 });
}
run();