dgb-wallet/packages/p2p
Digibyte.X 93cd8b4bf4 daemon: verify proof-of-work on every synced header; fork choice by work
DigiByte is multi-algorithm, so this brings in six hash functions:
SHA256d and Scrypt in JS, and Qubit, Skein, Groestl and Odocrypt from
DigiByte Core's own C sources compiled to WebAssembly (packages/p2p/native,
emscripten via docker). Each header is checked against its nBits target and
the network powLimit before it can enter the chain; a peer serving an
invalid or future-dated header is benched. Competing branches are accepted
only when they carry more accumulated work than what they replace.

npm run pow:test -w @dgb-wallet/p2p verifies real mainnet headers of all
six algorithms and that a tampered header fails.
2026-10-02 18:37:31 +02:00
..
bin daemon: verify proof-of-work on every synced header; fork choice by work 2026-10-02 18:37:31 +02:00
native daemon: verify proof-of-work on every synced header; fork choice by work 2026-10-02 18:37:31 +02:00
scripts daemon: verify proof-of-work on every synced header; fork choice by work 2026-10-02 18:37:31 +02:00
src daemon: verify proof-of-work on every synced header; fork choice by work 2026-10-02 18:37:31 +02:00
test daemon: verify proof-of-work on every synced header; fork choice by work 2026-10-02 18:37:31 +02:00
.gitignore DigiByte.X Wallet — recovery-first web wallet monorepo 2026-09-20 20:16:52 +02:00
package.json daemon: verify proof-of-work on every synced header; fork choice by work 2026-10-02 18:37:31 +02:00
README.md DigiByte.X Wallet — recovery-first web wallet monorepo 2026-09-20 20:16:52 +02:00
tsconfig.json DigiByte.X Wallet — recovery-first web wallet monorepo 2026-09-20 20:16:52 +02:00

@dgb-wallet/p2p

DigiByte P2P client for the Maximum Privacy backend. Client-side chain data via BIP157/158 compact block filters — the wallet does its own address matching locally, so peers never learn which addresses it cares about.

Current status: Milestone 1 (peer connect + version handshake).

Planned milestones:

  1. ✅ Peer connect + version handshake
  2. Peer discovery via DNS seeds + getaddr
  3. Header sync (getheaders / headers)
  4. BIP157 filter negotiation + BIP158 filter download
  5. Filter probing (address → scripthash → filter match)
  6. Block fetching for filter hits
  7. Transaction broadcast (inv / tx)
  8. Dandelion++ integration
  9. Persistent cache

Milestone 1 demo

cd "D:\Dev\SilentCode\Digibyte"
npm install                        # first time only
npm run build -w @dgb-wallet/core
npm run handshake -w @dgb-wallet/p2p

Resolves DGB DNS seeds → connects to real live peers on port 12024 → performs the version/verack handshake → reports each peer's protocol version, user agent, service flags, and chain tip height.

To target a specific peer IP:

npm run handshake -w @dgb-wallet/p2p -- 1.2.3.4

Layout

src/
  hash.ts     — double-SHA256 for message checksums
  varint.ts   — Bitcoin/DGB compact-size int encoding
  framing.ts  — 24-byte header + payload + checksum, multi-frame parsing
  version.ts  — version/verack message encode/decode, service flag bits
  peer.ts     — per-peer TCP + handshake state machine
  index.ts    — re-exports

scripts/
  handshake-demo.ts — Milestone 1 end-to-end demo

Depends on @dgb-wallet/core for network parameters (DGB_P2P.magic, defaultPort, dnsSeeds).