feat: betting system — Cashu escrow, Lightning deposit/withdraw, payouts

Complete betting infrastructure:
- Bets schema (SQLite) with escrow status tracking
- Cashu token verification + minting (stub for real mint)
- Lightning invoice creation + withdrawal (stub for real LN node)
- Bet placement with odds lock, settlement on fight end
- Payout automation for winners, refunds on draws
- Bet history by pubkey + fight pool info
- Verifiable bet proofs for transparency
- API routes: /api/bets/{odds,place,fight,history,deposit,withdraw}

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-08 00:33:08 +00:00
co-authored by Claude Opus 4.6
parent 6ede5da675
commit a254a77151
5 changed files with 522 additions and 5 deletions
+17
View File
@@ -55,3 +55,20 @@ export const rounds = sqliteTable('rounds', {
narration: text('narration'),
createdAt: text('created_at').notNull(),
})
export const bets = sqliteTable('bets', {
id: text('id').primaryKey(),
fightId: text('fight_id').notNull().references(() => fights.id),
bettorPubkey: text('bettor_pubkey').notNull(),
botId: text('bot_id').notNull().references(() => bots.id),
amountSats: integer('amount_sats').notNull(),
oddsAtPlacement: real('odds_at_placement').notNull(),
cashuToken: text('cashu_token').notNull(),
status: text('status', {
enum: ['pending', 'locked', 'won', 'lost', 'refunded', 'paid'],
}).notNull().default('pending'),
payoutSats: integer('payout_sats'),
payoutToken: text('payout_token'),
createdAt: text('created_at').notNull(),
settledAt: text('settled_at'),
})