fix: derive currency decimals from CRYPTO_TYPE (XMR=12, not WOW's 11)

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).
This commit is contained in:
jwinterm
2026-05-31 15:45:01 -04:00
parent ccdb4521b2
commit 04774c4ca2
+7
View File
@@ -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);