Skip to content

feat(escrow): escrow session lifecycle — create, fund, settle - #35

Merged
comwanga merged 4 commits into
mainfrom
feat/escrow-agent-discovery
Aug 8, 2026
Merged

feat(escrow): escrow session lifecycle — create, fund, settle#35
comwanga merged 4 commits into
mainfrom
feat/escrow-agent-discovery

Conversation

@comwanga

@comwanga comwanga commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the full escrow session lifecycle on top of the existing agent discovery layer. Agents are service providers, escrows are transaction instances, wallets are payment tools — these three concepts are now cleanly separated.

Flow

Agent discovery → Use this agent → Create escrow → Fund → Settle

Backend

  • Escrow modelescrows table with state machine: draftawaiting_fundingfundedactiverelease_pendingreleased, plus cancelled, refunded, disputed, failed, expired
  • API router at /api/v1/escrows: POST create, GET list (with status filter), GET detail, POST activate, POST fund (generates bolt11 invoice), POST confirm-funded, POST release, POST cancel
  • Escrow service with validated state transitions
  • 13 backend tests covering full lifecycle

Frontend

Route What
/dashboard/escrows List — active escrows grouped at top, past escrows below, status badges, agent labels, amounts
/dashboard/escrows/create?agent=<coordinate> Create form — agent pre-filled from "Use this agent", amount, rail selector (lightning/bitcoin/spark), review card, cancel/create buttons
/dashboard/escrows/[id] Detail + funding — progress steps, escrow details card, NWC one-click pay, manual invoice with copy, confirm-funded dialog, terminal state cards

Wiring

  • "Use this agent" in the agent detail dialog now routes to /dashboard/escrows/create?agent=<coordinate>
  • Escrows nav item (Wallet icon) added to sidebar between Agent and Settings
  • NWC one-click pay reuses existing lib/lightning.ts

Out of scope (future)

  • Agent-side status event publication to Nostr
  • Automatic escrow state detection from relay subscription
  • Multi-token support
  • Escrow fee collection
  • Reputation/ratings
  • Dispute mediation

Adds a full escrow session flow on top of the agent discovery layer:

- Escrow model with state machine (draft → awaiting_funding → funded →
  active → release_pending → released, plus cancel/refund/dispute paths)
- API router at /api/v1/escrows: create, list, get, activate, fund,
  confirm-funded, release, cancel
- Pydantic schemas and escrow_service with validated state transitions

Frontend:
- /dashboard/escrows — list view with active/past grouping, status badges,
  agent labels, amounts
- /dashboard/escrows/create?agent=<coordinate> — create form with amount,
  rail selector (lightning/bitcoin/spark), review card
- /dashboard/escrows/[id] — detail view with progress steps, funding
  screen (NWC wallet + manual invoice), status cards for each state
- Sidebar nav: Escrows (Wallet icon)

Wiring:
- 'Use this agent' in agent detail dialog now routes to create escrow
  with the agent coordinate pre-filled
- NWC one-click pay reuses existing lib/lightning.ts payWithNwc

Tests:
- backend/tests/test_escrow_sessions.py: 13 tests covering create, list,
  filter, 403, activate, fund, full lifecycle, cancel, amount validation
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
squadsync Ready Ready Preview Aug 8, 2026 8:07pm

@comwanga
comwanga marked this pull request as ready for review August 8, 2026 20:10
@comwanga
comwanga merged commit 80a5ca1 into main Aug 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant