dgb-wallet/packages/bns/README.md
Digibyte.X d50286a9a5 DigiByte.X Wallet — recovery-first web wallet monorepo
Packages: core (BIP39/32/44/49/84/86 derivation, WIF), keystore (PBKDF2 +
AES-GCM), psbt, p2p (BIP157/158 SPV daemon, Dandelion++ broadcast with
relay-echo verification), blockbook, rpc, electrum, net, bns, web-ui
(React/Vite), mobile (Expo). ops/ holds the nginx vhost, systemd unit and
push.sh deploy script for digibyte.x/web.
2026-09-20 20:16:52 +02:00

55 lines
2.5 KiB
Markdown

# @dgb-wallet/bns
BNS (Bitcoin Cash Name Service) resolver client for the DigiByte.X Wallet. Wraps the canonical zero-dependency `resolver-web.js` from `D:\Dev\SilentMode\Argus\src\lib\` (single source of truth, kept in lockstep with the rest of the Silent Mode stack per its `PROTOCOL.md`).
Handles `.dgb` and every other activated BNS TLD (`.bch`, `.p2p`, `.deviant`, `.nav`, `.sia`, `.nt`, `.sm`, `.lm`) as of the 2026-07-30 bootstrap.
## API
```ts
import { resolveName, resolveEndpoint, normalizeName, normalizeFingerprint } from '@dgb-wallet/bns';
// Full resolve — returns everything on-chain for a name
const entry = await resolveName('rpc.dgb');
// { name: 'rpc.dgb', records: { ip: '...', tls: '...' }, height, txid, category }
// Endpoint-only — enforces both ip AND tls fingerprint present
const { ip, tls } = await resolveEndpoint('rpc.dgb');
// { name: 'rpc.dgb', ip: '203.0.113.42', tls: 'ab12cd34...' }
// Canonicalize any input to <label>.<tld>
normalizeName('RPC.DGB') // 'rpc.dgb'
normalizeName('rpc.dgb/foo') // 'rpc.dgb'
// Accepts colon-hex, sha256/ prefix, or plain hex
normalizeFingerprint('sha256/AB:CD:EF:...') // 'abcdef...'
```
`resolveEndpoint` is what `@dgb-wallet/rpc` uses to look up its backend — refuses to return a result unless *both* `ip` and `tls` records are present, because connecting without a pinned fingerprint would defeat the whole point of the BCH-anchored PKI model.
## Demo
```bash
cd "D:\Dev\SilentCode\Digibyte"
npm install # first time only
npm run demo -w @dgb-wallet/bns # resolves tlds.bch by default
npm run demo -w @dgb-wallet/bns -- rpc.dgb
```
## How the trust chain flows
```
BNS name (rpc.dgb)
↓ resolveEndpoint
BCH chain (CashToken cert + OP_RETURN records)
↓
{ ip, tls fingerprint }
↓ TLS handshake with fingerprint pin
VPS running DigiByte Core
```
No ICANN, no Let's Encrypt, no CA/Browser Forum. Trust anchor is the BCH chain plus the BNS Root CA (installed system-wide by Ariadne if you're on a machine with Silent Mode; verified inline by `@dgb-wallet/rpc` regardless).
## Coupling with Silent Mode
`src/resolver.ts` imports `resolver-web.js` via a relative path (`../../../../../SilentMode/Argus/src/lib/resolver-web.js`). This documents the dependency; both projects sit on the same developer machine and evolve together. If `resolver-web.js` is later published as an npm package (e.g. `@silentmode/bns-resolver`), the relative import becomes `import ... from '@silentmode/bns-resolver'` and nothing else changes.