import { randomBytes } from "crypto"; export interface LNbitsInvoice { paymentHash: string; paymentRequest: string; } export interface LNbitsInvoiceStatus { paid: boolean; paidAt?: Date; } const paidInvoices = new Set(); export async function createInvoice( amountSats: number, memo: string, ): Promise { const paymentHash = randomBytes(32).toString("hex"); const paymentRequest = `lnbcrt${amountSats}u1stub_${paymentHash.slice(0, 16)}`; console.log(`[stub] Created invoice: ${amountSats} sats — "${memo}" — hash=${paymentHash}`); return { paymentHash, paymentRequest }; } export async function checkInvoicePaid( paymentHash: string, ): Promise { if (paidInvoices.has(paymentHash)) { return { paid: true, paidAt: new Date() }; } return { paid: false }; } export function markInvoicePaid(paymentHash: string): void { paidInvoices.add(paymentHash); console.log(`[stub] Marked invoice paid: hash=${paymentHash}`); }