askexperts
Version:
AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol
77 lines (76 loc) • 2.58 kB
TypeScript
import { ExpertPaymentManager } from "./ExpertPaymentManager.js";
import { ExpertQuote, Invoice, Proof } from "../common/types.js";
/**
* LightningPaymentManager handles lightning payments using NWC
* with a limit on parallel payment operations
*/
export declare class LightningPaymentManager implements ExpertPaymentManager {
private nwcClient;
private maxParallelPayments;
private activePayments;
private paymentQueue;
/**
* Creates a new LightningPaymentManager
*
* @param nwcString - NWC connection string
* @param maxParallelPayments - Maximum number of parallel payments (default: 5)
*/
constructor(nwcString: string, maxParallelPayments?: number);
/**
* Pays a lightning invoice
*
* @param invoice - Lightning invoice to pay
* @returns Promise resolving to payment preimage
*/
payInvoice(invoice: string): Promise<string>;
/**
* Processes the next payment in the queue if any
* @private
*/
private processNextPayment;
/**
* Disposes of resources when the manager is no longer needed
*/
[Symbol.dispose](): void;
/**
* Creates a lightning invoice
*
* @param amount - Amount in satoshis
* @param description - Invoice description
* @param expiry - Expiry time in seconds (optional)
* @returns Promise resolving to an object containing the invoice and payment hash
*/
makeInvoice(amount: number, description: string, expiry?: number): Promise<{
invoice: string;
paymentHash: string;
}>;
/**
* Creates invoices for expert payment
*
* @param amountSats - Amount in satoshis
* @param description - Invoice description
* @param expirySec - Expiry time in seconds
* @returns Promise resolving to an array of invoices
*/
makeInvoices(amountSats: number, description: string, expirySec: number): Promise<Invoice[]>;
/**
* Verifies a payment using the preimage
*
* @param paymentHash - Payment hash to verify
* @param preimage - Payment preimage
* @throws Error if verification fails
*/
verifyLightningPayment({ invoice, payment_hash, preimage, }: {
invoice?: string;
payment_hash?: string;
preimage: string;
}): Promise<void>;
/**
* Verifies a payment
*
* @param quote - The expert quote containing invoices
* @param proof - The payment proof
* @throws Error if verification fails
*/
verifyPayment(quote: ExpertQuote, proof: Proof): Promise<void>;
}