This iteration introduces the backend foundation for rewards, shop purchases, inventory, and transaction history.
HCoinwallet per user.- Shop catalog with purchasable items.
- User inventory with quantity and acquisition timestamps.
- Transaction ledger (
REWARD,PURCHASE,REFUND,ADJUSTMENT). - Guardrails for memory and persistent storage with alerting.
- File-based state:
${homedir.data.dir}/economy-state.json - Uses existing
PersistenceServicewith synchronous save for economic mutations. - In-memory cache keeps only a bounded recent transaction window.
- Deep history is loaded on demand from disk when pagination requests older entries.
Configured in application.properties:
economy.transactions.persisted-maxeconomy.transactions.cache-maxeconomy.storage.max-byteseconomy.memory.max-userseconomy.memory.max-inventory-entrieseconomy.inventory.user-max-itemseconomy.guard.stricteconomy.guard.alert-cooldown
When economy.guard.strict=true, mutation operations are blocked once a limit is hit and a warning alert is emitted.
GET /api/economy/catalogGET /api/economy/wallet(auth required)GET /api/economy/inventory?limit=&offset=(auth required)GET /api/economy/transactions?limit=&offset=(auth required)POST /api/economy/purchasebody{ "itemId": "profile-glow" }(auth required)GET /api/economy/stats(admin required)
- Each successful XP award also credits HCoin using:
economy.rewards.xp-to-hcoin-ratioeconomy.rewards.min-hcoin
If guardrails are active, XP awarding remains functional and only HCoin credit is skipped.