Skip to content

feat: add esplora-compatible block and transaction endpoints#7

Merged
elsirion merged 1 commit intoelsirion:masterfrom
douglaz:fix/block-raw-binary-response
Jan 14, 2026
Merged

feat: add esplora-compatible block and transaction endpoints#7
elsirion merged 1 commit intoelsirion:masterfrom
douglaz:fix/block-raw-binary-response

Conversation

@douglaz
Copy link
Copy Markdown
Collaborator

@douglaz douglaz commented Jan 13, 2026

Summary

Primary fix: The /api/block/{hash}/raw endpoint now correctly returns raw binary block data with Content-Type: application/octet-stream instead of hex-encoded text. This matches the real esplora API behavior (blockstream.info/mempool.space).

Additional endpoints added:

  • /api/block/{hash}/header - returns 80-byte block header as hex
  • /api/tx/{txid}/merkle-proof - returns JSON with block_height, merkle array, and pos

Development tooling:

  • justfile with common dev commands (just run, just test, just build, etc.)
  • scripts/run-local.sh - run minipool with Bitcoin Core cookie auth from ~/.bitcoin
  • scripts/test-endpoints.sh - comprehensive test suite comparing against blockstream.info

Other changes:

  • Updated flake inputs to Rust 1.92.0
  • Added just to devShell

Test plan

All 16 endpoint tests pass against blockstream.info:

Total tests: 16
Passed: 16
Failed: 0
Skipped: 0

Run tests with a single command (requires local Bitcoin Core with cookie auth):

nix develop -c just run-and-test

Or manually in separate terminals:

nix develop -c just run   # terminal 1
nix develop -c just test http://127.0.0.1:9090  # terminal 2

@douglaz douglaz force-pushed the fix/block-raw-binary-response branch 2 times, most recently from 3db5659 to 8fafba8 Compare January 14, 2026 00:31
@douglaz douglaz changed the title fix: return binary data for /api/block/{hash}/raw endpoint feat: add esplora-compatible block and transaction endpoints Jan 14, 2026
@douglaz douglaz force-pushed the fix/block-raw-binary-response branch from 8fafba8 to 92d9ea5 Compare January 14, 2026 00:38
Add new esplora API endpoints:
- GET /api/block/{hash}/header - returns 80-byte block header as hex
- GET /api/tx/{txid}/merkle-proof - returns merkle proof in Electrum format

Other changes:
- Fix /api/block/{hash}/raw to return binary data instead of hex
- Add unit tests for compute_merkle_proof function
- Add minipool-test check to flake.nix for CI test execution
- Fix error handling when transaction not found in block
@douglaz douglaz force-pushed the fix/block-raw-binary-response branch from cc43eb7 to 5609007 Compare January 14, 2026 01:21
proof
}

/// GET /api/tx/{txid}/merkle-proof - Get merkle proof in JSON format
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL this API exists

@elsirion elsirion merged commit b8284ec into elsirion:master Jan 14, 2026
4 checks passed
@douglaz douglaz deleted the fix/block-raw-binary-response branch January 14, 2026 15:46
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.

2 participants