From 04774c4ca2108870228bc9b17356babe8889a0e4 Mon Sep 17 00:00:00 2001 From: jwinterm Date: Sun, 31 May 2026 15:45:01 -0400 Subject: [PATCH] fix: derive currency decimals from CRYPTO_TYPE (XMR=12, not WOW's 11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit paymentConfig set currency.symbol from CRYPTO_TYPE but left currency.decimals at the WOW default (11), so on the XMR (Monero) instance every amount in /api/game-modes and the payment UI displayed 10x too large (0.01 XMR shown as 0.10). The atomic amounts and the payment QR were always correct — only the web display divisor was wrong. Now decimals is inferred from the symbol (CURRENCY_DECIMALS env still overrides). WOW stays 11 (unchanged). --- src/config/paymentConfig.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/config/paymentConfig.js b/src/config/paymentConfig.js index 7287104..125256b 100644 --- a/src/config/paymentConfig.js +++ b/src/config/paymentConfig.js @@ -4,6 +4,7 @@ */ const { EventEmitter } = require('events'); +const { inferCurrencyDecimals } = require('../game/helpers/gameModeUtils'); const DEFAULT_CONFIG = Object.freeze({ paymentsEnabled: true, @@ -248,6 +249,12 @@ class PaymentConfigManager { } config.currency.symbol = process.env.CRYPTO_TYPE || config.currency.symbol; + // Derive decimals from the currency (XMR=12, WOW=11) so display divisors match the + // chain. Previously decimals stayed at the WOW default (11) even for XMR, making all + // XMR amounts display 10x too large. An explicit CURRENCY_DECIMALS env still wins. + config.currency.decimals = process.env.CURRENCY_DECIMALS + ? parseInt(process.env.CURRENCY_DECIMALS, 10) + : inferCurrencyDecimals(config.currency.symbol); config.currency.minPayment = parseAtomicValue(process.env.PAYOUT_MIN_AMOUNT, config.currency.minPayment); config.currency.maxPayment = parseAtomicValue(process.env.MAX_CREDIT_PURCHASE_PER_DAY, config.currency.maxPayment);