diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index dbf2d5932..606df22ee 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -210,6 +210,7 @@ namespace BTCPayServer.Controllers vm.AvailableExchanges = exchanges; vm.DefaultCurrencyPairs = storeBlob.GetDefaultCurrencyPairString(); vm.ShowScripting = storeBlob.RateScripting; + vm.HintRates = storeBlob.Hints?.Rates == true; return View(vm); } @@ -255,6 +256,7 @@ namespace BTCPayServer.Controllers blob.PreferredExchange = model.PreferredExchange; blob.Spread = (decimal)model.Spread / 100.0m; blob.DefaultCurrencyPairs = currencyPairs; + blob.Hints.Rates = false; if (!model.ShowScripting) { if (!exchanges.Any(provider => provider.Id.Equals(model.PreferredExchange, StringComparison.InvariantCultureIgnoreCase))) @@ -471,32 +473,6 @@ namespace BTCPayServer.Controllers }); } - [HttpGet] - [Route("{storeId}")] - public IActionResult UpdateStore() - { - var store = HttpContext.GetStoreData(); - if (store == null) - return NotFound(); - - var storeBlob = store.GetStoreBlob(); - var vm = new StoreViewModel(); - vm.Id = store.Id; - vm.StoreName = store.StoreName; - vm.StoreWebsite = store.StoreWebsite; - vm.NetworkFeeMode = storeBlob.NetworkFeeMode; - vm.AnyoneCanCreateInvoice = storeBlob.AnyoneCanInvoice; - vm.SpeedPolicy = store.SpeedPolicy; - vm.CanDelete = _Repo.CanDeleteStores(); - AddPaymentMethods(store, storeBlob, vm); - vm.MonitoringExpiration = (int)storeBlob.MonitoringExpiration.TotalMinutes; - vm.InvoiceExpiration = (int)storeBlob.InvoiceExpiration.TotalMinutes; - vm.LightningDescriptionTemplate = storeBlob.LightningDescriptionTemplate; - vm.PaymentTolerance = storeBlob.PaymentTolerance; - vm.PayJoinEnabled = storeBlob.PayJoinEnabled; - return View(vm); - } - private void AddPaymentMethods(StoreData store, StoreBlob storeBlob, StoreViewModel vm) { @@ -556,6 +532,36 @@ namespace BTCPayServer.Controllers } + + [HttpGet] + [Route("{storeId}")] + public IActionResult UpdateStore() + { + var store = HttpContext.GetStoreData(); + if (store == null) + return NotFound(); + + var storeBlob = store.GetStoreBlob(); + var vm = new StoreViewModel(); + vm.Id = store.Id; + vm.StoreName = store.StoreName; + vm.StoreWebsite = store.StoreWebsite; + vm.NetworkFeeMode = storeBlob.NetworkFeeMode; + vm.AnyoneCanCreateInvoice = storeBlob.AnyoneCanInvoice; + vm.SpeedPolicy = store.SpeedPolicy; + vm.CanDelete = _Repo.CanDeleteStores(); + AddPaymentMethods(store, storeBlob, vm); + vm.MonitoringExpiration = (int)storeBlob.MonitoringExpiration.TotalMinutes; + vm.InvoiceExpiration = (int)storeBlob.InvoiceExpiration.TotalMinutes; + vm.LightningDescriptionTemplate = storeBlob.LightningDescriptionTemplate; + vm.PaymentTolerance = storeBlob.PaymentTolerance; + vm.PayJoinEnabled = storeBlob.PayJoinEnabled; + vm.HintWallet = storeBlob.Hints.Wallet; + vm.HintLightning = storeBlob.Hints.Lighting; + return View(vm); + } + + [HttpPost] [Route("{storeId}")] public async Task UpdateStore(StoreViewModel model, string command = null) @@ -625,7 +631,6 @@ namespace BTCPayServer.Controllers { storeId = CurrentStore.Id }); - } [HttpGet] diff --git a/BTCPayServer/Controllers/UserStoresController.cs b/BTCPayServer/Controllers/UserStoresController.cs index 7f5077117..398e71bb1 100644 --- a/BTCPayServer/Controllers/UserStoresController.cs +++ b/BTCPayServer/Controllers/UserStoresController.cs @@ -37,6 +37,23 @@ namespace BTCPayServer.Controllers return View(); } + [HttpPost] + [Route("create")] + public async Task CreateStore(CreateStoreViewModel vm) + { + if (!ModelState.IsValid) + { + return View(vm); + } + var store = await _Repo.CreateStore(GetUserId(), vm.Name); + CreatedStoreId = store.Id; + TempData[WellKnownTempData.SuccessMessage] = "Store successfully created"; + return RedirectToAction(nameof(StoresController.UpdateStore), "Stores", new + { + storeId = store.Id + }); + } + public string CreatedStoreId { get; set; @@ -119,23 +136,6 @@ namespace BTCPayServer.Controllers return View(result); } - [HttpPost] - [Route("create")] - public async Task CreateStore(CreateStoreViewModel vm) - { - if (!ModelState.IsValid) - { - return View(vm); - } - var store = await _Repo.CreateStore(GetUserId(), vm.Name); - CreatedStoreId = store.Id; - TempData[WellKnownTempData.SuccessMessage] = "Store successfully created"; - return RedirectToAction(nameof(StoresController.UpdateStore), "Stores", new - { - storeId = store.Id - }); - } - private string GetUserId() { return _UserManager.GetUserId(User); diff --git a/BTCPayServer/Data/StoreBlob.cs b/BTCPayServer/Data/StoreBlob.cs index ab08eaafa..c9c79aa8d 100644 --- a/BTCPayServer/Data/StoreBlob.cs +++ b/BTCPayServer/Data/StoreBlob.cs @@ -188,6 +188,14 @@ namespace BTCPayServer.Data public bool RedirectAutomatically { get; set; } public bool PayJoinEnabled { get; set; } + public StoreHints Hints { get; set; } + public class StoreHints + { + public bool Wallet { get; set; } + public bool Lighting { get; set; } + public bool Rates { get; set; } + } + public IPaymentFilter GetExcludedPaymentMethods() { #pragma warning disable CS0618 // Type or member is obsolete diff --git a/BTCPayServer/Data/StoreDataExtensions.cs b/BTCPayServer/Data/StoreDataExtensions.cs index a4272537c..3de895543 100644 --- a/BTCPayServer/Data/StoreDataExtensions.cs +++ b/BTCPayServer/Data/StoreDataExtensions.cs @@ -46,6 +46,9 @@ namespace BTCPayServer.Data var result = storeData.StoreBlob == null ? new StoreBlob() : new Serializer(null).ToObject(Encoding.UTF8.GetString(storeData.StoreBlob)); if (result.PreferredExchange == null) result.PreferredExchange = CoinGeckoRateProvider.CoinGeckoName; + + if (result.Hints == null) + result.Hints = new StoreBlob.StoreHints(); return result; } diff --git a/BTCPayServer/Models/StoreViewModels/RatesViewModel.cs b/BTCPayServer/Models/StoreViewModels/RatesViewModel.cs index fa7bfde21..bfb86b395 100644 --- a/BTCPayServer/Models/StoreViewModels/RatesViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/RatesViewModel.cs @@ -53,6 +53,7 @@ namespace BTCPayServer.Models.StoreViewModels public string DefaultCurrencyPairs { get; set; } public string StoreId { get; set; } public IEnumerable AvailableExchanges { get; set; } + public bool HintRates { get; set; } [Display(Name = "Add a spread on exchange rate of ... %")] [Range(0.0, 100.0)] diff --git a/BTCPayServer/Models/StoreViewModels/StoreViewModel.cs b/BTCPayServer/Models/StoreViewModels/StoreViewModel.cs index 7e5990d1d..ebe87c67f 100644 --- a/BTCPayServer/Models/StoreViewModels/StoreViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/StoreViewModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using BTCPayServer.Client.Models; using BTCPayServer.Validation; +using static BTCPayServer.Data.StoreBlob; namespace BTCPayServer.Models.StoreViewModels { @@ -90,6 +91,9 @@ namespace BTCPayServer.Models.StoreViewModels [Display(Name = "Enable Payjoin/P2EP")] public bool PayJoinEnabled { get; set; } + public bool HintWallet { get; set; } + public bool HintLightning { get; set; } + public class LightningNode { public string CryptoCode { get; set; } diff --git a/BTCPayServer/Services/Stores/StoreRepository.cs b/BTCPayServer/Services/Stores/StoreRepository.cs index f47dbd34c..dd62c80b5 100644 --- a/BTCPayServer/Services/Stores/StoreRepository.cs +++ b/BTCPayServer/Services/Stores/StoreRepository.cs @@ -171,7 +171,7 @@ namespace BTCPayServer.Services.Stores { StoreDataId = storeData.Id, ApplicationUserId = ownerId, - Role = StoreRoles.Owner + Role = StoreRoles.Owner, }; ctx.Add(storeData); ctx.Add(userStore); @@ -182,6 +182,14 @@ namespace BTCPayServer.Services.Stores public async Task CreateStore(string ownerId, string name) { var store = new StoreData() { StoreName = name }; + var blob = store.GetStoreBlob(); + blob.Hints = new Data.StoreBlob.StoreHints + { + Wallet = true, + Lighting = true, + Rates = true + }; + store.SetStoreBlob(blob); await CreateStore(ownerId, store); return store; } diff --git a/BTCPayServer/Views/Stores/Rates.cshtml b/BTCPayServer/Views/Stores/Rates.cshtml index 0fc5659e9..bc6130148 100644 --- a/BTCPayServer/Views/Stores/Rates.cshtml +++ b/BTCPayServer/Views/Stores/Rates.cshtml @@ -1,4 +1,4 @@ -@model BTCPayServer.Models.StoreViewModels.RatesViewModel +@model BTCPayServer.Models.StoreViewModels.RatesViewModel @{ Layout = "../Shared/_NavLayout.cshtml"; ViewData.SetActivePageAndTitle(StoreNavPages.Rates, "Rates"); @@ -18,6 +18,16 @@
+ @if (Model.HintRates) + { +

+ + Please verify all Rates settings and test exchange rate currency pairs + +

+ } @if (Model.ShowScripting) {
@@ -159,7 +169,7 @@

- Current price source is @Model.PreferredExchange. + Current Rates source is @Model.PreferredExchange.

diff --git a/BTCPayServer/Views/Stores/UpdateStore.cshtml b/BTCPayServer/Views/Stores/UpdateStore.cshtml index 616b7c2df..435f6b010 100644 --- a/BTCPayServer/Views/Stores/UpdateStore.cshtml +++ b/BTCPayServer/Views/Stores/UpdateStore.cshtml @@ -20,7 +20,7 @@

Wallet On-chain payments

- @if (!Model.DerivationSchemes.Any(a => !String.IsNullOrEmpty(a.Value))) + @if (Model.HintWallet) {

@@ -102,7 +102,7 @@

Lightning Off-chain payments

- @if (!Model.DerivationSchemes.Any(a => !String.IsNullOrEmpty(a.Value))) + @if (Model.HintLightning) {