dgb-wallet/packages/p2p
Digibyte.X 690959a983 p2p: BIP158 matching in WebAssembly (gcs.c), Number-based JS fallback; Blockbook upstream → Atomic
The daemon's wallet scan hashed every watched script against every block
filter with a BigInt SipHash: ~3 filters/s on the VPS once the gap limits
went to 200/100 (~3,300 scripts), i.e. days for a one-year window. The
matcher now lives in dgbpow.wasm next to the PoW hashes — scripts are
uploaded once per scan, each filter is one call, the set is decoded once
and each target binary-searched — ~5,500 filters/s locally, ~2,000/s on
the VPS with block fetches. The JS path was rewritten with uint32 lanes
and exact 32×32 partial products as a fallback (module missing or filter
beyond its buffers). scripts/gcs-check.ts cross-checks both against a
BigInt reference on random filters; `npm run gcs:test -w @dgb-wallet/p2p`.

NOWNodes stopped accepting the proxy's API key ("Unknown API_key" on every
endpoint), which is why the wallet showed "Blockbook HTTP 401" for every
path. The vhost mirror now proxies /blockbook/ to Atomic Wallet's public
Blockbook; ops/blockbook-upstream.sh switches the live vhost either way.
2026-10-11 23:37:28 +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 p2p: BIP158 matching in WebAssembly (gcs.c), Number-based JS fallback; Blockbook upstream → Atomic 2026-10-11 23:37:28 +02:00
scripts p2p: BIP158 matching in WebAssembly (gcs.c), Number-based JS fallback; Blockbook upstream → Atomic 2026-10-11 23:37:28 +02:00
src p2p: BIP158 matching in WebAssembly (gcs.c), Number-based JS fallback; Blockbook upstream → Atomic 2026-10-11 23:37:28 +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 p2p: BIP158 matching in WebAssembly (gcs.c), Number-based JS fallback; Blockbook upstream → Atomic 2026-10-11 23:37:28 +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).