run402-mcp
Version:
MCP server for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.
74 lines • 3.1 kB
TypeScript
export declare const NWC_REQUEST_KIND = 23194;
export declare const NWC_RESPONSE_KIND = 23195;
export interface NwcConnection {
walletPubkey: string;
relayUrl: string;
secretHex: string;
clientPubkey: string;
}
/** Nostr wire time: unix seconds (the protocol's own field name). */
export type UnixSeconds = number;
export interface NwcNostrEvent {
id: string;
pubkey: string;
created_at: UnixSeconds;
kind: number;
tags: string[][];
content: string;
sig: string;
}
export declare class NwcError extends Error {
readonly code: string;
constructor(code: string, message: string);
}
export declare function parseNwcUri(uri: string): NwcConnection;
export declare function nip44ConversationKey(secretHex: string, peerPubkeyHex: string): Uint8Array;
export declare function nip44Encrypt(conversation: Uint8Array, plaintext: string, nonce?: Uint8Array): string;
export declare function nip44Decrypt(conversation: Uint8Array, payload: string): string;
export declare function signNwcEvent(secretHex: string, kind: number, tags: string[][], content: string): NwcNostrEvent;
/** Closes every standing relay connection (process exit, tests). */
export declare function closeNwcConnections(): void;
export type NwcTransport = (connection: NwcConnection, request: NwcNostrEvent, timeoutMs: number) => Promise<NwcNostrEvent>;
/**
* One NIP-47 call. Throws `NwcError` with the wallet's error code
* (`INSUFFICIENT_BALANCE`, `QUOTA_EXCEEDED`, `NOT_FOUND`, `UNAUTHORIZED`, …)
* or a transport code (`TIMEOUT`, `RELAY_UNREACHABLE`, `RELAY_REJECTED`, `RELAY_CLOSED`, `BAD_RESPONSE`).
*/
export declare function nwcRequest<T = Record<string, unknown>>(connection: NwcConnection, method: string, params: Record<string, unknown>, options?: {
timeoutMs?: number;
transport?: NwcTransport;
}): Promise<T>;
/** The agent-side wallet verbs the Lightning rail needs. Amounts are in sats. */
export declare class NwcWallet {
private readonly options;
private readonly connection;
constructor(pairingUri: string, options?: {
timeoutMs?: number;
transport?: NwcTransport;
});
private call;
/** The node behind the pairing: its network name, pubkey, and permitted methods. */
getInfo(): Promise<{
network: string | null;
pubkey: string | null;
methods: string[];
}>;
getBalanceSats(): Promise<number>;
/** Remaining budget in sats, or null when the wallet has no budget. */
getBudgetSats(): Promise<{
usedSats: number;
totalSats: number | null;
renewsAtSeconds: UnixSeconds | null;
} | null>;
/** Pays a BOLT11 invoice; returns the preimage (hex) the wallet reports. */
payInvoice(bolt11: string): Promise<{
preimage: string;
feesPaidMsat: number | null;
}>;
/** Looks an invoice up by payment hash; a settled outgoing payment carries its preimage. */
lookupInvoice(paymentHash: string): Promise<{
state: string | null;
preimage: string | null;
} | null>;
}
//# sourceMappingURL=nwc.d.ts.map