add backup scripts and improve docs and .env.example

This commit is contained in:
jwinterm
2025-12-22 16:29:32 -05:00
parent 7f91d83308
commit 7d701fe01b
14 changed files with 1335 additions and 702 deletions
+98 -65
View File
@@ -1,116 +1,149 @@
# =============================================================================
# Wownerogue Server Configuration
# =============================================================================
# Copy this file to .env and customize for your environment.
# The server validates these settings at startup and warns about misconfigurations.
# -----------------------------------------------------------------------------
# Network Selection (IMPORTANT for Monero users)
# Network Selection
# -----------------------------------------------------------------------------
# For Wownero: Only mainnet exists, this setting is ignored
# For Monero: Choose mainnet, stagenet, or testnet
# For Wownero: Only mainnet exists (this setting is ignored)
# For Monero: mainnet | stagenet | testnet
# ⚠️ STAGENET WARNING: Stagenet XMR has no real value! Only for testing.
MONERO_NETWORK=mainnet
# MONERO_NETWORK=stagenet
# MONERO_NETWORK=testnet
# -----------------------------------------------------------------------------
# Difficulty Settings
# Difficulty Presets
# -----------------------------------------------------------------------------
# Presets: easy, normal, hard, casino
# - easy: Small dungeon, slow monster, high player win rate (~70%)
# - normal: Balanced difficulty (~45% player win rate)
# - hard: Large dungeon, aggressive monster (~35% player win rate)
# - casino: Maximum house edge (~30% player win rate) - DEFAULT for paid modes
# Leave unset to auto-select based on PAYMENTS_ENABLED
# Presets: easy | normal | hard | casino
# easy - Small dungeon, slow monster (~70% player win rate)
# normal - Balanced difficulty (~45% player win rate)
# hard - Large dungeon, aggressive monster (~35% player win rate)
# casino - Maximum house edge (~30% player win rate) - DEFAULT for paid modes
# Leave unset to auto-select based on payment mode.
# DIFFICULTY_PRESET=casino
# DIFFICULTY_PRESET=normal
# -----------------------------------------------------------------------------
# Unified Payment System (recommended configuration)
# Payment System
# -----------------------------------------------------------------------------
# Master switch for payments. Set false for FREE mode (no payments required).
PAYMENTS_ENABLED=true
# Enable one or both monetized modes (comma separated list: direct,credits)
# Payment modes: direct | credits | direct,credits (comma-separated)
# direct - Pay per game, eligible for payouts on win
# credits - Buy credit packages, spend 1 credit per game
# Enabling both allows users to choose; users with credits use them first.
PAYMENT_MODES=direct,credits
# Direct (per-run) mode settings
# -----------------------------------------------------------------------------
# Direct Mode (pay-per-game)
# -----------------------------------------------------------------------------
DIRECT_PAYMENT_ENABLED=true
DIRECT_GAME_PRICE=100000000000 # 1 WOW in atomic units (1e11)
DIRECT_REQUIRES_ADDRESS=true
DIRECT_ALLOW_GUEST_PLAY=false
DIRECT_PAYOUTS_ENABLED=true
DIRECT_PAYOUT_ESCAPE=2.0
DIRECT_PAYOUT_TREASURE=3.0
DIRECT_GAME_PRICE=100000000000 # Price in atomic units (1 WOW = 1e11)
DIRECT_REQUIRES_ADDRESS=true # Require payout address before playing
DIRECT_ALLOW_GUEST_PLAY=false # Allow play without payout address
# Credits mode settings
# Direct mode payouts
# ⚠️ Requires PRIMARY_WALLET_ENDPOINT to be configured!
DIRECT_PAYOUTS_ENABLED=true
DIRECT_PAYOUT_ESCAPE=2.0 # Multiplier for escaping the dungeon
DIRECT_PAYOUT_TREASURE=3.0 # Multiplier for finding treasure
# -----------------------------------------------------------------------------
# Credits Mode (buy packages, spend per game)
# -----------------------------------------------------------------------------
CREDITS_ENABLED=true
CREDITS_PER_GAME=1
CREDITS_REQUIRES_ADDRESS=true
ALLOW_MIXED_MODE=true
PREFER_CREDITS_FIRST=true
CREDITS_PER_GAME=1 # Credits consumed per game
CREDITS_REQUIRES_ADDRESS=true # Require payout address for credits mode
ALLOW_MIXED_MODE=true # Allow both direct and credits options
PREFER_CREDITS_FIRST=true # Auto-use credits if available
# Credits mode payouts (usually disabled - credits are a bulk discount)
# ⚠️ If enabled, requires PRIMARY_WALLET_ENDPOINT!
CREDITS_PAYOUTS_ENABLED=false
CREDITS_PAYOUT_BASE=50000000000 # 0.5 WOW per credit payout baseline
CREDITS_PAYOUT_BASE=50000000000 # Base payout per credit win
CREDITS_PAYOUT_ESCAPE=1.5
CREDITS_PAYOUT_TREASURE=2.0
# Credit packages (JSON array)
# Each package: { id, credits, price (atomic units string), bonus (extra free credits) }
# ⚠️ Must be valid JSON! Server validates at startup.
CREDITS_PACKAGES='[{"id":"small","credits":10,"price":"500000000000","bonus":0},{"id":"medium","credits":25,"price":"1000000000000","bonus":2},{"id":"large","credits":100,"price":"3500000000000","bonus":15}]'
# Global payouts / limits
# -----------------------------------------------------------------------------
# Global Payout Settings
# -----------------------------------------------------------------------------
PAYOUTS_ENABLED=true
PAYOUT_MIN_AMOUNT=10000000000 # 0.1 WOW minimum payout
PAYOUT_MAX_PER_GAME=10000000000000
PAYOUT_BATCH_INTERVAL=300 # seconds (5 minutes)
PAYOUT_MAX_RETRIES=3
MAX_PAYOUT_BATCH_SIZE=50
PAYOUT_MIN_AMOUNT=10000000000 # 0.1 WOW minimum payout
PAYOUT_MAX_PER_GAME=10000000000000 # Max payout per single game
PAYOUT_BATCH_INTERVAL=300 # Seconds between payout batches (5 min)
PAYOUT_MAX_RETRIES=3 # Retry failed payouts
MAX_PAYOUT_BATCH_SIZE=50 # Max payouts per batch
# Anti-abuse limits
# -----------------------------------------------------------------------------
# Anti-Abuse Limits
# -----------------------------------------------------------------------------
MAX_GAMES_PER_HOUR=60
MAX_PAYOUTS_PER_DAY=100
MAX_CREDIT_PURCHASE_PER_DAY=100000000000000
GAME_COOLDOWN_SECONDS=5
# -----------------------------------------------------------------------------
# Legacy overrides (optional). These mirror the old configuration style and
# are primarily kept for backwards compatibility or quick testing.
# Wallet RPC (required for paid modes)
# -----------------------------------------------------------------------------
# GAME_MODE accepts FREE, PAID_SINGLE, PAID_CREDITS. When set it overrides
# PAYMENT_MODES. Leave unset to rely on unified config above.
GAME_MODE=
# Legacy per-mode prices (still read as fallbacks if PAYMENT_MODES unset)
CRYPTO_TYPE=WOW
SINGLE_GAME_PRICE=1e11 # 1 WOW (atomic units)
CREDITS_PACKAGE_PRICE=5e11 # 5 WOW (atomic units)
# SINGLE_GAME_PRICE=5e9 # 0.005 XMR (5000000000)
# CREDITS_PACKAGE_PRICE=5e10 # 0.05 XMR (50000000000)
# Wallet RPC Configuration (required for paid modes)
# Run wownero-wallet-rpc or monero-wallet-rpc with --rpc-bind-port
# ⚠️ Without this, payments and payouts will fail!
PRIMARY_WALLET_ENDPOINT=http://127.0.0.1:34570
# WALLET_RPC_USER=user
# WALLET_RPC_PASSWORD=password
# Blockchain RPC Configuration (daemon URLs)
# -----------------------------------------------------------------------------
# Blockchain RPC (daemon)
# -----------------------------------------------------------------------------
PRIMARY_RPC_ENDPOINT=http://127.0.0.1:34568
FALLBACK_RPC_ENDPOINT=http://127.0.0.1:34568
RPC_POLL_INTERVAL=2000
RPC_POLL_INTERVAL=2000 # Milliseconds between block polls
# Database Configuration
# -----------------------------------------------------------------------------
# Database (PostgreSQL)
# -----------------------------------------------------------------------------
DB_HOST=localhost
DB_PORT=5432
DB_NAME=wownerogue
DB_USER=jw
DB_PASSWORD=jw
DB_USER=your_db_user
DB_PASSWORD=your_db_password
# Server Configuration
# -----------------------------------------------------------------------------
# Server
# -----------------------------------------------------------------------------
PORT=3000
NODE_ENV=production
# Block Height Source & Debug Controls
# BLOCK_SOURCE=daemon -> always use real blockchain height (default for paid modes)
# BLOCK_SOURCE=simulated -> force simulated blocks (development)
# SIMULATED_BLOCKS=true/false overrides automatic detection (if set)
# FORCE_SIMULATED_BLOCKS=true will force simulation even in paid modes (for local testing)
# Examples:
# BLOCK_SOURCE=daemon
# BLOCK_SOURCE=simulated
# SIMULATED_BLOCKS=false
# FORCE_SIMULATED_BLOCKS=true
# -----------------------------------------------------------------------------
# Admin API
# -----------------------------------------------------------------------------
# Required for admin endpoints: /api/admin/refund/payment, /api/admin/credits/adjust, etc.
# Generate a secure key: openssl rand -hex 32
# Pass as X-Admin-Key header when calling admin endpoints.
# ADMIN_API_KEY=your-secure-random-key-here
# -----------------------------------------------------------------------------
# Block Simulation (Development Only)
# -----------------------------------------------------------------------------
# BLOCK_SOURCE: daemon (real blockchain) | simulated (fake blocks for testing)
# In paid modes, defaults to daemon. In FREE mode, defaults to simulated.
BLOCK_SOURCE=daemon
# SIMULATED_BLOCKS=false
# FORCE_SIMULATED_BLOCKS=false
# -----------------------------------------------------------------------------
# Legacy Configuration (deprecated, kept for compatibility)
# -----------------------------------------------------------------------------
# GAME_MODE: FREE | PAID_SINGLE | PAID_CREDITS
# If set, overrides PAYMENT_MODES. Prefer using PAYMENT_MODES instead.
# GAME_MODE=
# Legacy prices (used if PAYMENT_MODES not set)
CRYPTO_TYPE=WOW
# SINGLE_GAME_PRICE=1e11
# CREDITS_PACKAGE_PRICE=5e11