Skip to content

feat: add fedimint-critical esplora endpoints#6

Merged
elsirion merged 1 commit intoelsirion:masterfrom
douglaz:feature/fedimint-phase1-endpoints
Jan 6, 2026
Merged

feat: add fedimint-critical esplora endpoints#6
elsirion merged 1 commit intoelsirion:masterfrom
douglaz:feature/fedimint-phase1-endpoints

Conversation

@douglaz
Copy link
Copy Markdown
Collaborator

@douglaz douglaz commented Jan 6, 2026

Summary

Adds esplora endpoints required for fedimint compatibility.

New Endpoints

  • GET /api/block/{hash} - Block info in esplora JSON format
  • GET /api/blocks/tip/hash - Best block hash
  • GET /api/tx/{txid} - Transaction details with vin/vout arrays and confirmation status
  • GET /api/tx/{txid}/status - Transaction confirmation status
  • GET /api/tx/{txid}/merkleblock-proof - Merkle inclusion proof for transaction verification
  • POST /api/tx - Transaction broadcast with input validation

Implementation Details

  • Proper BIP-141 weight calculation using bitcoin::Transaction
  • TxStatus helper for consistent status construction
  • DoS protection with MAX_TX_HEX_SIZE limit (800KB)
  • Consistent error handling with is_not_found_error() helper
  • Optional fee field (requires prevout lookup to calculate)
  • Proper 400/404/500 error code semantics
  • Generic error messages to prevent information leakage

Test Plan

Tested manually against mainnet Bitcoin Core:

  • /api/blocks/tip/hash returns 64-char hex block hash
  • /api/block/{hash} returns correct esplora JSON format
  • /api/tx/{txid} includes vin/vout with scriptsig, witness data
  • /api/tx/{txid}/status returns JSON with block_height populated
  • /api/tx/{txid}/merkleblock-proof returns hex-encoded proof
  • POST /api/tx validates: empty body (400), invalid hex (400), too large (400), invalid tx (400)
  • Error cases return appropriate status codes (400/404/500)

Endpoints Summary

The proxy now supports 11 endpoints:

Endpoint Description
/health Health check (returns tip height)
/api/blocks/tip/height Current blockchain tip height
/api/blocks/tip/hash Best block hash
/api/block-height/{height} Block hash for specific height
/api/fee-estimates Fee estimates for confirmation targets
/api/block/{hash}/raw Raw block data
/api/block/{hash} Block info (esplora JSON)
/api/tx/{txid} Transaction details (esplora JSON)
/api/tx/{txid}/status Transaction confirmation status
/api/tx/{txid}/merkleblock-proof Merkle inclusion proof
POST /api/tx Broadcast raw transaction

@douglaz douglaz changed the title feat: add fedimint-critical esplora endpoints feat: add fedimint-critical esplora endpoints (Phase 1 + high-priority) Jan 6, 2026
@douglaz douglaz force-pushed the feature/fedimint-phase1-endpoints branch from 63706f3 to e3346e2 Compare January 6, 2026 18:21
Add esplora API endpoints required for Fedimint integration:

New endpoints:
- POST /api/tx - Broadcast raw transaction
- GET /api/tx/{txid} - Get transaction details
- GET /api/tx/{txid}/status - Get confirmation status
- GET /api/tx/{txid}/merkleblock-proof - Get merkle inclusion proof
- GET /api/block/{hash} - Get block information
- GET /api/blocks/tip/hash - Get best block hash

Implementation details:
- Proper BIP-141 weight calculation using bitcoin::Transaction
- TxStatus helper for consistent status construction
- DoS protection with MAX_TX_HEX_SIZE limit (800KB)
- Consistent error handling with is_not_found_error() helper
- Optional fee field (requires prevout lookup to calculate)
- Proper 400/404/500 error code semantics

Security:
- Generic error messages to prevent information leakage
- Input validation before RPC calls
@douglaz douglaz force-pushed the feature/fedimint-phase1-endpoints branch from e3346e2 to 2f6fceb Compare January 6, 2026 18:25
@douglaz douglaz changed the title feat: add fedimint-critical esplora endpoints (Phase 1 + high-priority) feat: add fedimint-critical esplora endpoints Jan 6, 2026
@douglaz douglaz marked this pull request as ready for review January 6, 2026 18:31
@elsirion
Copy link
Copy Markdown
Owner

elsirion commented Jan 6, 2026

Do we need all these endpoints? I remember explicitly optimizing for fedimintd compatibility. These look a lot like what a client/gateway would need.

Copy link
Copy Markdown
Owner

@elsirion elsirion left a comment

Choose a reason for hiding this comment

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

The only thing that I think was missing is tx submission, the others seem not entirely necessary, but possibly useful for other processes relying on an esplora-like API

Comment on lines +287 to +291
RouteInfo::new_post(
"/api/tx",
"Broadcast a raw transaction (hex-encoded in body).",
post(broadcast_transaction),
),
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.

This was definitely needed

Comment on lines +272 to +286
RouteInfo::new(
"/api/tx/{txid}",
"Get transaction information for a specific txid.",
get(get_transaction),
),
RouteInfo::new(
"/api/tx/{txid}/status",
"Get transaction confirmation status.",
get(get_tx_status),
),
RouteInfo::new(
"/api/tx/{txid}/merkleblock-proof",
"Get merkle inclusion proof for a transaction.",
get(get_tx_merkleblock_proof),
),
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.

Likely not relevant

Comment on lines +267 to +271
RouteInfo::new(
"/api/block/{hash}",
"Get block information for a specific block hash.",
get(get_block_info),
),
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.

Fedimint uses the /api/block/{hash}/raw endpoint, but if you have a use case for this one fine

Comment on lines +247 to +251
RouteInfo::new(
"/api/blocks/tip/hash",
"Get the best block hash.",
get(get_tip_hash),
),
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.

Unclear why this is needed

@elsirion elsirion merged commit 7f44840 into elsirion:master Jan 6, 2026
3 of 4 checks passed
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