Wallet, NWC, and Payment Services Implementation Plan

Status: in progress; Phases 0-4 complete for unbound interactive NWC connections

Related design: WALLET_NWC_PAYMENTS.md

Goal

Introduce a first-party NIP-47 client, named NWC wallet management, safe monetary types, and core payment service boundaries without adding a third-party payment dependency. Deliver the protocol and wallet infrastructure first, then add interactive payment UX, Cashu integration, and scheduled automation in separate phases.

Delivery Principles

Phase 0: Prompt Context Boundary

Status: complete in the current working tree

Follow-up outside the wallet critical path:

Phase 1: Exact Monetary Types

Status: complete

Proposed files:

src/payments/amount.ts
src/payments/types.ts

Exit criteria:

Phase 2: NWC Protocol Foundation

Status: complete

Proposed files:

src/nwc/connection.ts
src/nwc/errors.ts
src/nwc/protocol.ts
src/nwc/schemas.ts
src/nwc/types.ts

Exit criteria:

Phase 3: First-Party NWC Client

Status: complete

Proposed files:

src/nwc/client.ts
src/nwc/transport.ts

Verification scenarios:

Exit criteria:

Phase 4: NWC Connection Persistence And Commands

Status: complete for unbound interactive connections; automation metadata is deferred to Phase 10

Proposed files:

src/nwc/state.ts
src/commands/nwc/definition.ts
src/commands/nwc/handler.ts
src/commands/nwc/...renderers...

Verification scenarios:

Exit criteria:

Phase 5: Command Namespace And Aggregate Wallet View

Exit criteria:

Phase 6: Interactive Payment Contracts And Core Broker

Proposed files:

src/payments/interactive-types.ts
src/payments/validation.ts
src/payments/service.ts
src/payments/lightning-invoice.ts

Exit criteria:

Phase 7: Core Payment Modal And Provider Adapters

Proposed areas:

src/payments/web-prompt.ts
src/web/ws-schema.ts
src/web/ws.ts
web/src/payments/

Verification scenarios:

Exit criteria:

Phase 8: Migrate Existing Lightning Payments

Exit criteria:

Phase 9: Cashu Payment Adapter

Exit criteria:

Phase 10: Automation Connections And Scoped Plugin API

Exit criteria:

Phase 11: Scheduler V3 Payment Policy

Exit criteria:

Phase 12: NR Zap Receipt Support

Exit criteria:

Deferred Work

Verification Commands

Run after each applicable phase:

bunx tsc --noEmit
bunx eslint <touched files>
bunx prettier --check <touched files>
git diff --check

Also run each modified installed plugin repository's available verification and patch checks separately because plugins/ contains independent Git repositories and is ignored by the AppWeaver core repository.