feat: add fedimint-critical esplora endpoints#6
Merged
elsirion merged 1 commit intoelsirion:masterfrom Jan 6, 2026
Merged
Conversation
63706f3 to
e3346e2
Compare
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
e3346e2 to
2f6fceb
Compare
Owner
|
Do we need all these endpoints? I remember explicitly optimizing for |
elsirion
approved these changes
Jan 6, 2026
Owner
elsirion
left a comment
There was a problem hiding this comment.
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), | ||
| ), |
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), | ||
| ), |
Comment on lines
+267
to
+271
| RouteInfo::new( | ||
| "/api/block/{hash}", | ||
| "Get block information for a specific block hash.", | ||
| get(get_block_info), | ||
| ), |
Owner
There was a problem hiding this comment.
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), | ||
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds esplora endpoints required for fedimint compatibility.
New Endpoints
GET /api/block/{hash}- Block info in esplora JSON formatGET /api/blocks/tip/hash- Best block hashGET /api/tx/{txid}- Transaction details with vin/vout arrays and confirmation statusGET /api/tx/{txid}/status- Transaction confirmation statusGET /api/tx/{txid}/merkleblock-proof- Merkle inclusion proof for transaction verificationPOST /api/tx- Transaction broadcast with input validationImplementation Details
bitcoin::TransactionTxStatushelper for consistent status constructionMAX_TX_HEX_SIZElimit (800KB)is_not_found_error()helperTest Plan
Tested manually against mainnet Bitcoin Core:
/api/blocks/tip/hashreturns 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}/statusreturns JSON with block_height populated/api/tx/{txid}/merkleblock-proofreturns hex-encoded proofPOST /api/txvalidates: empty body (400), invalid hex (400), too large (400), invalid tx (400)Endpoints Summary
The proxy now supports 11 endpoints:
/health/api/blocks/tip/height/api/blocks/tip/hash/api/block-height/{height}/api/fee-estimates/api/block/{hash}/raw/api/block/{hash}/api/tx/{txid}/api/tx/{txid}/status/api/tx/{txid}/merkleblock-proofPOST /api/tx