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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
50b85f5171
commit
f964274c02
@@ -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'),
|
||||
|
||||
@@ -589,10 +589,11 @@ export async function redeemCashuToken(token: string, botId: string): Promise<{
|
||||
|
||||
/** Recover orphaned payments on startup */
|
||||
export async function recoverOrphanedPayments(): Promise<void> {
|
||||
// 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),
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user