Skip to content

[Phase 2] feat(core): transaction fee lookup endpoint #84

@Tinna23

Description

@Tinna23

Overview

Add a GET /api/fees/transaction/:hash endpoint that proxies to Horizon's transaction endpoint, retrieves the fee charged for a specific transaction, and enriches it with historical context from our SQLite store.

Horizon Source

Horizon endpoint: GET https://horizon-testnet.stellar.org/transactions/:hash
Key field from response: fee_charged

Response Shape

{
  "hash": "abc123...",
  "fee_charged": 150,
  "ledger": 1234567,
  "created_at": "2026-03-21T10:00:00Z",
  "context": {
    "network_avg_fee": 110,
    "network_base_fee": 100,
    "percentile_rank": "p60",
    "verdict": "FAIR"
  }
}

Verdict Logic

Compare fee_charged against the network stats stored for the closest timestamp in SQLite:

  • fee_charged <= base_fee * 1.1 → `"OPTIMAL"
  • fee_charged <= avg_fee * 3 → `"OVERPAID"

Acceptance Criteria

  • GET /api/fees/transaction/:hash returns the above response shape
  • Proxies to Horizon testnet and extracts fee_charged
  • Looks up the closest timestamp match in SQLite for historical context
  • Calculates percentile_rank by comparing fee_charged against stored percentile values
  • Returns 404 with a clear error message if the transaction hash is not found on Horizon
  • Returns 400 if the hash format is clearly invalid (not 64 hex chars)
  • Unit tests for verdict logic covering all four cases
  • CORS headers consistent with existing endpoints

Notes

  • Related frontend issue: [Phase 2] feat(ui): dashboard — transaction lookup page

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBackend / Rust core work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions