SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "telex.js")
31 STORE("descrHdr", "TELEX terminal interface")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "explorer.tela")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "1d475579a3f4c6261cdc2671ccedf678015234ea4466332a0656e8acf0055d87")
37 STORE("fileCheckS", "170a456bfe6968948196f6eb92e83f1f4513c5a54bd9af5390af0c94c068ce60")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
({
name:'telex',version:'1.0.0',isVisible:!1,xswdModalVisible:!1,dataInitialized:!1,connectionStartTime:null,apiRequestCount:0,externalRequestsBlocked:0,connectionEndpoint:'',actualXswdEndpoint:'',
init(){this.connectionStartTime=Date.now();this.createXSWDTerminalModal();this.startMetricsTracking()},
createXSWDTerminalModal(){const m=document.createElement('div');m.id='xswd-terminal-modal';m.style.cssText='display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.98);z-index:1001;backdrop-filter:blur(15px)';
m.innerHTML='<div style="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background:#000000;border:2px solid #00ff41;border-radius:0;width:95%;max-width:1300px;height:92vh;overflow:hidden;box-shadow:0 0 40px rgba(0,255,65,0.4),inset 0 0 0 1px rgba(0,255,65,0.1);font-family:\'Courier New\',Consolas,\'Lucida Console\',Monaco,monospace"><div style="background:#001100;border-bottom:2px solid #00ff41;padding:1rem;display:flex;justify-content:space-between;align-items:center;box-shadow:0 2px 10px rgba(0,255,65,0.2)"><div style="display:flex;align-items:center;gap:15px"><div style="color:#00ff41;font-size:1.3rem;font-weight:bold;text-shadow:0 0 10px #00ff41">T E L E X</div><div style="color:#009900;font-size:0.9rem">TELA Explorer v1.0</div></div><button onclick="window.telex.hideXSWDTerminal()" style="background:#000;border:1px solid #00ff41;color:#00ff41;padding:6px 12px;border-radius:0;cursor:pointer;font-family:monospace;text-shadow:0 0 5px #00ff41;transition:all 0.2s">[ CLOSE ]</button></div><div style="height:calc(100% - 120px);overflow-y:auto;padding:1rem;background:#000000"><div style="color:#00ff41;margin-bottom:1.5rem;font-size:0.9rem;line-height:1.3;text-shadow:0 0 3px #00ff41">> TELEX Protocol Analysis - Real-time DERO blockchain data<br/>> Demonstrating decentralized application power<br/>> All data flows directly from your DERO node<br/><span style="color:#666;animation:blink 1s infinite">_</span></div><div style="margin-bottom:2rem;padding:1rem;background:#001100;border:1px solid #00ff41;border-radius:0;box-shadow:0 0 15px rgba(0,255,65,0.2)"><div style="color:#00ff41;margin-bottom:1rem;font-weight:bold;text-shadow:0 0 5px #00ff41">[ API COMMANDS ] - Click to append data below</div><div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px"><button onclick="window.telex.runXSWDCommand(\'getinfo\')" style="background:#000;border:1px solid #00ff41;color:#00ff41;padding:8px 12px;border-radius:0;cursor:pointer;font-family:monospace;font-size:0.8rem;text-shadow:0 0 3px #00ff41;transition:all 0.2s">DERO.GetInfo</button><button onclick="window.telex.runXSWDCommand(\'getlastblock\')" style="background:#000;border:1px solid #00ff41;color:#00ff41;padding:8px 12px;border-radius:0;cursor:pointer;font-family:monospace;font-size:0.8rem;text-shadow:0 0 3px #00ff41;transition:all 0.2s">GetLastBlock</button><button onclick="window.telex.runXSWDCommand(\'gettxpool\')" style="background:#000;border:1px solid #00ff41;color:#00ff41;padding:8px 12px;border-radius:0;cursor:pointer;font-family:monospace;font-size:0.8rem;text-shadow:0 0 3px #00ff41;transition:all 0.2s">GetTxPool</button><button onclick="window.telex.runXSWDCommand(\'getpoolstats\')" style="background:#000;border:1px solid #00ff41;color:#00ff41;padding:8px 12px;border-radius:0;cursor:pointer;font-family:monospace;font-size:0.8rem;text-shadow:0 0 3px #00ff41;transition:all 0.2s">Enhanced Pool</button><button onclick="window.telex.runXSWDCommand(\'comprehensive\')" style="background:#001100;border:1px solid #b73019;color:#b73019;padding:8px 12px;border-radius:0;cursor:pointer;font-family:monospace;font-size:0.8rem;text-shadow:0 0 3px #b73019;transition:all 0.2s">Full Analysis</button></div></div><div id="xswd-terminal-output" style="color:#00ff41;font-size:0.82rem;line-height:1.3;white-space:pre-wrap;word-wrap:break-word;text-shadow:0 0 2px #00ff41;min-height:400px"></div></div><div style="background:#001100;border-top:1px solid #00ff41;padding:0.5rem 1rem;color:#009900;font-size:0.8rem;display:flex;justify-content:space-between;box-shadow:0 -2px 10px rgba(0,255,65,0.1)"><span>TELEX Protocol | TELA Explorer v1.0 | Direct Blockchain Connection</span><span id="xswd-terminal-status" style="color:#00ff41;text-shadow:0 0 3px #00ff41">Initializing...</span></div></div><style>@keyframes blink{0%,50%{opacity:1}51%,100%{opacity:0}}button:hover{box-shadow:0 0 10px currentColor!important;transform:scale(1.02)}</style>';
document.body.appendChild(m)},
showXSWDTerminal(){const m=document.getElementById('xswd-terminal-modal');if(m){this.xswdModalVisible=!0;m.style.display='block';if(!this.dataInitialized){this.loadInitialTerminalData();this.dataInitialized=!0}}},
hideXSWDTerminal(){const m=document.getElementById('xswd-terminal-modal');if(m){this.isVisible=!1;this.xswdModalVisible=!1;m.style.display='none'}},
addTerminalMessage(msg,isCmd=!1){const o=document.getElementById('xswd-terminal-output');if(o){const ts=new Date().toLocaleTimeString();const pfx=isCmd?`[${ts}] > `:'';o.textContent+=`${pfx}${msg}\n`;o.scrollTop=o.scrollHeight}},
async loadInitialTerminalData(){this.updateTerminalStatus('Loading Cypherpunk dashboard...');
const o=document.getElementById('xswd-terminal-output');if(!o)return;
o.textContent='';await this.typewriterEffect(o,'================================================================\n║ ║\n║ T E L E X ║\n║ ║\n║ ╔═══════════════════════════════╗ ║\n║ ║ TELA EXPLORER v1.0 ║ ║\n║ ║ Decentralized Interface ║ ║\n║ ╚═══════════════════════════════╝ ║\n║ ║\n================================================================\n\n> TELEX PROTOCOL INITIALIZED\n> ESTABLISHING SECURE CONNECTION TO DERO BLOCKCHAIN...\n> CONNECTION ESTABLISHED\n> LOADING REAL-TIME DATA STREAM...\n\n',10);
try{const info=await window.xswd.call('DERO.GetInfo');const lastBlock=await window.xswd.call('DERO.GetLastBlockHeader');
const uptimeStr = info.uptime ? `${Math.floor(info.uptime/3600)}h ${Math.floor((info.uptime%3600)/60).toString().padStart(2, '0')}m` : 'Unknown';
const data=`================================================================\nDERO BLOCKCHAIN STATUS - LIVE DATA STREAM\n================================================================\nNetwork Height: ${info.height?.toLocaleString()||'Loading...'}\nStable Height: ${info.stableheight?.toLocaleString()||'Loading...'}\nTopo Height: ${info.topoheight?.toLocaleString()||'Loading...'}\nPeer Connections: ${((info.incoming_connections_count||0)+(info.outgoing_connections_count||0))}\nNetwork Type: ${info.testnet?'TESTNET':'MAINNET'}\nNode Version: ${info.version||'Unknown'}\nUptime: ${uptimeStr}\n\nLatest Block Hash: ${lastBlock.block_header?.hash?.substring(0,32)+'...'||'Loading...'}\nBlock Timestamp: ${lastBlock.block_header?.timestamp?(lastBlock.block_header.timestamp>1000000000000?new Date(lastBlock.block_header.timestamp):new Date(lastBlock.block_header.timestamp*1000)).toLocaleString():'Loading...'}\nBlock Difficulty: ${lastBlock.block_header?.difficulty?.toLocaleString()||'Loading...'}\nMiners Count: ${lastBlock.block_header?.miners?.length||0}\n\nTELEX CAPABILITIES ONLINE:\n> Direct blockchain access [ACTIVE]\n> Real-time data streaming [ACTIVE]\n> Zero external dependencies [ACTIVE]\n> End-to-end encryption [ACTIVE]\n> Privacy-first architecture [ACTIVE]\n\n================================================================\nUse the API commands above to execute live blockchain queries\n================================================================\n\n`;
o.textContent+=data;this.updateTerminalStatus('Ready - Cypherpunk mode active')}catch(e){o.textContent='================================================================\n║ ║\n║ T E L E X ║\n║ ║\n║ ╔═══════════════════════════════╗ ║\n║ ║ TELA EXPLORER v1.0 ║ ║\n║ ║ [ CONNECTION ERROR ] ║ ║\n║ ╚═══════════════════════════════╝ ║\n║ ║\n================================================================\n\n';const data=`================================================================\nDERO NODE CONNECTION STATUS\n================================================================\nStatus: CONNECTION ERROR - DERO daemon required\nReason: ${e.message}\n\nREAL-TIME DATA UNAVAILABLE:\nNetwork Height: No connection\nPeer Connections: No connection\nNetwork Type: Unknown\nNode Status: OFFLINE (Connection Required)\n\nPlease start your DERO daemon to access live blockchain data\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n`;
o.textContent+=data;this.updateTerminalStatus('Connection error - DERO daemon required')}
o.scrollTop=o.scrollHeight},
async typewriterEffect(el,txt,spd=30){return new Promise(res=>{let i=0;const t=setInterval(()=>{if(i<txt.length){el.textContent+=txt.charAt(i);i++;el.scrollTop=el.scrollHeight}else{clearInterval(t);res()}},spd)})},
updateTerminalStatus(sts){const s=document.getElementById('xswd-terminal-status');if(s)s.textContent=sts},
async runXSWDCommand(cmd){this.updateTerminalStatus('Executing...');
try{let res,nm;
switch(cmd){case'getinfo':nm='DERO.GetInfo';this.addTerminalMessage(`Executing: ${nm}`,!0);res=await window.xswd.call('DERO.GetInfo');break;
case'getlastblock':nm='DERO.GetLastBlockHeader';this.addTerminalMessage(`Executing: ${nm}`,!0);res=await window.xswd.call('DERO.GetLastBlockHeader');break;
case'gettxpool':nm='DERO.GetTxPool (Raw)';this.addTerminalMessage(`Executing: ${nm}`,!0);res=await window.xswd.call('DERO.GetTxPool');break;
case'getpoolstats':nm='getTxPoolWithStats (Enhanced)';this.addTerminalMessage(`Executing: ${nm}`,!0);res=window.xswd.getTxPoolWithStats?await window.xswd.getTxPoolWithStats():{error:'Enhanced method not available'};break;
case'comprehensive':nm='Comprehensive Blockchain Analysis';this.addTerminalMessage(`Executing: ${nm}`,!0);res=await this.runComprehensiveAnalysis();break;
default:this.addTerminalMessage('Unknown command');this.updateTerminalStatus('Ready');return}
const fmt=this.formatXSWDResponse(res,nm);this.addTerminalMessage(fmt);this.updateTerminalStatus('Ready')}catch(e){this.addTerminalMessage(`ERROR: ${e.message}`);this.updateTerminalStatus('Error')}},
async runComprehensiveAnalysis(){const a={timestamp:new Date().toISOString(),telex_capabilities:{},blockchain_state:{},network_analysis:{},privacy_metrics:{}};
try{const info=await window.xswd.call('DERO.GetInfo');a.blockchain_state={height:info.height,stableheight:info.stableheight,topoheight:info.topoheight,network:info.testnet?'testnet':'mainnet',version:info.version,peer_count:info.incoming_connections_count+info.outgoing_connections_count};
const lb=await window.xswd.call('DERO.GetLastBlockHeader');a.blockchain_state.latest_block={hash:lb.hash,timestamp:lb.timestamp,difficulty:lb.difficulty,size:lb.size};
const tp=await window.xswd.call('DERO.GetTxPool');a.network_analysis.mempool={transaction_count:tp.txs?tp.txs.length:0,total_fees:tp.txs?tp.txs.reduce((s,tx)=>s+(tx.fee||0),0):0};
a.privacy_metrics={connection_duration:this.connectionStartTime?Date.now()-this.connectionStartTime:0,api_requests_made:this.apiRequestCount,external_requests_blocked:this.externalRequestsBlocked,data_source:'Direct DERO node via TELEX',privacy_level:'Maximum (no external dependencies)'};
a.telex_capabilities={direct_blockchain_access:!0,real_time_data:!0,no_intermediaries:!0,encrypted_communication:!0,local_processing:!0,available_methods:['DERO.GetInfo','DERO.GetTxPool','DERO.GetLastBlockHeader','DERO.GetBlock','DERO.GetTransaction','DERO.GetSC']}}catch(e){a.error=e.message}
return a},
formatXSWDResponse(d,cn){const sep='━'.repeat(65);let o=`\n${sep}\n`;o+=`${cn.toUpperCase()} - LIVE BLOCKCHAIN DATA\n`;o+=`${sep}\n`;
if(d.error){o+=`ERROR: ${d.error}\n`}else{const js=JSON.stringify(d,null,2);o+=js;
if(cn.includes('GetInfo')){o+=`\n\nNETWORK ANALYSIS:\n Height: ${d.height?.toLocaleString()||'N/A'}\n Stable Height: ${d.stableheight?.toLocaleString()||'N/A'}\n Peers: ${((d.incoming_connections_count||0)+(d.outgoing_connections_count||0))}\n Network: ${d.testnet?'TESTNET':'MAINNET'}\n Version: ${d.version||'N/A'}\n`}else if(cn.includes('TxPool')){const tc=d.txs?d.txs.length:0;o+=`\n\nMEMPOOL ANALYSIS:\n Transactions: ${tc}\n`;if(tc>0){const tf=d.txs.reduce((s,tx)=>s+(tx.fee||0),0);o+=` Total Fees: ${tf.toLocaleString()} atomic units\n Sample TX: ${d.txs[0].txid||d.txs[0].as_hex?.substring(0,24)+'...'||'N/A'}\n`}else{o+=` Status: MEMPOOL EMPTY\n`}}else if(cn.includes('LastBlock')){const b=d.block_header||{};o+=`\n\nBLOCK ANALYSIS:\n Height: ${b.height?.toLocaleString()||'N/A'}\n Hash: ${b.hash?.substring(0,24)+'...'||'N/A'}\n Difficulty: ${b.difficulty?.toLocaleString()||'N/A'}\n Miners: ${b.miners?.length||0}\n Timestamp: ${b.timestamp?new Date(b.timestamp).toLocaleString():'N/A'}\n`}else if(cn.includes('Comprehensive')){o+=`\n\nTELEX PROTOCOL DEMONSTRATION COMPLETE!\n > Direct DERO node connection established\n > Zero external APIs or servers involved\n > Complete privacy and decentralization achieved\n > Real-time blockchain data streaming active\n`}}
o+=`\n${sep}\n`;return o},
startMetricsTracking(){setInterval(()=>{this.updateMetrics()},1000)},
updateMetrics(){},
incrementApiRequests(){this.apiRequestCount++},
incrementBlockedRequests(){this.externalRequestsBlocked++},
togglePrivacyStatus(){const m=document.getElementById('xswd-terminal-modal');if(m){this.isVisible=!this.isVisible;m.style.display=this.isVisible?'block':'none';if(this.isVisible&&!this.dataInitialized){this.loadInitialTerminalData();this.dataInitialized=!0}}}
})
*/ |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "telex.js")
31 STORE("descrHdr", "TELEX terminal interface")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "explorer.tela")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "1d475579a3f4c6261cdc2671ccedf678015234ea4466332a0656e8acf0055d87")
37 STORE("fileCheckS", "170a456bfe6968948196f6eb92e83f1f4513c5a54bd9af5390af0c94c068ce60")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
({
name:'telex',version:'1.0.0',isVisible:!1,xswdModalVisible:!1,dataInitialized:!1,connectionStartTime:null,apiRequestCount:0,externalRequestsBlocked:0,connectionEndpoint:'',actualXswdEndpoint:'',
init(){this.connectionStartTime=Date.now();this.createXSWDTerminalModal();this.startMetricsTracking()},
createXSWDTerminalModal(){const m=document.createElement('div');m.id='xswd-terminal-modal';m.style.cssText='display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.98);z-index:1001;backdrop-filter:blur(15px)';
m.innerHTML='<div style="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background:#000000;border:2px solid #00ff41;border-radius:0;width:95%;max-width:1300px;height:92vh;overflow:hidden;box-shadow:0 0 40px rgba(0,255,65,0.4),inset 0 0 0 1px rgba(0,255,65,0.1);font-family:\'Courier New\',Consolas,\'Lucida Console\',Monaco,monospace"><div style="background:#001100;border-bottom:2px solid #00ff41;padding:1rem;display:flex;justify-content:space-between;align-items:center;box-shadow:0 2px 10px rgba(0,255,65,0.2)"><div style="display:flex;align-items:center;gap:15px"><div style="color:#00ff41;font-size:1.3rem;font-weight:bold;text-shadow:0 0 10px #00ff41">T E L E X</div><div style="color:#009900;font-size:0.9rem">TELA Explorer v1.0</div></div><button onclick="window.telex.hideXSWDTerminal()" style="background:#000;border:1px solid #00ff41;color:#00ff41;padding:6px 12px;border-radius:0;cursor:pointer;font-family:monospace;text-shadow:0 0 5px #00ff41;transition:all 0.2s">[ CLOSE ]</button></div><div style="height:calc(100% - 120px);overflow-y:auto;padding:1rem;background:#000000"><div style="color:#00ff41;margin-bottom:1.5rem;font-size:0.9rem;line-height:1.3;text-shadow:0 0 3px #00ff41">> TELEX Protocol Analysis - Real-time DERO blockchain data<br/>> Demonstrating decentralized application power<br/>> All data flows directly from your DERO node<br/><span style="color:#666;animation:blink 1s infinite">_</span></div><div style="margin-bottom:2rem;padding:1rem;background:#001100;border:1px solid #00ff41;border-radius:0;box-shadow:0 0 15px rgba(0,255,65,0.2)"><div style="color:#00ff41;margin-bottom:1rem;font-weight:bold;text-shadow:0 0 5px #00ff41">[ API COMMANDS ] - Click to append data below</div><div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px"><button onclick="window.telex.runXSWDCommand(\'getinfo\')" style="background:#000;border:1px solid #00ff41;color:#00ff41;padding:8px 12px;border-radius:0;cursor:pointer;font-family:monospace;font-size:0.8rem;text-shadow:0 0 3px #00ff41;transition:all 0.2s">DERO.GetInfo</button><button onclick="window.telex.runXSWDCommand(\'getlastblock\')" style="background:#000;border:1px solid #00ff41;color:#00ff41;padding:8px 12px;border-radius:0;cursor:pointer;font-family:monospace;font-size:0.8rem;text-shadow:0 0 3px #00ff41;transition:all 0.2s">GetLastBlock</button><button onclick="window.telex.runXSWDCommand(\'gettxpool\')" style="background:#000;border:1px solid #00ff41;color:#00ff41;padding:8px 12px;border-radius:0;cursor:pointer;font-family:monospace;font-size:0.8rem;text-shadow:0 0 3px #00ff41;transition:all 0.2s">GetTxPool</button><button onclick="window.telex.runXSWDCommand(\'getpoolstats\')" style="background:#000;border:1px solid #00ff41;color:#00ff41;padding:8px 12px;border-radius:0;cursor:pointer;font-family:monospace;font-size:0.8rem;text-shadow:0 0 3px #00ff41;transition:all 0.2s">Enhanced Pool</button><button onclick="window.telex.runXSWDCommand(\'comprehensive\')" style="background:#001100;border:1px solid #b73019;color:#b73019;padding:8px 12px;border-radius:0;cursor:pointer;font-family:monospace;font-size:0.8rem;text-shadow:0 0 3px #b73019;transition:all 0.2s">Full Analysis</button></div></div><div id="xswd-terminal-output" style="color:#00ff41;font-size:0.82rem;line-height:1.3;white-space:pre-wrap;word-wrap:break-word;text-shadow:0 0 2px #00ff41;min-height:400px"></div></div><div style="background:#001100;border-top:1px solid #00ff41;padding:0.5rem 1rem;color:#009900;font-size:0.8rem;display:flex;justify-content:space-between;box-shadow:0 -2px 10px rgba(0,255,65,0.1)"><span>TELEX Protocol | TELA Explorer v1.0 | Direct Blockchain Connection</span><span id="xswd-terminal-status" style="color:#00ff41;text-shadow:0 0 3px #00ff41">Initializing...</span></div></div><style>@keyframes blink{0%,50%{opacity:1}51%,100%{opacity:0}}button:hover{box-shadow:0 0 10px currentColor!important;transform:scale(1.02)}</style>';
document.body.appendChild(m)},
showXSWDTerminal(){const m=document.getElementById('xswd-terminal-modal');if(m){this.xswdModalVisible=!0;m.style.display='block';if(!this.dataInitialized){this.loadInitialTerminalData();this.dataInitialized=!0}}},
hideXSWDTerminal(){const m=document.getElementById('xswd-terminal-modal');if(m){this.isVisible=!1;this.xswdModalVisible=!1;m.style.display='none'}},
addTerminalMessage(msg,isCmd=!1){const o=document.getElementById('xswd-terminal-output');if(o){const ts=new Date().toLocaleTimeString();const pfx=isCmd?`[${ts}] > `:'';o.textContent+=`${pfx}${msg}\n`;o.scrollTop=o.scrollHeight}},
async loadInitialTerminalData(){this.updateTerminalStatus('Loading Cypherpunk dashboard...');
const o=document.getElementById('xswd-terminal-output');if(!o)return;
o.textContent='';await this.typewriterEffect(o,'================================================================\n║ ║\n║ T E L E X ║\n║ ║\n║ ╔═══════════════════════════════╗ ║\n║ ║ TELA EXPLORER v1.0 ║ ║\n║ ║ Decentralized Interface ║ ║\n║ ╚═══════════════════════════════╝ ║\n║ ║\n================================================================\n\n> TELEX PROTOCOL INITIALIZED\n> ESTABLISHING SECURE CONNECTION TO DERO BLOCKCHAIN...\n> CONNECTION ESTABLISHED\n> LOADING REAL-TIME DATA STREAM...\n\n',10);
try{const info=await window.xswd.call('DERO.GetInfo');const lastBlock=await window.xswd.call('DERO.GetLastBlockHeader');
const uptimeStr = info.uptime ? `${Math.floor(info.uptime/3600)}h ${Math.floor((info.uptime%3600)/60).toString().padStart(2, '0')}m` : 'Unknown';
const data=`================================================================\nDERO BLOCKCHAIN STATUS - LIVE DATA STREAM\n================================================================\nNetwork Height: ${info.height?.toLocaleString()||'Loading...'}\nStable Height: ${info.stableheight?.toLocaleString()||'Loading...'}\nTopo Height: ${info.topoheight?.toLocaleString()||'Loading...'}\nPeer Connections: ${((info.incoming_connections_count||0)+(info.outgoing_connections_count||0))}\nNetwork Type: ${info.testnet?'TESTNET':'MAINNET'}\nNode Version: ${info.version||'Unknown'}\nUptime: ${uptimeStr}\n\nLatest Block Hash: ${lastBlock.block_header?.hash?.substring(0,32)+'...'||'Loading...'}\nBlock Timestamp: ${lastBlock.block_header?.timestamp?(lastBlock.block_header.timestamp>1000000000000?new Date(lastBlock.block_header.timestamp):new Date(lastBlock.block_header.timestamp*1000)).toLocaleString():'Loading...'}\nBlock Difficulty: ${lastBlock.block_header?.difficulty?.toLocaleString()||'Loading...'}\nMiners Count: ${lastBlock.block_header?.miners?.length||0}\n\nTELEX CAPABILITIES ONLINE:\n> Direct blockchain access [ACTIVE]\n> Real-time data streaming [ACTIVE]\n> Zero external dependencies [ACTIVE]\n> End-to-end encryption [ACTIVE]\n> Privacy-first architecture [ACTIVE]\n\n================================================================\nUse the API commands above to execute live blockchain queries\n================================================================\n\n`;
o.textContent+=data;this.updateTerminalStatus('Ready - Cypherpunk mode active')}catch(e){o.textContent='================================================================\n║ ║\n║ T E L E X ║\n║ ║\n║ ╔═══════════════════════════════╗ ║\n║ ║ TELA EXPLORER v1.0 ║ ║\n║ ║ [ CONNECTION ERROR ] ║ ║\n║ ╚═══════════════════════════════╝ ║\n║ ║\n================================================================\n\n';const data=`================================================================\nDERO NODE CONNECTION STATUS\n================================================================\nStatus: CONNECTION ERROR - DERO daemon required\nReason: ${e.message}\n\nREAL-TIME DATA UNAVAILABLE:\nNetwork Height: No connection\nPeer Connections: No connection\nNetwork Type: Unknown\nNode Status: OFFLINE (Connection Required)\n\nPlease start your DERO daemon to access live blockchain data\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n`;
o.textContent+=data;this.updateTerminalStatus('Connection error - DERO daemon required')}
o.scrollTop=o.scrollHeight},
async typewriterEffect(el,txt,spd=30){return new Promise(res=>{let i=0;const t=setInterval(()=>{if(i<txt.length){el.textContent+=txt.charAt(i);i++;el.scrollTop=el.scrollHeight}else{clearInterval(t);res()}},spd)})},
updateTerminalStatus(sts){const s=document.getElementById('xswd-terminal-status');if(s)s.textContent=sts},
async runXSWDCommand(cmd){this.updateTerminalStatus('Executing...');
try{let res,nm;
switch(cmd){case'getinfo':nm='DERO.GetInfo';this.addTerminalMessage(`Executing: ${nm}`,!0);res=await window.xswd.call('DERO.GetInfo');break;
case'getlastblock':nm='DERO.GetLastBlockHeader';this.addTerminalMessage(`Executing: ${nm}`,!0);res=await window.xswd.call('DERO.GetLastBlockHeader');break;
case'gettxpool':nm='DERO.GetTxPool (Raw)';this.addTerminalMessage(`Executing: ${nm}`,!0);res=await window.xswd.call('DERO.GetTxPool');break;
case'getpoolstats':nm='getTxPoolWithStats (Enhanced)';this.addTerminalMessage(`Executing: ${nm}`,!0);res=window.xswd.getTxPoolWithStats?await window.xswd.getTxPoolWithStats():{error:'Enhanced method not available'};break;
case'comprehensive':nm='Comprehensive Blockchain Analysis';this.addTerminalMessage(`Executing: ${nm}`,!0);res=await this.runComprehensiveAnalysis();break;
default:this.addTerminalMessage('Unknown command');this.updateTerminalStatus('Ready');return}
const fmt=this.formatXSWDResponse(res,nm);this.addTerminalMessage(fmt);this.updateTerminalStatus('Ready')}catch(e){this.addTerminalMessage(`ERROR: ${e.message}`);this.updateTerminalStatus('Error')}},
async runComprehensiveAnalysis(){const a={timestamp:new Date().toISOString(),telex_capabilities:{},blockchain_state:{},network_analysis:{},privacy_metrics:{}};
try{const info=await window.xswd.call('DERO.GetInfo');a.blockchain_state={height:info.height,stableheight:info.stableheight,topoheight:info.topoheight,network:info.testnet?'testnet':'mainnet',version:info.version,peer_count:info.incoming_connections_count+info.outgoing_connections_count};
const lb=await window.xswd.call('DERO.GetLastBlockHeader');a.blockchain_state.latest_block={hash:lb.hash,timestamp:lb.timestamp,difficulty:lb.difficulty,size:lb.size};
const tp=await window.xswd.call('DERO.GetTxPool');a.network_analysis.mempool={transaction_count:tp.txs?tp.txs.length:0,total_fees:tp.txs?tp.txs.reduce((s,tx)=>s+(tx.fee||0),0):0};
a.privacy_metrics={connection_duration:this.connectionStartTime?Date.now()-this.connectionStartTime:0,api_requests_made:this.apiRequestCount,external_requests_blocked:this.externalRequestsBlocked,data_source:'Direct DERO node via TELEX',privacy_level:'Maximum (no external dependencies)'};
a.telex_capabilities={direct_blockchain_access:!0,real_time_data:!0,no_intermediaries:!0,encrypted_communication:!0,local_processing:!0,available_methods:['DERO.GetInfo','DERO.GetTxPool','DERO.GetLastBlockHeader','DERO.GetBlock','DERO.GetTransaction','DERO.GetSC']}}catch(e){a.error=e.message}
return a},
formatXSWDResponse(d,cn){const sep='━'.repeat(65);let o=`\n${sep}\n`;o+=`${cn.toUpperCase()} - LIVE BLOCKCHAIN DATA\n`;o+=`${sep}\n`;
if(d.error){o+=`ERROR: ${d.error}\n`}else{const js=JSON.stringify(d,null,2);o+=js;
if(cn.includes('GetInfo')){o+=`\n\nNETWORK ANALYSIS:\n Height: ${d.height?.toLocaleString()||'N/A'}\n Stable Height: ${d.stableheight?.toLocaleString()||'N/A'}\n Peers: ${((d.incoming_connections_count||0)+(d.outgoing_connections_count||0))}\n Network: ${d.testnet?'TESTNET':'MAINNET'}\n Version: ${d.version||'N/A'}\n`}else if(cn.includes('TxPool')){const tc=d.txs?d.txs.length:0;o+=`\n\nMEMPOOL ANALYSIS:\n Transactions: ${tc}\n`;if(tc>0){const tf=d.txs.reduce((s,tx)=>s+(tx.fee||0),0);o+=` Total Fees: ${tf.toLocaleString()} atomic units\n Sample TX: ${d.txs[0].txid||d.txs[0].as_hex?.substring(0,24)+'...'||'N/A'}\n`}else{o+=` Status: MEMPOOL EMPTY\n`}}else if(cn.includes('LastBlock')){const b=d.block_header||{};o+=`\n\nBLOCK ANALYSIS:\n Height: ${b.height?.toLocaleString()||'N/A'}\n Hash: ${b.hash?.substring(0,24)+'...'||'N/A'}\n Difficulty: ${b.difficulty?.toLocaleString()||'N/A'}\n Miners: ${b.miners?.length||0}\n Timestamp: ${b.timestamp?new Date(b.timestamp).toLocaleString():'N/A'}\n`}else if(cn.includes('Comprehensive')){o+=`\n\nTELEX PROTOCOL DEMONSTRATION COMPLETE!\n > Direct DERO node connection established\n > Zero external APIs or servers involved\n > Complete privacy and decentralization achieved\n > Real-time blockchain data streaming active\n`}}
o+=`\n${sep}\n`;return o},
startMetricsTracking(){setInterval(()=>{this.updateMetrics()},1000)},
updateMetrics(){},
incrementApiRequests(){this.apiRequestCount++},
incrementBlockedRequests(){this.externalRequestsBlocked++},
togglePrivacyStatus(){const m=document.getElementById('xswd-terminal-modal');if(m){this.isVisible=!this.isVisible;m.style.display=this.isVisible?'block':'none';if(this.isVisible&&!this.dataInitialized){this.loadInitialTerminalData();this.dataInitialized=!0}}}
})
*/'] |