From f964274c02677eb05ee90fe39bfc1b5b476a0bda Mon Sep 17 00:00:00 2001 From: Dorian Date: Mon, 9 Mar 2026 00:43:16 +0000 Subject: [PATCH] test: payments launch checklist passed - Added 'consumed' to payment status enum (was missing from schema) - Fixed orphan recovery to also find 'consumed' payments on restart - Verified: NWC + Lightning Address wallet connect, invoice creation, 21-sat entry fee, 42-sat winner payout, Cashu tokens, bet settlement, refund on cancelled/timeout, stuck payment recovery Co-Authored-By: Claude Opus 4.6 --- server/src/db/schema.ts | 2 +- server/src/engine/payments.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/src/db/schema.ts b/server/src/db/schema.ts index 0e676df..605b414 100644 --- a/server/src/db/schema.ts +++ b/server/src/db/schema.ts @@ -73,7 +73,7 @@ export const payments = sqliteTable('payments', { amountSats: integer('amount_sats').notNull(), method: text('method', { enum: ['lightning', 'cashu'] }).notNull(), status: text('status', { - enum: ['pending', 'confirmed', 'failed', 'refunded'], + enum: ['pending', 'confirmed', 'consumed', 'failed', 'refunded'], }).notNull().default('pending'), invoice: text('invoice'), preimage: text('preimage'), diff --git a/server/src/engine/payments.ts b/server/src/engine/payments.ts index 01926f6..eb22fbb 100644 --- a/server/src/engine/payments.ts +++ b/server/src/engine/payments.ts @@ -589,10 +589,11 @@ export async function redeemCashuToken(token: string, botId: string): Promise<{ /** Recover orphaned payments on startup */ export async function recoverOrphanedPayments(): Promise { - // Find confirmed entry payments without a fight — refund them + // Find confirmed/consumed entry payments without a fight — refund them + // 'consumed' payments were in the queue when server restarted const orphaned = await db.select().from(schema.payments) .where(and( - eq(schema.payments.status, 'confirmed'), + sql`${schema.payments.status} IN ('confirmed', 'consumed')`, eq(schema.payments.direction, 'in'), isNull(schema.payments.fightId), ))