From 895d13c34e01ee3a5fe29150fd5b8bdcf3ef2ec9 Mon Sep 17 00:00:00 2001 From: Abhijay Jain Date: Thu, 10 Jul 2025 07:28:59 +0530 Subject: [PATCH] (Feat): Allowed Fallback Exchange Rate to Be Enabled via API (#6839) Signed-off-by: Abhijay jain --- .../GreenfieldStoreRatesConfigurationController.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesConfigurationController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesConfigurationController.cs index 6d30ca129..f92817956 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesConfigurationController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesConfigurationController.cs @@ -95,8 +95,17 @@ namespace BTCPayServer.Controllers.GreenField var storeData = HttpContext.GetStoreData(); var storeBlob = storeData.GetStoreBlob(); var blob = storeBlob.GetRateSettings(fallback); - if (blob is null) + + // If fallback rates are not enabled but someone is trying to configure them, enable them automatically + if (blob is null && fallback) + { + blob = storeBlob.GetOrCreateRateSettings(fallback); + } + else if (blob is null) + { return this.CreateAPIError(404, "fallback-disabled", "The fallback rates are disabled"); + } + ValidateAndSanitizeConfiguration(configuration, storeBlob, blob); if (!ModelState.IsValid) return this.CreateValidationError(ModelState);