feat: payments schema + deps for Lightning ranked fights
Add payments and wallet_connections tables, new columns on fights (mode, pot_sats, payout_status) and bots (sats_won, sats_wagered, has_wallet). Install nostr-tools and @cashu/cashu-ts for NWC + ecash support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
6b139a076a
commit
e92f483e66
@@ -58,6 +58,34 @@ export function runMigrations() {
|
||||
);
|
||||
`)
|
||||
|
||||
sqlite.exec(`
|
||||
CREATE TABLE IF NOT EXISTS payments (
|
||||
id TEXT PRIMARY KEY,
|
||||
fight_id TEXT REFERENCES fights(id),
|
||||
bot_id TEXT NOT NULL REFERENCES bots(id),
|
||||
direction TEXT NOT NULL,
|
||||
amount_sats INTEGER NOT NULL,
|
||||
method TEXT NOT NULL,
|
||||
status TEXT NOT NULL DEFAULT 'pending',
|
||||
invoice TEXT,
|
||||
preimage TEXT,
|
||||
cashu_token TEXT,
|
||||
error_reason TEXT,
|
||||
created_at TEXT NOT NULL,
|
||||
confirmed_at TEXT,
|
||||
refunded_at TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS wallet_connections (
|
||||
id TEXT PRIMARY KEY,
|
||||
bot_id TEXT NOT NULL UNIQUE REFERENCES bots(id),
|
||||
method TEXT NOT NULL,
|
||||
connection_data TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
last_used_at TEXT
|
||||
);
|
||||
`)
|
||||
|
||||
// Column migrations for existing databases
|
||||
const migrations = [
|
||||
"ALTER TABLE bots ADD COLUMN archetype TEXT NOT NULL DEFAULT 'standard'",
|
||||
@@ -66,6 +94,14 @@ export function runMigrations() {
|
||||
"ALTER TABLE bots ADD COLUMN consecutive_errors INTEGER NOT NULL DEFAULT 0",
|
||||
"ALTER TABLE bots ADD COLUMN last_error_at TEXT",
|
||||
"ALTER TABLE bots ADD COLUMN customization TEXT",
|
||||
// Ranked fights columns
|
||||
"ALTER TABLE fights ADD COLUMN mode TEXT NOT NULL DEFAULT 'free'",
|
||||
"ALTER TABLE fights ADD COLUMN pot_sats INTEGER NOT NULL DEFAULT 0",
|
||||
"ALTER TABLE fights ADD COLUMN payout_status TEXT",
|
||||
// Bot sats tracking
|
||||
"ALTER TABLE bots ADD COLUMN sats_won INTEGER NOT NULL DEFAULT 0",
|
||||
"ALTER TABLE bots ADD COLUMN sats_wagered INTEGER NOT NULL DEFAULT 0",
|
||||
"ALTER TABLE bots ADD COLUMN has_wallet INTEGER NOT NULL DEFAULT 0",
|
||||
]
|
||||
|
||||
for (const sql of migrations) {
|
||||
|
||||
Reference in New Issue
Block a user