feat(extensions): add extension loader infrastructure #3

Merged
padreug merged 15 commits from feature/extension-loader into dev 2026-04-02 18:47:55 +00:00
Owner

Summary

  • Adds a modular extension system for Lightning.Pub enabling third-party plugins
  • Provides isolated SQLite databases per extension for data safety
  • Implements ExtensionContext API for accessing Lightning.Pub services (payments, Nostr, storage)
  • Supports RPC method registration with automatic namespacing
  • Includes HTTP route handling for protocols like LNURL
  • Event routing for payment receipts and Nostr events
  • Comprehensive documentation with architecture overview and working examples

Key Components

  • src/extensions/types.ts - Core extension interfaces
  • src/extensions/loader.ts - Extension discovery, loading, and lifecycle management
  • src/extensions/context.ts - Bridge between extensions and Lightning.Pub services
  • src/extensions/database.ts - SQLite isolation with WAL mode
  • src/extensions/README.md - Full documentation with examples

ExtensionContext API

Method Description
getApplication() Get application info
createInvoice() Create Lightning invoice
payInvoice() Pay Lightning invoice
getLnurlPayInfo() Get LNURL-pay info for a user (enables Lightning Address/zaps)
sendEncryptedDM() Send Nostr DM (NIP-44)
publishNostrEvent() Publish Nostr event
registerMethod() Register RPC method
onPaymentReceived() Subscribe to payment callbacks
onNostrEvent() Subscribe to Nostr events

Test plan

  • Review extension loader code for correctness
  • Verify TypeScript compilation succeeds
  • Test extension discovery from src/extensions/ directory
  • Test RPC method registration and routing
  • Test database isolation between extensions

🤖 Generated with Claude Code

## Summary - Adds a modular extension system for Lightning.Pub enabling third-party plugins - Provides isolated SQLite databases per extension for data safety - Implements ExtensionContext API for accessing Lightning.Pub services (payments, Nostr, storage) - Supports RPC method registration with automatic namespacing - Includes HTTP route handling for protocols like LNURL - Event routing for payment receipts and Nostr events - Comprehensive documentation with architecture overview and working examples ## Key Components - `src/extensions/types.ts` - Core extension interfaces - `src/extensions/loader.ts` - Extension discovery, loading, and lifecycle management - `src/extensions/context.ts` - Bridge between extensions and Lightning.Pub services - `src/extensions/database.ts` - SQLite isolation with WAL mode - `src/extensions/README.md` - Full documentation with examples ## ExtensionContext API | Method | Description | |--------|-------------| | `getApplication()` | Get application info | | `createInvoice()` | Create Lightning invoice | | `payInvoice()` | Pay Lightning invoice | | `getLnurlPayInfo()` | Get LNURL-pay info for a user (enables Lightning Address/zaps) | | `sendEncryptedDM()` | Send Nostr DM (NIP-44) | | `publishNostrEvent()` | Publish Nostr event | | `registerMethod()` | Register RPC method | | `onPaymentReceived()` | Subscribe to payment callbacks | | `onNostrEvent()` | Subscribe to Nostr events | ## Test plan - [ ] Review extension loader code for correctness - [ ] Verify TypeScript compilation succeeds - [ ] Test extension discovery from `src/extensions/` directory - [ ] Test RPC method registration and routing - [ ] Test database isolation between extensions 🤖 Generated with [Claude Code](https://claude.com/claude-code)
padreug added 2 commits 2026-02-13 19:00:23 +00:00
Adds a modular extension system for Lightning.Pub that allows
third-party functionality to be added without modifying core code.

Features:
- ExtensionLoader: discovers and loads extensions from directory
- ExtensionContext: provides extensions with access to Lightning.Pub APIs
- ExtensionDatabase: isolated SQLite database per extension
- Lifecycle management: initialize, shutdown, health checks
- RPC method registration: extensions can add new RPC methods
- Event dispatching: routes payments and Nostr events to extensions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
docs(extensions): add comprehensive extension loader documentation
Some checks are pending
Docker Compose Actions Workflow / test (push) Waiting to run
b5d192b9fb
Covers architecture, API reference, lifecycle, database isolation,
RPC methods, HTTP routes, event handling, and complete examples.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
padreug added 1 commit 2026-02-13 20:06:29 +00:00
feat(extensions): add getLnurlPayInfo to ExtensionContext
Some checks failed
Docker Compose Actions Workflow / test (push) Has been cancelled
7a7b995b5c
Enables extensions to get LNURL-pay info for users by pubkey,
supporting Lightning Address (LUD-16) and zap (NIP-57) functionality.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
padreug added 3 commits 2026-02-16 22:03:00 +00:00
The @noble/curves secp256k1.getSharedSecret expects Uint8Array arguments,
not hex strings. Use hex.decode() to convert the private and public keys.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add .dockerignore for runtime state files (sqlite, logs, secrets)
- Bump Node.js base image from 18 to 20
- Add @types/better-sqlite3 dev dependency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: use fresh balance in PayAppUserInvoice notification
Some checks failed
Docker Compose Actions Workflow / test (push) Has been cancelled
c4edcb114d
notifyAppUserPayment was sending the stale cached balance from the
entity loaded before PayInvoice decremented it. Update the entity's
balance_sats from the PayInvoice response so LiveUserOperation events
contain the correct post-payment balance.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
padreug force-pushed feature/extension-loader from c4edcb114d to eb0278a82c 2026-02-28 12:54:12 +00:00 Compare
padreug force-pushed feature/extension-loader from eb0278a82c to 492fb8981a 2026-03-04 20:23:08 +00:00 Compare
padreug force-pushed feature/extension-loader from 492fb8981a to c308d4be78 2026-03-26 22:46:08 +00:00 Compare
padreug added 1 commit 2026-04-01 17:24:33 +00:00
fix(extensions): add HTTP route types and getHttpRoutes to Extension interface
Some checks are pending
Docker Compose Actions Workflow / test (push) Waiting to run
5cc7f3998c
HttpRoute, HttpRequest, and HttpResponse types were used by extensions
(withdraw, nip05) but not defined in the shared types.ts. Adds them
here so extensions import from the shared module instead of defining
locally. Also adds getHttpRoutes() as an optional method on the
Extension interface for extensions that expose HTTP endpoints.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
padreug force-pushed feature/extension-loader from 5cc7f3998c to a574a5b817 2026-04-02 18:46:45 +00:00 Compare
padreug merged commit 77e5772afd into dev 2026-04-02 18:47:55 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: aiolabs/lightning-pub#3
No description provided.