import type { LightningProvider, Invoice } from 'l402-kit';
class MyProvider implements LightningProvider {
async createInvoice(amountSats: number): Promise<Invoice> {
// Call your Lightning node API
const result = await myNode.createInvoice(amountSats);
const macaroon = Buffer.from(
JSON.stringify({ hash: result.hash, exp: Date.now() + 3_600_000 })
).toString('base64');
return {
paymentRequest: result.bolt11,
paymentHash: result.hash,
macaroon,
amountSats,
expiresAt: Date.now() + 3_600_000,
};
}
async checkPayment(paymentHash: string): Promise<boolean> {
return myNode.isPaid(paymentHash);
}
}