Some checks are pending
Docker Compose Actions Workflow / test (push) Waiting to run
## 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 - [x] Review extension loader code for correctness - [x] Verify TypeScript compilation succeeds - [x] Test extension discovery from `src/extensions/` directory - [x] Test RPC method registration and routing - [x] Test database isolation between extensions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: boufni95 <boufni95@gmail.com> Co-authored-by: Patrick Mulligan <patjmulligan@protonmail.com> Reviewed-on: #3
199 lines
9 KiB
TypeScript
199 lines
9 KiB
TypeScript
// @generated by protobuf-ts 2.11.1
|
|
// @generated from protobuf file "invoices.proto" (package "invoicesrpc", syntax proto3)
|
|
// tslint:disable
|
|
import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
|
|
import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
|
|
import { Invoices } from "./invoices.js";
|
|
import type { HtlcModifyRequest } from "./invoices.js";
|
|
import type { HtlcModifyResponse } from "./invoices.js";
|
|
import type { DuplexStreamingCall } from "@protobuf-ts/runtime-rpc";
|
|
import type { LookupInvoiceMsg } from "./invoices.js";
|
|
import type { SettleInvoiceResp } from "./invoices.js";
|
|
import type { SettleInvoiceMsg } from "./invoices.js";
|
|
import type { AddHoldInvoiceResp } from "./invoices.js";
|
|
import type { AddHoldInvoiceRequest } from "./invoices.js";
|
|
import type { CancelInvoiceResp } from "./invoices.js";
|
|
import type { CancelInvoiceMsg } from "./invoices.js";
|
|
import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
import { stackIntercept } from "@protobuf-ts/runtime-rpc";
|
|
import type { Invoice } from "./lightning.js";
|
|
import type { SubscribeSingleInvoiceRequest } from "./invoices.js";
|
|
import type { ServerStreamingCall } from "@protobuf-ts/runtime-rpc";
|
|
import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
|
|
//
|
|
// Comments in this file will be directly parsed into the API
|
|
// Documentation as descriptions of the associated method, message, or field.
|
|
// These descriptions should go right above the definition of the object, and
|
|
// can be in either block or // comment format.
|
|
//
|
|
// An RPC method can be matched to an lncli command by placing a line in the
|
|
// beginning of the description in exactly the following format:
|
|
// lncli: `methodname`
|
|
//
|
|
// Failure to specify the exact name of the command will cause documentation
|
|
// generation to fail.
|
|
//
|
|
// More information on how exactly the gRPC documentation is generated from
|
|
// this proto file can be found here:
|
|
// https://github.com/lightninglabs/lightning-api
|
|
|
|
/**
|
|
* Invoices is a service that can be used to create, accept, settle and cancel
|
|
* invoices.
|
|
*
|
|
* @generated from protobuf service invoicesrpc.Invoices
|
|
*/
|
|
export interface IInvoicesClient {
|
|
/**
|
|
*
|
|
* SubscribeSingleInvoice returns a uni-directional stream (server -> client)
|
|
* to notify the client of state transitions of the specified invoice.
|
|
* Initially the current invoice state is always sent out.
|
|
*
|
|
* @generated from protobuf rpc: SubscribeSingleInvoice
|
|
*/
|
|
subscribeSingleInvoice(input: SubscribeSingleInvoiceRequest, options?: RpcOptions): ServerStreamingCall<SubscribeSingleInvoiceRequest, Invoice>;
|
|
/**
|
|
* lncli: `cancelinvoice`
|
|
* CancelInvoice cancels a currently open invoice. If the invoice is already
|
|
* canceled, this call will succeed. If the invoice is already settled, it will
|
|
* fail.
|
|
*
|
|
* @generated from protobuf rpc: CancelInvoice
|
|
*/
|
|
cancelInvoice(input: CancelInvoiceMsg, options?: RpcOptions): UnaryCall<CancelInvoiceMsg, CancelInvoiceResp>;
|
|
/**
|
|
* lncli: `addholdinvoice`
|
|
* AddHoldInvoice creates a hold invoice. It ties the invoice to the hash
|
|
* supplied in the request.
|
|
*
|
|
* @generated from protobuf rpc: AddHoldInvoice
|
|
*/
|
|
addHoldInvoice(input: AddHoldInvoiceRequest, options?: RpcOptions): UnaryCall<AddHoldInvoiceRequest, AddHoldInvoiceResp>;
|
|
/**
|
|
* lncli: `settleinvoice`
|
|
* SettleInvoice settles an accepted invoice. If the invoice is already
|
|
* settled, this call will succeed.
|
|
*
|
|
* @generated from protobuf rpc: SettleInvoice
|
|
*/
|
|
settleInvoice(input: SettleInvoiceMsg, options?: RpcOptions): UnaryCall<SettleInvoiceMsg, SettleInvoiceResp>;
|
|
/**
|
|
*
|
|
* LookupInvoiceV2 attempts to look up at invoice. An invoice can be referenced
|
|
* using either its payment hash, payment address, or set ID.
|
|
*
|
|
* @generated from protobuf rpc: LookupInvoiceV2
|
|
*/
|
|
lookupInvoiceV2(input: LookupInvoiceMsg, options?: RpcOptions): UnaryCall<LookupInvoiceMsg, Invoice>;
|
|
/**
|
|
*
|
|
* HtlcModifier is a bidirectional streaming RPC that allows a client to
|
|
* intercept and modify the HTLCs that attempt to settle the given invoice. The
|
|
* server will send HTLCs of invoices to the client and the client can modify
|
|
* some aspects of the HTLC in order to pass the invoice acceptance tests.
|
|
*
|
|
* @generated from protobuf rpc: HtlcModifier
|
|
*/
|
|
htlcModifier(options?: RpcOptions): DuplexStreamingCall<HtlcModifyResponse, HtlcModifyRequest>;
|
|
}
|
|
//
|
|
// Comments in this file will be directly parsed into the API
|
|
// Documentation as descriptions of the associated method, message, or field.
|
|
// These descriptions should go right above the definition of the object, and
|
|
// can be in either block or // comment format.
|
|
//
|
|
// An RPC method can be matched to an lncli command by placing a line in the
|
|
// beginning of the description in exactly the following format:
|
|
// lncli: `methodname`
|
|
//
|
|
// Failure to specify the exact name of the command will cause documentation
|
|
// generation to fail.
|
|
//
|
|
// More information on how exactly the gRPC documentation is generated from
|
|
// this proto file can be found here:
|
|
// https://github.com/lightninglabs/lightning-api
|
|
|
|
/**
|
|
* Invoices is a service that can be used to create, accept, settle and cancel
|
|
* invoices.
|
|
*
|
|
* @generated from protobuf service invoicesrpc.Invoices
|
|
*/
|
|
export class InvoicesClient implements IInvoicesClient, ServiceInfo {
|
|
typeName = Invoices.typeName;
|
|
methods = Invoices.methods;
|
|
options = Invoices.options;
|
|
constructor(private readonly _transport: RpcTransport) {
|
|
}
|
|
/**
|
|
*
|
|
* SubscribeSingleInvoice returns a uni-directional stream (server -> client)
|
|
* to notify the client of state transitions of the specified invoice.
|
|
* Initially the current invoice state is always sent out.
|
|
*
|
|
* @generated from protobuf rpc: SubscribeSingleInvoice
|
|
*/
|
|
subscribeSingleInvoice(input: SubscribeSingleInvoiceRequest, options?: RpcOptions): ServerStreamingCall<SubscribeSingleInvoiceRequest, Invoice> {
|
|
const method = this.methods[0], opt = this._transport.mergeOptions(options);
|
|
return stackIntercept<SubscribeSingleInvoiceRequest, Invoice>("serverStreaming", this._transport, method, opt, input);
|
|
}
|
|
/**
|
|
* lncli: `cancelinvoice`
|
|
* CancelInvoice cancels a currently open invoice. If the invoice is already
|
|
* canceled, this call will succeed. If the invoice is already settled, it will
|
|
* fail.
|
|
*
|
|
* @generated from protobuf rpc: CancelInvoice
|
|
*/
|
|
cancelInvoice(input: CancelInvoiceMsg, options?: RpcOptions): UnaryCall<CancelInvoiceMsg, CancelInvoiceResp> {
|
|
const method = this.methods[1], opt = this._transport.mergeOptions(options);
|
|
return stackIntercept<CancelInvoiceMsg, CancelInvoiceResp>("unary", this._transport, method, opt, input);
|
|
}
|
|
/**
|
|
* lncli: `addholdinvoice`
|
|
* AddHoldInvoice creates a hold invoice. It ties the invoice to the hash
|
|
* supplied in the request.
|
|
*
|
|
* @generated from protobuf rpc: AddHoldInvoice
|
|
*/
|
|
addHoldInvoice(input: AddHoldInvoiceRequest, options?: RpcOptions): UnaryCall<AddHoldInvoiceRequest, AddHoldInvoiceResp> {
|
|
const method = this.methods[2], opt = this._transport.mergeOptions(options);
|
|
return stackIntercept<AddHoldInvoiceRequest, AddHoldInvoiceResp>("unary", this._transport, method, opt, input);
|
|
}
|
|
/**
|
|
* lncli: `settleinvoice`
|
|
* SettleInvoice settles an accepted invoice. If the invoice is already
|
|
* settled, this call will succeed.
|
|
*
|
|
* @generated from protobuf rpc: SettleInvoice
|
|
*/
|
|
settleInvoice(input: SettleInvoiceMsg, options?: RpcOptions): UnaryCall<SettleInvoiceMsg, SettleInvoiceResp> {
|
|
const method = this.methods[3], opt = this._transport.mergeOptions(options);
|
|
return stackIntercept<SettleInvoiceMsg, SettleInvoiceResp>("unary", this._transport, method, opt, input);
|
|
}
|
|
/**
|
|
*
|
|
* LookupInvoiceV2 attempts to look up at invoice. An invoice can be referenced
|
|
* using either its payment hash, payment address, or set ID.
|
|
*
|
|
* @generated from protobuf rpc: LookupInvoiceV2
|
|
*/
|
|
lookupInvoiceV2(input: LookupInvoiceMsg, options?: RpcOptions): UnaryCall<LookupInvoiceMsg, Invoice> {
|
|
const method = this.methods[4], opt = this._transport.mergeOptions(options);
|
|
return stackIntercept<LookupInvoiceMsg, Invoice>("unary", this._transport, method, opt, input);
|
|
}
|
|
/**
|
|
*
|
|
* HtlcModifier is a bidirectional streaming RPC that allows a client to
|
|
* intercept and modify the HTLCs that attempt to settle the given invoice. The
|
|
* server will send HTLCs of invoices to the client and the client can modify
|
|
* some aspects of the HTLC in order to pass the invoice acceptance tests.
|
|
*
|
|
* @generated from protobuf rpc: HtlcModifier
|
|
*/
|
|
htlcModifier(options?: RpcOptions): DuplexStreamingCall<HtlcModifyResponse, HtlcModifyRequest> {
|
|
const method = this.methods[5], opt = this._transport.mergeOptions(options);
|
|
return stackIntercept<HtlcModifyResponse, HtlcModifyRequest>("duplex", this._transport, method, opt);
|
|
}
|
|
}
|