Skip to content

Implement Horizon streaming for real-time payment monitoring #19

Description

@prodbycorne

Overview

Classic Stellar payment operations to airdrop recipient addresses need to be tracked via Horizon's event streaming API. This enables confirming recipient payouts and detecting trust-line establishment in real time.

What to Stream

  • Payment operations to tracked recipient addresses
  • Trust line changes — detect when recipients establish the required trust line before claiming
  • Account created — detect when a new account is funded by an airdrop operation

Architecture

Horizon SSE (/accounts/:id/operations)
     │
     ▼
StreamManager (reconnects on disconnect, tracks cursor)
     │
     ▼
PaymentProcessor (validates, deduplicates, stores)
     │
     ▼
DB (payment_operations table) + Webhook dispatcher

Implementation

// src/indexer/horizonStream.js
const { Horizon } = require('@stellar/stellar-sdk');

class HorizonStreamManager {
  constructor(server, accounts) { ... }
  start() { /* opens SSE stream per tracked account */ }
  stop() { /* closes all streams */ }
  onPayment(handler) { ... }
}
  • Use stellar-sdk's server.operations().forAccount(id).stream()
  • Persist last paging token per account to DB
  • Resume from stored cursor on service restart
  • Reconnect with exponential backoff (1s → 5s → 30s)

Acceptance Criteria

  • HorizonStreamManager implemented
  • Streams payment operations for dynamically tracked addresses
  • Cursor persisted and resumed on restart
  • Auto-reconnects after stream disconnect
  • Payment events forwarded to webhook dispatcher
  • Stream health exposed in /api/v1/indexer/status
  • Unit tests with mocked Horizon SDK

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignfeatureNew feature or enhancementindexingBlockchain indexing and event streaming

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions