Skip to content

Conversation

@shruggr
Copy link

@shruggr shruggr commented Dec 16, 2025

Summary

  • Add v2 RESTful routes with path parameters matching go-chaintracks API style (/v2/tip, /v2/header/height/:height, /v2/header/hash/:hash, /v2/headers)
  • Add binary routes returning 80-byte headers with height in X-Block-Height HTTP header (.bin suffix variants)
  • Extract v1 RPC-style routes to separate module for legacy compatibility
  • Switch from ChaintracksService.startJsonRpcServer() to custom Express app mounting both v1 and v2 routes

Routes Added

V2 JSON Routes

  • GET /v2/network - Get blockchain network name
  • GET /v2/tip - Get chain tip header
  • GET /v2/header/height/:height - Get header by height
  • GET /v2/header/hash/:hash - Get header by hash
  • GET /v2/headers?height=N&count=M - Get multiple headers

V2 Binary Routes

  • GET /v2/tip.bin - Chain tip as 80-byte binary
  • GET /v2/header/height/:height.bin - Header by height as binary
  • GET /v2/header/hash/:hash.bin - Header by hash as binary
  • GET /v2/headers.bin?height=N&count=M - Multiple headers as binary

Binary routes return raw 80-byte block headers with X-Block-Height HTTP header for height metadata. Hash fields (previousHash, merkleRoot) are correctly converted from display format (byte-reversed) to internal byte order for binary serialization.

- Add v2 routes with RESTful path parameters (/v2/tip, /v2/header/height/:height, etc.)
- Add binary routes returning 80-byte headers with X-Block-Height HTTP header
- Extract v1 RPC-style routes to separate module for legacy compatibility
- Switch from ChaintracksService.startJsonRpcServer() to custom Express app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant