dgb-wallet/packages/rpc/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

42 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# @dgb-wallet/rpc
JSON-RPC client for DigiByte Core, calling only the read-only + broadcast methods a wallet needs. Companion to [`ops/setup.sh`](../../ops/setup.sh), which provisions the matching pruned VPS backend.
## API
- `new RpcClient({ url, username, password, timeoutMs })`
- `getBlockchainInfo(client)` — chain tip, sync progress, prune status
- `scanTxOutSet(client, descriptors)` — walk UTXO set for descriptors/xpubs; returns matching UTXOs
- `sendRawTransaction(client, hex)` — broadcast; returns txid or throws
- `estimateSmartFee(client, confTarget)` — DGB/kB fee estimate
- `descriptorForAccount(purpose, xpub, change, rangeEnd)` — build BIP44/49/84/86 descriptors with checksums
- `descriptorChecksum(desc)`, `withChecksum(desc)` — BIP380 checksum helpers
## Demo — real recovery scan via your VPS
Provision the backend once with [`../../ops/setup.sh`](../../ops/setup.sh) (turnkey for a fresh Ubuntu/Debian VPS). Then:
```bash
cd "D:\Dev\SilentCode\Digibyte"
npm install # first time only
npm run build -w @dgb-wallet/core
export DGB_RPC_URL=https://your-domain.example.com/
export DGB_RPC_USER=dgb_...
export DGB_RPC_PASSWORD=...
npm run demo -w @dgb-wallet/rpc
# or with a specific seed:
npm run demo -w @dgb-wallet/rpc -- "word1 word2 ... word12"
```
Scans 3 accounts × 4 descriptor paths × 2 change/receive × 101 addresses each = **2,424 addresses in one RPC call**, typically 5–15 seconds on a synced pruned node. Prints every UTXO found with its descriptor path, ready to feed into `@dgb-wallet/psbt` for spending.
## Descriptor checksums
DGB Core requires descriptors passed to `scantxoutset` to carry a BIP380 checksum. `withChecksum(desc)` and `descriptorForAccount(...)` compute it locally so we don't need a round-trip to `getdescriptorinfo`.
## Notes
- Uses `fetch` — Node 18+, React Native, and browser extensions all work.
- Future: swap `fetch` for `@dgb-wallet/net`'s `NetProvider` so requests can go through Tor by default (per RESEARCH.md §10.7b).
- Wallet-side is stateless; the VPS holds the chain state. Client keys never leave the wallet.