Skip to content

[P2] Channels: Off-chain state update signing and exchange protocol #845

Description

@Calebux

Parent Issue

#825

Summary

Implement the off-chain protocol for exchanging signed balance updates between user and renewal executor during each billing cycle.

Details

  • Each state update = { channel_id, balance_user, balance_executor, sequence_number }
  • Both parties sign the state update (user via Freighter, executor via backend key)
  • State updates are exchanged via a simple HTTP API (or WebSocket for real-time)
  • Both parties persist the latest signed state locally
  • Sequence number monotonically increases — higher seq always supersedes lower

Affected Code

  • New: backend/src/services/channel-state.ts — state management + signing
  • New: backend/src/routes/channels.ts — HTTP endpoints for state exchange
  • client/lib/ — new payment-channel.ts client
  • DB: new payment_channels and channel_states tables

Acceptance Criteria

  • Both parties can sign and exchange state updates
  • Latest state is persisted and recoverable
  • Invalid signatures are rejected
  • Sequence number ordering is enforced

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programprivacyPrivacy-preserving features

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions