#!/usr/bin/env node /** * JesusOS original Termux BTC payout address discovery (read-only). * Checks only explicitly named ORIGINAL public-address configuration sources * and local Bitcoin Core wallet availability (read-only RPC). * It NEVER reads key stores, seed phrases, Android app private data, or * unrelated project files. No money, wallet, address or miner is created. * No full address or secret is displayed, written, uploaded or transmitted. */ import fs from 'node:fs'; import path from 'node:path'; import {spawnSync} from 'node:child_process'; import {createHash} from 'node:crypto'; const home=process.env.HOME||''; const dir=path.join(home,'jesusos-bitcoin-mining'); const sha=b=>createHash('sha256').update(b).digest(); const sha2=b=>sha(sha(b)); const base58='123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; const bech32='qpzry9x8gf2tvdw0s3jn54khce6mua7l'; const allowedFields=new Set(['BITCOIN_ADDRESS','BITCOIN_RECEIVE_ADDRESS','BTC_RECEIVE_ADDRESS','BTC_PAYOUT_ADDRESS','BTC_WALLET_ADDRESS','MINING_PAYOUT_ADDRESS','STRATUM_WORKER']); const fileNames=['jesusos-pool-settings.env','pool.env','mining.env','.env','.env.local','bitcoin-address.txt','btc-address.txt','payout-address.txt','bitcoin-receive-address.txt']; const userFileNames=['bitcoin-address.txt','btc-address.txt','bitcoin-payout.txt','.profile','.bashrc','.zshrc']; function isBase58(s){ if(s.length<26||s.length>35||![...'13'].includes(s[0]))return false; let v=0n; for(const ch of s){const i=base58.indexOf(ch);if(i<0)return false;v=v*58n+BigInt(i);} const bytes=[]; while(v>0n){bytes.unshift(Number(v&255n));v>>=8n;} const leading=s.match(/^1*/)?.[0].length||0; const raw=Buffer.from([...Array(leading).fill(0),...bytes]); return raw.length===25&&(raw[0]===0x00||raw[0]===0x05)&&sha2(raw.subarray(0,21)).subarray(0,4).equals(raw.subarray(21)); } function polymod(vals){ const g=[0x3b6a57b2,0x26508e6d,0x1ea119fa,0x3d4233dd,0x2a1462b3]; let c=1; for(const v of vals){ const b=c>>>25; c=((c&0x1ffffff)<<5)^v; for(let i=0;i<5;i++)if((b>>i)&1)c^=g[i]; } return c>>>0; } function convert5to8(vals){ let acc=0,bits=0;const bytes=[]; for(const v of vals){ if(v<0||v>31)return null; acc=(acc<<5)|v;bits+=5; while(bits>=8){bits-=8;bytes.push((acc>>bits)&255)} } if(bits>=5||((acc<<(8-bits))&255)!==0)return null; return bytes; } function isBech32(s){ if(s.length<14||s.length>90||s.toLowerCase()!==s&&s.toUpperCase()!==s)return false; s=s.toLowerCase(); const pos=s.lastIndexOf('1'); if(pos!==2||s.slice(0,pos)!=='bc')return false; const letters=s.slice(pos+1),data=[]; for(const ch of letters){const n=bech32.indexOf(ch);if(n<0)return false;data.push(n)} if(data.length<7)return false; // hrp_expand('bc') = [98>>5, 99>>5, 0, 98&31, 99&31] const sum=polymod([3,3,0,2,3,...data]); const version=data[0],program=convert5to8(data.slice(1,-6)); if(version<0||version>16||!program||program.length<2||program.length>40)return false; if(version===0)return sum===1&&(program.length===20||program.length===32); return sum===0x2bc830a3; } function validMainnet(s){return isBase58(s)||isBech32(s);} function safeSuffix(address){return address.slice(0,3)+'…'+address.slice(-4);} function getWorker(s){return s.replace(/^['"]|['"]$/g,'').trim().split('.')[0]} function readCandidates(file,plain=false){ let raw,st; // Do not follow symlinks to unexpected files or sensitive stores. try{st=fs.lstatSync(file);if(!st.isFile()||st.isSymbolicLink()||st.size>65536)return;}catch{return;} try{raw=fs.readFileSync(file,'utf8')}catch{return;} for(const line of raw.split(/\r?\n/)){ const match=line.match(/^\s*(?:export\s+)?([A-Z_][A-Z0-9_]*)\s*=\s*(.*?)\s*(?:#.*)?$/); let value; if(match&&allowedFields.has(match[1]))value=match[2]; else if(plain&&line.trim().length<=120)value=line.trim(); else continue; const candidate=getWorker(value||''); if(validMainnet(candidate)){ const label=path.relative(home,file); if(!found.has(candidate))found.set(candidate,new Set()); found.get(candidate).add(label); } } } const found=new Map(); for(const file of fileNames)readCandidates(path.join(dir,file),file.endsWith('.txt')); for(const file of userFileNames)readCandidates(path.join(home,file),file.endsWith('.txt')); for(const key of allowedFields){ if(typeof process.env[key]!=='string')continue; const candidate=getWorker(process.env[key]); if(!validMainnet(candidate))continue; if(!found.has(candidate))found.set(candidate,new Set()); found.get(candidate).add('current Termux environment'); } console.log('=== JesusOS original Bitcoin payout inventory · READ ONLY ==='); console.log('Original mining workspace:',fs.existsSync(dir)?'PRESENT':'NOT FOUND'); console.log('Bitcoin MAINNET receive addresses passing public checksum:',found.size); for(const [a,sources] of found)console.log('EXISTING PUBLIC ADDRESS:',safeSuffix(a),'sources:',[...sources].join(', '),'OWNER CONTROL: NOT VERIFIED'); console.log('Private keys / seed phrases / balance: NOT examined; no full address displayed.'); const cli=spawnSync('which',['bitcoin-cli'],{encoding:'utf8',timeout:2500}); const hasCli=cli.status===0; console.log('Bitcoin Core local wallet command installed:',hasCli?'YES':'NOT FOUND'); if(hasCli){ const result=spawnSync('bitcoin-cli',['-rpcconnect=127.0.0.1','listwallets'],{encoding:'utf8',timeout:5000,maxBuffer:32768}); if(result.status===0){ let wallets; try{wallets=JSON.parse(result.stdout)}catch{} console.log('Bitcoin Core loaded wallets:',Array.isArray(wallets)?wallets.length:'UNREADABLE RESULT'); console.log('No addresses or wallet names extracted; no address generated.'); }else console.log('Bitcoin Core local wallet RPC: NOT AVAILABLE (no wallet changed).'); } if(found.size===0){ console.log('RESULT: no public payout address recovered from the examined ORIGINAL Termux settings.'); console.log('A wallet in another Android app cannot be inspected through Termux; no wallet or address was invented.'); }else if(found.size===1){ console.log('RESULT: one candidate address found. Confirm you control its receiving wallet BEFORE using it for real-pool payouts.'); }else console.log('RESULT: multiple candidate addresses found. Human wallet ownership selection required; no automatic payout substitution.'); console.log('No processes started or stopped. No files changed. No network requests or secrets transmitted.');