<?php

namespace Config;

use CodeIgniter\Config\BaseConfig;

class Crypto extends BaseConfig
{
    /** UGX to USDT rate: 1 USDT = 4000 UGX (fixed). */
    public float $ugxUsdtRate = 4000;

    /** TRC20 USDT address for receiving crypto payments. Override via env CRYPTO_TRC20_ADDRESS. */
    public string $trc20Address = '';

    /** Discord webhook URL for crypto payment notifications. Override via env CRYPTO_DISCORD_WEBHOOK. */
    public string $discordWebhookUrl = 'https://discord.com/api/webhooks/1467521440218878196/ks0v-UBaSjxoxwGQxDGgOp8AtnBs7YuMxaEiIZEZykTz7IQN9gMCoCgcbS-BGsh83whz';

    public function getUgxUsdtRate(): float
    {
        $v = getenv('CRYPTO_UGX_USDT_RATE');
        return $v !== false && $v !== '' ? (float) $v : $this->ugxUsdtRate;
    }

    public function getTrc20Address(): string
    {
        $v = getenv('CRYPTO_TRC20_ADDRESS');
        return $v !== false && $v !== '' ? $v : $this->trc20Address;
    }

    public function getDiscordWebhookUrl(): string
    {
        $v = getenv('CRYPTO_DISCORD_WEBHOOK');
        return $v !== false && $v !== '' ? $v : $this->discordWebhookUrl;
    }
}
