// Resolve a BNS name against real chipnet electrum servers. // Default: resolve tlds.bch (the well-known root TLD certificate) and // print the activated TLD list. Pass any name as an arg to resolve it. import { resolveName, DEFAULT_ELECTRUM } from '../src/index.js'; const name = process.argv[2] ?? 'tlds.bch'; console.log(`\nBNS resolve: ${name}`); console.log(`Electrum pool (${DEFAULT_ELECTRUM.length}):`); for (const s of DEFAULT_ELECTRUM) console.log(` ${s.url}${s.ip ? ' (ip ' + s.ip + ')' : ''}`); console.log(); const t0 = performance.now(); const entry = await resolveName(name); const ms = (performance.now() - t0).toFixed(0); if (!entry) { console.log(` ${name} — not registered (index built in ${ms} ms)`); process.exit(1); } console.log(` ${entry.name} (index built in ${ms} ms)`); if (entry.height) console.log(` height: ${entry.height}`); if (entry.txid) console.log(` txid: ${entry.txid}`); console.log(` records:`); for (const [k, v] of Object.entries(entry.records)) { if (v == null) continue; const shown = v.length > 200 ? v.slice(0, 200) + '...' : v; console.log(` ${k}: ${shown}`); }