Remove blockchain dependence from credit flow:
- watch credits now DB-only
- webhook earnings now DB-only
- wallet balance now DB-only
- admin bonus/adjustment routes operate on DB totals
Add admin adjustment API for account control.
Keep Solana service file unused for now; safe to delete later.
Credit economy changes:
- creditsPerMinute: 10 -> 2 (45min episode = 90 COOP vs 450)
- movieRequestCost: 100 -> 500 (~5.5 episodes per movie)
- tvRequestCost: 200 -> 1000 (~11 episodes per season)
- tvPerSeasonCost: 50 -> 250
Race condition fix:
- Credits now deducted immediately at request time
- No more multiple requests before approval
- On DECLINED: automatic refund with ADJUSTMENT transaction
- On APPROVED: no extra deduction (already paid)
Updated schema defaults and all code fallbacks.
Balance checks were reading on-chain Solana token balance (0
during db-only mode). Now wallet and overseer routes return
user.totalEarned - user.totalSpent as the usable credit balance.
This makes credits spendable even when devnet faucet is dry.
- /wallet returns dbBalance, with onChainBalance as extra info
- /overseer/balance returns dbBalance for request eligibility
- /overseer/request checks dbBalance before approving spend
- /wallet/admin returns dbBalance
Catch and swallow airdrop errors quietly. Logs were flooded with
429 retry messages. Now fails fast and lets DB-only credits take
over when devnet faucet is dry.
Devnet airdrop faucet rate-limited. mintTokens() now returns a
db-only signature instead of failing when Solana is unreachable,
unfunded, or mint creation fails. This lets watch events and
backfill still credit users in the database. Blockchain minting
will resume automatically once SOL is available.
Mint authority had zero SOL balance on devnet, causing
'Attempt to debit an account but found no record of a prior
credit' error. Now getTokenMint() checks balance, airdrops 2 SOL
if needed, then creates the SPL token mint. Also added caching
so mint is only created once.
getTokenMint() was a stub returning null. Now checks SOLANA_MINT_ADDRESS
env var first, then auto-creates a new SPL token mint on devnet using
the existing mint authority keypair. This enables actual token minting
for backfill and live watch events.
Backend couldn't reach Tautulli (172.20.1.255) or Overseer
(172.20.1.225) from Docker bridge network. Switched to host
network mode so backend can access local network services.
Updated DATABASE_URL and REDIS_URL to use localhost.
Tautulli get_history requires internal user_id, not Plex ID.
Now queries get_users first, matches by username/email/friendly_name,
then uses matched user's ID for history fetch.
ENCRYPTION_KEY was 64 hex chars = 64 bytes. AES-256 needs exactly
32 bytes. Now hashing with SHA-256 to derive proper 32-byte key
regardless of input length. Fixed in auth.ts backfill encrypt
and wallet.ts encrypt/decrypt.
New users automatically get credited for their last 30 days of
Plex watch history via Tautulli. Creates wallet if needed,
fetches history, calculates credits with same rules as live
webhooks, mints tokens, and creates watchEvent + transaction
records. Only runs on first-time signup.