Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Get Tx by Hash API #13

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions electrumx/server/session/http_unified_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def mount_routes(self, router: UrlDispatcher):
router.add_get("/v2/arc20/holders/{id}", self.get_arc20_holders)
router.add_get("/v2/arc20/info/{id}", self.get_arc20_token)
router.add_get("/v2/arc20/utxos/wallet/{wallet}", self.get_arc20_utxos)
router.add_get("/v2/arc20/transactions/hash/{hash}", self.get_arc20_transaction_by_hash)

def _resolve_ticker_to_atomical_id(self, ticker: str) -> bytes | None:
bp = self.session_mgr.bp
Expand Down Expand Up @@ -735,6 +736,18 @@ async def get_arc20_transactions(self, request: "Request") -> "Response":
}
)

@error_handler
async def get_arc20_transaction_by_hash(self, request: "Request") -> "Response":
tx_hash = request.match_info.get("hash", "")
if not hash:
return format_response(None, 400, "Hash is required.")

tx = await self._get_tx_detail(tx_hash, None, None)
if not tx:
return format_response(None, 404, "transaction not found.")

return format_response(tx)

async def _get_arc20_holders_by_block_height(self, atomical_id: bytes, block_height: int) -> dict:
utxos = await self.session_mgr.db.get_atomical_utxos_at_height_by_atomical_id(atomical_id, block_height)

Expand Down
Loading