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

84 lines
3.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/core
DigiByte wallet primitives — no node required.
- BIP39 seed generation / validation / import
- BIP32 hierarchical deterministic derivation with DGB xpub/xprv version bytes
- BIP44 legacy, BIP49 P2SH-SegWit, BIP84 native SegWit, BIP86 Taproot
- Address encoding for `D…`, `S…`, `dgb1q…`, `dgb1p…`
- WIF (Wallet Import Format) import/export with network-byte validation
This package is the shared crypto core that the mobile app and browser
extension both depend on. All keygen and signing happens locally; the
package never talks to a network.
## Quick start
```bash
cd "D:\Program Files\DigiByte-Wallet\packages\core" # or wherever you put it
npm install
npm run demo
```
Generates a fresh 12-word seed and prints the first three addresses at
each of the four descriptor classes (legacy, P2SH-SegWit, native SegWit,
Taproot).
To recover from an existing seed and dump many candidate addresses,
generate a throwaway test seed first (never use a real seed):
```bash
# 1. generate a fresh throwaway seed and copy it from stdout
npm run demo
# 2. paste ONLY those 12 words back — nothing else, no placeholder text
npm run recover -- "word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12"
```
> ⚠️ **Never paste a real seed phrase into a terminal, a chat, a support
> ticket, or any input field that isn't the wallet itself.** Terminal
> command history persists in `~/.bash_history` /
> `%USERPROFILE%\.bash_history` / PowerShell's `PSReadLine` history —
> anyone with access to your machine can recover it. Use a fresh test
> seed for any script that takes a seed as an argument.
Cross-check any produced address against `iancoleman.io/bip39` with
coin = "DGB - Digibyte" — they should match byte-for-byte.
## Network parameters
Sourced from `src/kernel/chainparams.cpp` `CMainParams` in
[DigiByte-Core/digibyte](https://github.com/DigiByte-Core/digibyte).
| | Mainnet | Testnet |
|---|---|---|
| bech32 HRP | `dgb` | `dgbt` |
| pubKeyHash | `0x1e` → `D…` | `0x7e` |
| scriptHash | `0x3f` → `S…` | `0x8c` |
| WIF | `0x80` | `0xef` |
| xpub / xprv | `0x0488b21e` / `0x0488ade4` | `0x043587cf` / `0x04358394` |
| SLIP-0044 coin type | **20** | 1 (all testnets) |
## Layout
```
src/
network.ts — DGB mainnet + testnet params, P2P constants
seed.ts — BIP39: generate, validate, mnemonic → seed
hd.ts — BIP32: root, account, address nodes
address.ts — P2PKH, P2SH-P2WPKH, P2WPKH, P2TR encoders
wif.ts — WIF import/export with version-byte validation
descriptor.ts — derivation-path strings, xpub/xprv export
index.ts — re-exports
scripts/
derive-from-seed.ts — generate wallet, show 3 addresses per path
recover-from-seed.ts — scan 5 accounts × 20 addresses per path
```
## Roadmap
- **`@dgb-wallet/p2p`** — DGB P2P client with BIP157/158 compact block filters
- **`@dgb-wallet/rpc`** — thin adapter for a local pruned Core (broadcast bastion)
- **`@dgb-wallet/blockbook`** — opt-in convenience-mode backend
- **`@dgb-wallet/psbt`** — transaction construction / signing on top of `core`