EMERGENCY FIXES: ✅ DELETE MockSilverPayService.cs - removed fake payment system ✅ REMOVE mock service registration - no fake payments possible ✅ GENERATE new JWT secret - replaced hardcoded key ✅ FIX HttpClient disposal - proper resource management SECURITY HARDENING: ✅ ADD production guards - prevent mock services in production ✅ CREATE environment configs - separate dev/prod settings ✅ ADD config validation - fail fast on misconfiguration IMPACT: - Mock payment system completely eliminated - JWT authentication now uses secure keys - Production deployment now validated on startup - Resource leaks fixed in TeleBot currency API 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
82 lines
2.7 KiB
C#
82 lines
2.7 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using LittleShop.Services;
|
|
using LittleShop.Enums;
|
|
|
|
namespace LittleShop.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class CurrencyController : ControllerBase
|
|
{
|
|
private readonly ISilverPayService _silverPayService;
|
|
private readonly ISystemSettingsService _systemSettingsService;
|
|
private readonly ILogger<CurrencyController> _logger;
|
|
|
|
public CurrencyController(
|
|
ISilverPayService silverPayService,
|
|
ISystemSettingsService systemSettingsService,
|
|
ILogger<CurrencyController> logger)
|
|
{
|
|
_silverPayService = silverPayService;
|
|
_systemSettingsService = systemSettingsService;
|
|
_logger = logger;
|
|
}
|
|
|
|
[HttpGet("available")]
|
|
public async Task<ActionResult<IEnumerable<string>>> GetAvailableCurrencies()
|
|
{
|
|
try
|
|
{
|
|
var availableCurrencies = new List<string>();
|
|
|
|
// Get SilverPay supported currencies
|
|
var silverPayCurrencies = await _silverPayService.GetSupportedCurrenciesAsync();
|
|
|
|
// Production currencies (always enabled if supported by SilverPay)
|
|
var productionCurrencies = new[] { "BTC", "ETH" };
|
|
foreach (var currency in productionCurrencies)
|
|
{
|
|
if (silverPayCurrencies.Contains(currency))
|
|
{
|
|
availableCurrencies.Add(currency);
|
|
}
|
|
}
|
|
|
|
// Test currencies (enabled via admin settings)
|
|
var testCurrencies = new[] { "TBTC", "TLTC" };
|
|
foreach (var currency in testCurrencies)
|
|
{
|
|
if (silverPayCurrencies.Contains(currency) &&
|
|
await _systemSettingsService.IsTestCurrencyEnabledAsync(currency))
|
|
{
|
|
availableCurrencies.Add(currency);
|
|
}
|
|
}
|
|
|
|
_logger.LogInformation("Available currencies: {Currencies}", string.Join(", ", availableCurrencies));
|
|
|
|
return Ok(availableCurrencies);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Error getting available currencies");
|
|
// Return safe fallback currencies
|
|
return Ok(new[] { "BTC", "ETH" });
|
|
}
|
|
}
|
|
|
|
[HttpGet("silverpay/supported")]
|
|
public async Task<ActionResult<IEnumerable<string>>> GetSilverPaySupportedCurrencies()
|
|
{
|
|
try
|
|
{
|
|
var currencies = await _silverPayService.GetSupportedCurrenciesAsync();
|
|
return Ok(currencies);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Error getting SilverPay supported currencies");
|
|
return StatusCode(500, "Failed to get supported currencies");
|
|
}
|
|
}
|
|
} |