From e5c6b9a979465681512553253ea69fdb85d9cb8f Mon Sep 17 00:00:00 2001 From: rockstardev Date: Thu, 15 Oct 2020 18:20:23 -0500 Subject: [PATCH 01/12] Rearranging store sections and providing warnings for new stores --- BTCPayServer/Views/Stores/UpdateStore.cshtml | 321 ++++++++++--------- 1 file changed, 173 insertions(+), 148 deletions(-) diff --git a/BTCPayServer/Views/Stores/UpdateStore.cshtml b/BTCPayServer/Views/Stores/UpdateStore.cshtml index 1fd5b092d..ec2c74507 100644 --- a/BTCPayServer/Views/Stores/UpdateStore.cshtml +++ b/BTCPayServer/Views/Stores/UpdateStore.cshtml @@ -1,4 +1,4 @@ -@using System.Text.RegularExpressions +@using System.Text.RegularExpressions @model StoreViewModel @{ Layout = "../Shared/_NavLayout.cshtml"; @@ -9,11 +9,11 @@ @if (!ViewContext.ModelState.IsValid) { -
-
-
+
+
+
+
-
}
@@ -36,6 +36,144 @@
+

Wallet On-chain payments

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

+ + Wallet not setup for the store. Please provide Derviation Scheme + +

+ } +

+ The Derivation Scheme + facilitates generation of the destination addresses for your invoices so funds can be received on-chain. +

+

+ Until wallet is defined, no invoices can be created for this store. + Optionally, you can have a store that only receives Lightning payments, see the next section for more details. +

+ + + + + + + + + + + + @foreach (var scheme in Model.DerivationSchemes.OrderBy(scheme => scheme.Collapsed)) + { + + + + + + + } + + @if (Model.DerivationSchemes.Any(scheme => scheme.Collapsed)) + { + + + + } + +
CryptoDerivation SchemeEnabledActions
@scheme.Crypto + @if (string.IsNullOrEmpty(scheme.Value)) + { + Not set + } + else + { + + @scheme.Value + + + @if (scheme.Value.Length > 20) + { + var match = Regex.Match(scheme.Value, @"((?:-\[(?:[^\]])+\])+|\S{6})$"); + @match.Value; + } + + } + + @if (scheme.Enabled) + { + + } + else + { + + } + + @if (!string.IsNullOrWhiteSpace(scheme.Value) && scheme.WalletSupported) + { + Wallet - + } + Modify +
+ +

Lightning Off-chain payments

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

+ + Review settings if you want to receive Lightning payments + +

+ } +

+ A connection to a Lightning Node is required to generate Lightning Network enabled invoices. +

+ + + + + + + + + + + + @foreach (var scheme in Model.LightningNodes) + { + + + + + + + } + +
CryptoAddressEnabledActions
@scheme.CryptoCode@scheme.Address + @if (scheme.Enabled) + { + + } + else + { + + } + Modify
+ +
+ + + +

+ Available placeholders: + {StoreName} {ItemDescription} {OrderId} +

+
+

Payment

@@ -46,7 +184,7 @@
- + @@ -67,7 +205,7 @@
- +
minutes
@@ -80,7 +218,7 @@
- +
minutes
@@ -93,7 +231,7 @@
- +
percent
@@ -115,119 +253,6 @@
-

Derivation Scheme

-

The Derivation Scheme represents the destination of the funds received by your invoice on chain.

- - - - - - - - - - - - @foreach(var scheme in Model.DerivationSchemes.OrderBy(scheme => scheme.Collapsed)) - { - - - - - - - } - - @if (Model.DerivationSchemes.Any(scheme => scheme.Collapsed)) - { - - - - } - -
CryptoDerivation SchemeEnabledActions
@scheme.Crypto - @if (string.IsNullOrEmpty(scheme.Value)) - { - Not set - } - else - { - - @scheme.Value - - - @if (scheme.Value.Length > 20) - { - var match = Regex.Match(scheme.Value, @"((?:-\[(?:[^\]])+\])+|\S{6})$"); - @match.Value; - } - - } - - @if(scheme.Enabled) - { - - } - else - { - - } - - @if(!string.IsNullOrWhiteSpace(scheme.Value) && scheme.WalletSupported) - { - Wallet - - } - Modify -
- -

Lightning nodes (Experimental)

-

- A connection to a lightning charge node is required to generate lightning network enabled invoices. -
- This is experimental and not advised for production. -

- - - - - - - - - - - - @foreach(var scheme in Model.LightningNodes) - { - - - - - - - } - -
CryptoAddressEnabledActions
@scheme.CryptoCode@scheme.Address - @if (scheme.Enabled) - { - - } - else - { - - } - Modify
- -
- - - -

- Available placeholders: - {StoreName} {ItemDescription} {OrderId} -

-
-

Additional Payment methods

@@ -238,23 +263,23 @@ - @foreach (var scheme in Model.ThirdPartyPaymentMethods) - { - - - - - - } + @foreach (var scheme in Model.ThirdPartyPaymentMethods) + { + + + + + + }
@scheme.Provider - @if (scheme.Enabled) - { - - } - else - { - - } - Modify
@scheme.Provider + @if (scheme.Enabled) + { + + } + else + { + + } + Modify
@@ -265,8 +290,8 @@ Service Actions - - + + Email @@ -293,12 +318,12 @@ @await Html.PartialAsync("_ValidationScriptsPartial") } From 17c8ac82485a6630bf8481114663c15c0cb189f1 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Thu, 15 Oct 2020 23:04:44 -0500 Subject: [PATCH 02/12] Moving general store settings in same section --- BTCPayServer/Views/Stores/UpdateStore.cshtml | 292 +++++++++---------- 1 file changed, 145 insertions(+), 147 deletions(-) diff --git a/BTCPayServer/Views/Stores/UpdateStore.cshtml b/BTCPayServer/Views/Stores/UpdateStore.cshtml index ec2c74507..616b7c2df 100644 --- a/BTCPayServer/Views/Stores/UpdateStore.cshtml +++ b/BTCPayServer/Views/Stores/UpdateStore.cshtml @@ -2,7 +2,7 @@ @model StoreViewModel @{ Layout = "../Shared/_NavLayout.cshtml"; - ViewData.SetActivePageAndTitle(StoreNavPages.Index, "Profile"); + ViewData.SetActivePageAndTitle(StoreNavPages.Index, @Model.StoreName); } @@ -18,9 +18,147 @@
-
-
-

General

+
+

Wallet On-chain payments

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

+ + Wallet not setup for the store. Please provide Derviation Scheme + +

+ } +

+ The Derivation Scheme + facilitates generation of the destination addresses for your invoices so funds can be received on-chain. +

+

+ Until wallet is defined, no invoices can be created for this store. + Optionally, you can have a store that only receives Lightning payments, see the next section for more details. +

+ + + + + + + + + + + + @foreach (var scheme in Model.DerivationSchemes.OrderBy(scheme => scheme.Collapsed)) + { + + + + + + + } + + @if (Model.DerivationSchemes.Any(scheme => scheme.Collapsed)) + { + + + + } + +
CryptoDerivation SchemeEnabledActions
@scheme.Crypto + @if (string.IsNullOrEmpty(scheme.Value)) + { + Not set + } + else + { + + @scheme.Value + + + @if (scheme.Value.Length > 20) + { + var match = Regex.Match(scheme.Value, @"((?:-\[(?:[^\]])+\])+|\S{6})$"); + @match.Value; + } + + } + + @if (scheme.Enabled) + { + + } + else + { + + } + + @if (!string.IsNullOrWhiteSpace(scheme.Value) && scheme.WalletSupported) + { + Wallet - + } + Modify +
+ +

Lightning Off-chain payments

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

+ + Review settings if you want to receive Lightning payments + +

+ } +

+ A connection to a Lightning Node is required to generate Lightning Network enabled invoices. +

+ + + + + + + + + + + + @foreach (var scheme in Model.LightningNodes) + { + + + + + + + } + +
CryptoAddressEnabledActions
@scheme.CryptoCode@scheme.Address + @if (scheme.Enabled) + { + + } + else + { + + } + Modify
+ + +
+ + + +

+ Available placeholders: + {StoreName} {ItemDescription} {OrderId} +

+
+ +

Store settings

@@ -36,145 +174,6 @@
-

Wallet On-chain payments

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

- - Wallet not setup for the store. Please provide Derviation Scheme - -

- } -

- The Derivation Scheme - facilitates generation of the destination addresses for your invoices so funds can be received on-chain. -

-

- Until wallet is defined, no invoices can be created for this store. - Optionally, you can have a store that only receives Lightning payments, see the next section for more details. -

- - - - - - - - - - - - @foreach (var scheme in Model.DerivationSchemes.OrderBy(scheme => scheme.Collapsed)) - { - - - - - - - } - - @if (Model.DerivationSchemes.Any(scheme => scheme.Collapsed)) - { - - - - } - -
CryptoDerivation SchemeEnabledActions
@scheme.Crypto - @if (string.IsNullOrEmpty(scheme.Value)) - { - Not set - } - else - { - - @scheme.Value - - - @if (scheme.Value.Length > 20) - { - var match = Regex.Match(scheme.Value, @"((?:-\[(?:[^\]])+\])+|\S{6})$"); - @match.Value; - } - - } - - @if (scheme.Enabled) - { - - } - else - { - - } - - @if (!string.IsNullOrWhiteSpace(scheme.Value) && scheme.WalletSupported) - { - Wallet - - } - Modify -
- -

Lightning Off-chain payments

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

- - Review settings if you want to receive Lightning payments - -

- } -

- A connection to a Lightning Node is required to generate Lightning Network enabled invoices. -

- - - - - - - - - - - - @foreach (var scheme in Model.LightningNodes) - { - - - - - - - } - -
CryptoAddressEnabledActions
@scheme.CryptoCode@scheme.Address - @if (scheme.Enabled) - { - - } - else - { - - } - Modify
- -
- - - -

- Available placeholders: - {StoreName} {ItemDescription} {OrderId} -

-
- -

Payment

@@ -250,8 +249,8 @@ -
-
+ +

Additional Payment methods

@@ -309,8 +308,7 @@ Delete this store } - - + From 15af66de55b39f0787d824a35d4a91c3f962e984 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Thu, 15 Oct 2020 23:30:46 -0500 Subject: [PATCH 03/12] Setting hints during store creation and update --- BTCPayServer/Controllers/StoresController.cs | 59 ++++++++++--------- .../Controllers/UserStoresController.cs | 34 +++++------ BTCPayServer/Data/StoreBlob.cs | 8 +++ BTCPayServer/Data/StoreDataExtensions.cs | 3 + .../Models/StoreViewModels/RatesViewModel.cs | 1 + .../Models/StoreViewModels/StoreViewModel.cs | 4 ++ .../Services/Stores/StoreRepository.cs | 10 +++- BTCPayServer/Views/Stores/Rates.cshtml | 14 ++++- BTCPayServer/Views/Stores/UpdateStore.cshtml | 4 +- 9 files changed, 88 insertions(+), 49 deletions(-) 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) {

From f5c90bebdc872c46346503bf7b2f46313d22d9c3 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Fri, 16 Oct 2020 00:21:37 -0500 Subject: [PATCH 04/12] Support for dismissing hints --- BTCPayServer/Controllers/StoresController.cs | 35 ++++++++++++++++---- BTCPayServer/Data/StoreBlob.cs | 2 +- BTCPayServer/Views/Shared/_NavLayout.cshtml | 4 +-- BTCPayServer/Views/Stores/Rates.cshtml | 3 +- BTCPayServer/Views/Stores/UpdateStore.cshtml | 8 +++-- BTCPayServer/Views/Stores/_Nav.cshtml | 11 ++++++ 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 606df22ee..78ee8358d 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -374,8 +374,8 @@ namespace BTCPayServer.Controllers new PaymentMethodCriteriaViewModel() { PaymentMethod = criteria.PaymentMethod.ToString(), - Type = criteria.Above? PaymentMethodCriteriaViewModel.CriteriaType.GreaterThan : PaymentMethodCriteriaViewModel.CriteriaType.LessThan, - Value = criteria.Value?.ToString()?? "" + Type = criteria.Above ? PaymentMethodCriteriaViewModel.CriteriaType.GreaterThan : PaymentMethodCriteriaViewModel.CriteriaType.LessThan, + Value = criteria.Value?.ToString() ?? "" }).ToList(); vm.CustomCSS = storeBlob.CustomCSS; vm.CustomLogo = storeBlob.CustomLogo; @@ -396,7 +396,9 @@ namespace BTCPayServer.Controllers .Select(o => new CheckoutExperienceViewModel.Format() { - Name = o.ToPrettyString(), Value = o.ToString(), PaymentId = o + Name = o.ToPrettyString(), + Value = o.ToString(), + PaymentId = o }).ToArray(); var defaultPaymentId = storeData.GetDefaultPaymentId(_NetworkProvider); @@ -441,7 +443,7 @@ namespace BTCPayServer.Controllers .Where(viewModel => !string.IsNullOrEmpty(viewModel.Value)).Select(viewModel => { CurrencyValue.TryParse(viewModel.Value, out var cv); - return new PaymentMethodCriteria() {Above = viewModel.Type == PaymentMethodCriteriaViewModel.CriteriaType.GreaterThan, Value = cv, PaymentMethod = PaymentMethodId.Parse(viewModel.PaymentMethod)}; + return new PaymentMethodCriteria() { Above = viewModel.Type == PaymentMethodCriteriaViewModel.CriteriaType.GreaterThan, Value = cv, PaymentMethod = PaymentMethodId.Parse(viewModel.PaymentMethod) }; }).ToList(); #pragma warning disable 612 blob.LightningMaxValue = null; @@ -557,7 +559,7 @@ namespace BTCPayServer.Controllers vm.PaymentTolerance = storeBlob.PaymentTolerance; vm.PayJoinEnabled = storeBlob.PayJoinEnabled; vm.HintWallet = storeBlob.Hints.Wallet; - vm.HintLightning = storeBlob.Hints.Lighting; + vm.HintLightning = storeBlob.Hints.Lightning; return View(vm); } @@ -979,10 +981,29 @@ namespace BTCPayServer.Controllers { storeId = CurrentStore.Id }); - } + [HttpGet] + [Route("{storeId}/dismissHint/{id}")] + public async Task DismissHint(string id) + { + var blob = CurrentStore.GetStoreBlob(); + if (id == "Rates" || id == "Wallet" || id == "Lightning") + { + try + { + var prop = blob.Hints.GetType().GetProperty(id); + prop.SetValue(blob.Hints, false); + } + // disregard parse errors + catch { } - + if (CurrentStore.SetStoreBlob(blob)) + { + await _Repo.UpdateStore(CurrentStore); + } + } + return Content("ack"); + } } } diff --git a/BTCPayServer/Data/StoreBlob.cs b/BTCPayServer/Data/StoreBlob.cs index c9c79aa8d..0ca210e6d 100644 --- a/BTCPayServer/Data/StoreBlob.cs +++ b/BTCPayServer/Data/StoreBlob.cs @@ -192,7 +192,7 @@ namespace BTCPayServer.Data public class StoreHints { public bool Wallet { get; set; } - public bool Lighting { get; set; } + public bool Lightning { get; set; } public bool Rates { get; set; } } diff --git a/BTCPayServer/Views/Shared/_NavLayout.cshtml b/BTCPayServer/Views/Shared/_NavLayout.cshtml index 08e8d46b3..d339d1dbd 100644 --- a/BTCPayServer/Views/Shared/_NavLayout.cshtml +++ b/BTCPayServer/Views/Shared/_NavLayout.cshtml @@ -1,11 +1,11 @@ -@{ +@{ Layout = "/Views/Shared/_Layout.cshtml"; ViewBag.ShowMenu = ViewBag.ShowMenu ?? true; if (!ViewData.ContainsKey("NavPartialName")) { ViewData["NavPartialName"] = "_Nav"; } - var title = $"{(ViewData.ContainsKey("MainTitle")? $"{ViewData["MainTitle"]}:" : String.Empty)} {ViewData["Title"]}"; + var title = $"{(ViewData.ContainsKey("MainTitle") ? $"{ViewData["MainTitle"]}:" : String.Empty)} {ViewData["Title"]}"; }

diff --git a/BTCPayServer/Views/Stores/Rates.cshtml b/BTCPayServer/Views/Stores/Rates.cshtml index bc6130148..bca54646b 100644 --- a/BTCPayServer/Views/Stores/Rates.cshtml +++ b/BTCPayServer/Views/Stores/Rates.cshtml @@ -23,7 +23,8 @@

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

diff --git a/BTCPayServer/Views/Stores/UpdateStore.cshtml b/BTCPayServer/Views/Stores/UpdateStore.cshtml index 435f6b010..1190513ec 100644 --- a/BTCPayServer/Views/Stores/UpdateStore.cshtml +++ b/BTCPayServer/Views/Stores/UpdateStore.cshtml @@ -2,7 +2,7 @@ @model StoreViewModel @{ Layout = "../Shared/_NavLayout.cshtml"; - ViewData.SetActivePageAndTitle(StoreNavPages.Index, @Model.StoreName); + ViewData.SetActivePageAndTitle(StoreNavPages.Index, Model.StoreName); } @@ -25,7 +25,8 @@

Wallet not setup for the store. Please provide Derviation Scheme -

@@ -107,7 +108,8 @@

Review settings if you want to receive Lightning payments -

diff --git a/BTCPayServer/Views/Stores/_Nav.cshtml b/BTCPayServer/Views/Stores/_Nav.cshtml index 3b3ea0e3a..d99241fe5 100644 --- a/BTCPayServer/Views/Stores/_Nav.cshtml +++ b/BTCPayServer/Views/Stores/_Nav.cshtml @@ -13,3 +13,14 @@ }
+ From 75dcdc72d272d42ca10af42bdb0d28b9d52d74ba Mon Sep 17 00:00:00 2001 From: rockstardev Date: Fri, 16 Oct 2020 00:35:53 -0500 Subject: [PATCH 05/12] Showing warning hint on stores listing page --- .../Controllers/UserStoresController.cs | 6 ++- .../Models/StoreViewModels/StoresViewModel.cs | 29 +++-------- .../Services/Stores/StoreRepository.cs | 2 +- .../Views/UserStores/ListStores.cshtml | 50 +++++++++++-------- 4 files changed, 42 insertions(+), 45 deletions(-) diff --git a/BTCPayServer/Controllers/UserStoresController.cs b/BTCPayServer/Controllers/UserStoresController.cs index 398e71bb1..56d8fc2f3 100644 --- a/BTCPayServer/Controllers/UserStoresController.cs +++ b/BTCPayServer/Controllers/UserStoresController.cs @@ -5,6 +5,7 @@ using BTCPayServer.Models; using BTCPayServer.Models.StoreViewModels; using BTCPayServer.Security; using BTCPayServer.Services.Stores; +using ExchangeSharp; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -125,12 +126,15 @@ namespace BTCPayServer.Controllers for (int i = 0; i < stores.Length; i++) { var store = stores[i]; + var blob = store.GetStoreBlob(); result.Stores.Add(new StoresViewModel.StoreViewModel() { Id = store.Id, + Name = store.StoreName, WebSite = store.StoreWebsite, - IsOwner = store.Role == StoreRoles.Owner + IsOwner = store.Role == StoreRoles.Owner, + HintWalletWarning = blob.Hints.Wallet }); } return View(result); diff --git a/BTCPayServer/Models/StoreViewModels/StoresViewModel.cs b/BTCPayServer/Models/StoreViewModels/StoresViewModel.cs index a57fcd045..075a55bbe 100644 --- a/BTCPayServer/Models/StoreViewModels/StoresViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/StoresViewModel.cs @@ -4,32 +4,15 @@ namespace BTCPayServer.Models.StoreViewModels { public class StoresViewModel { - public List Stores - { - get; set; - } = new List(); + public List Stores { get; set; } = new List(); public class StoreViewModel { - public string Name - { - get; set; - } - - public string WebSite - { - get; set; - } - - public string Id - { - get; set; - } - public bool IsOwner - { - get; - set; - } + public string Id { get; set; } + public string Name { get; set; } + public string WebSite { get; set; } + public bool IsOwner { get; set; } + public bool HintWalletWarning { get; set; } } } } diff --git a/BTCPayServer/Services/Stores/StoreRepository.cs b/BTCPayServer/Services/Stores/StoreRepository.cs index dd62c80b5..fec4c0c71 100644 --- a/BTCPayServer/Services/Stores/StoreRepository.cs +++ b/BTCPayServer/Services/Stores/StoreRepository.cs @@ -186,7 +186,7 @@ namespace BTCPayServer.Services.Stores blob.Hints = new Data.StoreBlob.StoreHints { Wallet = true, - Lighting = true, + Lightning = true, Rates = true }; store.SetStoreBlob(blob); diff --git a/BTCPayServer/Views/UserStores/ListStores.cshtml b/BTCPayServer/Views/UserStores/ListStores.cshtml index c2b39aa7d..a2b54678e 100644 --- a/BTCPayServer/Views/UserStores/ListStores.cshtml +++ b/BTCPayServer/Views/UserStores/ListStores.cshtml @@ -1,4 +1,4 @@ -@model StoresViewModel +@model StoresViewModel @{ ViewData["Title"] = "Stores"; var storeNameSortOrder = (string)ViewData["StoreNameSortOrder"]; @@ -11,11 +11,11 @@
@if (TempData.HasStatusMessage()) { -
-
- +
+
+ +
-
}
@@ -37,25 +37,21 @@ - + Name - + Website @@ -67,7 +63,21 @@ @foreach (var store in Model.Stores) { - @store.Name + + @if (store.IsOwner) + { + @store.Name + } + else + { + @store.Name + } + + @if (store.HintWalletWarning) + { + + } + @if (!string.IsNullOrEmpty(store.WebSite)) { From 36269cbed66ef750f4b0f24f2a79af35f37d2326 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Fri, 16 Oct 2020 11:50:51 -0500 Subject: [PATCH 06/12] Consistent styling for Back to List --- .../Views/PaymentRequest/EditPaymentRequest.cshtml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/BTCPayServer/Views/PaymentRequest/EditPaymentRequest.cshtml b/BTCPayServer/Views/PaymentRequest/EditPaymentRequest.cshtml index 389c7c4d0..8ab35a293 100644 --- a/BTCPayServer/Views/PaymentRequest/EditPaymentRequest.cshtml +++ b/BTCPayServer/Views/PaymentRequest/EditPaymentRequest.cshtml @@ -108,20 +108,20 @@ asp-route-searchterm="@($"orderid:{PaymentRequestRepository.GetOrderIdForPaymentRequest(Model.Id)}")">Invoices Clone @if (!Model.Archived) - { - Archive - + { + Archive + } else { - Unarchive - + Unarchive + } } - - Back to list +
+ Back to List
From 543e628a8ba49c6061c6089507908e7580dee1a9 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Fri, 16 Oct 2020 15:23:38 -0500 Subject: [PATCH 07/12] Removing rates hint --- BTCPayServer/Controllers/StoresController.cs | 4 +--- BTCPayServer/Data/StoreBlob.cs | 1 - BTCPayServer/Models/StoreViewModels/RatesViewModel.cs | 1 - BTCPayServer/Services/Stores/StoreRepository.cs | 3 +-- BTCPayServer/Views/Stores/Rates.cshtml | 11 ----------- 5 files changed, 2 insertions(+), 18 deletions(-) diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 78ee8358d..718da19e5 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -210,7 +210,6 @@ namespace BTCPayServer.Controllers vm.AvailableExchanges = exchanges; vm.DefaultCurrencyPairs = storeBlob.GetDefaultCurrencyPairString(); vm.ShowScripting = storeBlob.RateScripting; - vm.HintRates = storeBlob.Hints?.Rates == true; return View(vm); } @@ -256,7 +255,6 @@ 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))) @@ -988,7 +986,7 @@ namespace BTCPayServer.Controllers public async Task DismissHint(string id) { var blob = CurrentStore.GetStoreBlob(); - if (id == "Rates" || id == "Wallet" || id == "Lightning") + if (id == "Wallet" || id == "Lightning") { try { diff --git a/BTCPayServer/Data/StoreBlob.cs b/BTCPayServer/Data/StoreBlob.cs index 0ca210e6d..e86d767c8 100644 --- a/BTCPayServer/Data/StoreBlob.cs +++ b/BTCPayServer/Data/StoreBlob.cs @@ -193,7 +193,6 @@ namespace BTCPayServer.Data { public bool Wallet { get; set; } public bool Lightning { get; set; } - public bool Rates { get; set; } } public IPaymentFilter GetExcludedPaymentMethods() diff --git a/BTCPayServer/Models/StoreViewModels/RatesViewModel.cs b/BTCPayServer/Models/StoreViewModels/RatesViewModel.cs index bfb86b395..fa7bfde21 100644 --- a/BTCPayServer/Models/StoreViewModels/RatesViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/RatesViewModel.cs @@ -53,7 +53,6 @@ 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/Services/Stores/StoreRepository.cs b/BTCPayServer/Services/Stores/StoreRepository.cs index fec4c0c71..b41ff2f6f 100644 --- a/BTCPayServer/Services/Stores/StoreRepository.cs +++ b/BTCPayServer/Services/Stores/StoreRepository.cs @@ -186,8 +186,7 @@ namespace BTCPayServer.Services.Stores blob.Hints = new Data.StoreBlob.StoreHints { Wallet = true, - Lightning = true, - Rates = true + Lightning = true }; store.SetStoreBlob(blob); await CreateStore(ownerId, store); diff --git a/BTCPayServer/Views/Stores/Rates.cshtml b/BTCPayServer/Views/Stores/Rates.cshtml index bca54646b..18e657c46 100644 --- a/BTCPayServer/Views/Stores/Rates.cshtml +++ b/BTCPayServer/Views/Stores/Rates.cshtml @@ -18,17 +18,6 @@
- @if (Model.HintRates) - { -

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

- } @if (Model.ShowScripting) {
From 1646241dfb5b24a1094dd37de6383f6b9763257d Mon Sep 17 00:00:00 2001 From: rockstardev Date: Sat, 17 Oct 2020 14:26:29 -0500 Subject: [PATCH 08/12] Switch to POST for dismissing hints --- BTCPayServer/Controllers/StoresController.cs | 5 +++-- BTCPayServer/Views/Stores/_Nav.cshtml | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 718da19e5..889c9e785 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -981,8 +981,9 @@ namespace BTCPayServer.Controllers }); } - [HttpGet] - [Route("{storeId}/dismissHint/{id}")] + [HttpPost] + [Route("{storeId}/dismissHint")] + [IgnoreAntiforgeryToken] public async Task DismissHint(string id) { var blob = CurrentStore.GetStoreBlob(); diff --git a/BTCPayServer/Views/Stores/_Nav.cshtml b/BTCPayServer/Views/Stores/_Nav.cshtml index d99241fe5..1ceb65553 100644 --- a/BTCPayServer/Views/Stores/_Nav.cshtml +++ b/BTCPayServer/Views/Stores/_Nav.cshtml @@ -18,9 +18,7 @@ var url = "@Url.Action("DismissHint", "Stores", new { storeId = "store_Id", id="hint_Id" })" .replace("hint_Id", hintId) .replace("store_Id", storeId); - $.get(url, function (data) { - //row.toggleClass("seen loading"); - }); + $.post(url); return true; } From ef99eeb3002479c5462914e4ab20be8378736b22 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Sat, 17 Oct 2020 15:03:28 -0500 Subject: [PATCH 09/12] Adding selenium test for store hints --- BTCPayServer.Tests/SeleniumTester.cs | 2 +- BTCPayServer.Tests/SeleniumTests.cs | 18 +++++++++++++++++- .../Controllers/StoresController.BTCLike.cs | 4 +++- BTCPayServer/Views/Invoice/ListInvoices.cshtml | 2 +- BTCPayServer/Views/Stores/UpdateStore.cshtml | 4 ++-- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/BTCPayServer.Tests/SeleniumTester.cs b/BTCPayServer.Tests/SeleniumTester.cs index b3d36c370..224a60349 100644 --- a/BTCPayServer.Tests/SeleniumTester.cs +++ b/BTCPayServer.Tests/SeleniumTester.cs @@ -303,7 +303,7 @@ namespace BTCPayServer.Tests public string CreateInvoice(string storeName, decimal amount = 100, string currency = "USD", string refundEmail = "") { GoToInvoices(); - Driver.FindElement(By.Id("CreateNewInvoice")).Click(); + Driver.FindElement(By.Id("CreateNewInvoice")).Click(); // ocassionally gets stuck for some reason, tried force click and wait for element Driver.FindElement(By.Id("Amount")).SendKeys(amount.ToString(CultureInfo.InvariantCulture)); var currencyEl = Driver.FindElement(By.Id("Currency")); currencyEl.Clear(); diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index 971d1fede..583599a5e 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -301,8 +301,19 @@ namespace BTCPayServer.Tests await s.StartAsync(); var alice = s.RegisterNewUser(); var store = s.CreateNewStore().storeName; - s.AddDerivationScheme(); + // verify that hints are displayed on the store page + Assert.True(s.Driver.PageSource.Contains("Wallet not setup for the store, please provide Derviation Scheme"), + "Wallet hint not present"); + Assert.True(s.Driver.PageSource.Contains("Review settings if you want to receive Lightning payments"), + "Lightning hint not present"); + + s.AddDerivationScheme(); // wallet hint should be dismissed s.Driver.AssertNoError(); + Assert.False(s.Driver.PageSource.Contains("Wallet not setup for the store, please provide Derviation Scheme"), + "Wallet hint not dismissed on derivation scheme add"); + + s.Driver.FindElement(By.Id("dismissLightningHint")).Click(); // dismiss lightning hint + Assert.Contains(store, s.Driver.PageSource); var storeUrl = s.Driver.Url; s.ClickOnAllSideMenus(); @@ -362,6 +373,11 @@ namespace BTCPayServer.Tests s.Logout(); LogIn(s, alice); s.Driver.FindElement(By.Id("Stores")).Click(); + + // there shouldn't be any hints now + Assert.False(s.Driver.PageSource.Contains("Review settings if you want to receive Lightning payments"), + "Lightning hint should be dismissed at this point"); + s.Driver.FindElement(By.LinkText("Remove")).Click(); s.Driver.FindElement(By.Id("continue")).Click(); s.Driver.FindElement(By.Id("Stores")).Click(); diff --git a/BTCPayServer/Controllers/StoresController.BTCLike.cs b/BTCPayServer/Controllers/StoresController.BTCLike.cs index 5215f0333..372de61e0 100644 --- a/BTCPayServer/Controllers/StoresController.BTCLike.cs +++ b/BTCPayServer/Controllers/StoresController.BTCLike.cs @@ -167,7 +167,7 @@ namespace BTCPayServer.Controllers (vm.Confirmation && !string.IsNullOrWhiteSpace(vm.HintAddress)) || // - The user is clicking on continue after changing the config (!vm.Confirmation && oldConfig != vm.Config) || - // - The user is clickingon continue without changing config nor enabling/disabling + // - The user is clicking on continue without changing config nor enabling/disabling (!vm.Confirmation && oldConfig == vm.Config && willBeExcluded == wasExcluded); showAddress = showAddress && strategy != null; @@ -179,6 +179,7 @@ namespace BTCPayServer.Controllers await wallet.TrackAsync(strategy.AccountDerivation); store.SetSupportedPaymentMethod(paymentMethodId, strategy); storeBlob.SetExcluded(paymentMethodId, willBeExcluded); + storeBlob.Hints.Wallet = false; store.SetStoreBlob(storeBlob); } catch @@ -202,6 +203,7 @@ namespace BTCPayServer.Controllers { TempData[WellKnownTempData.SuccessMessage] = $"Derivation settings for {network.CryptoCode} has been modified."; } + // This is success case when derivation scheme is added to the store return RedirectToAction(nameof(UpdateStore), new { storeId = storeId }); } else if (!string.IsNullOrEmpty(vm.HintAddress)) diff --git a/BTCPayServer/Views/Invoice/ListInvoices.cshtml b/BTCPayServer/Views/Invoice/ListInvoices.cshtml index 4b3bce4fb..4dae378fc 100644 --- a/BTCPayServer/Views/Invoice/ListInvoices.cshtml +++ b/BTCPayServer/Views/Invoice/ListInvoices.cshtml @@ -29,7 +29,7 @@
- + Create an invoice diff --git a/BTCPayServer/Views/Stores/UpdateStore.cshtml b/BTCPayServer/Views/Stores/UpdateStore.cshtml index 1190513ec..1cc3dcbc2 100644 --- a/BTCPayServer/Views/Stores/UpdateStore.cshtml +++ b/BTCPayServer/Views/Stores/UpdateStore.cshtml @@ -24,7 +24,7 @@ {

- Wallet not setup for the store. Please provide Derviation Scheme + Wallet not setup for the store, please provide Derviation Scheme From be9cc419578e459bf649b2640f5d9ca065a688ed Mon Sep 17 00:00:00 2001 From: rockstardev Date: Sat, 17 Oct 2020 15:52:41 -0500 Subject: [PATCH 10/12] Dismissing lightning hint when connection is setup --- BTCPayServer/Controllers/StoresController.LightningLike.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/BTCPayServer/Controllers/StoresController.LightningLike.cs b/BTCPayServer/Controllers/StoresController.LightningLike.cs index 251d19f4c..a82c7b77c 100644 --- a/BTCPayServer/Controllers/StoresController.LightningLike.cs +++ b/BTCPayServer/Controllers/StoresController.LightningLike.cs @@ -137,6 +137,7 @@ namespace BTCPayServer.Controllers case "save": var storeBlob = store.GetStoreBlob(); storeBlob.SetExcluded(paymentMethodId, !vm.Enabled); + storeBlob.Hints.Lightning = false; store.SetStoreBlob(storeBlob); store.SetSupportedPaymentMethod(paymentMethodId, paymentMethod); await _Repo.UpdateStore(store); From d90fcf15bdc15d2720b03a03e99494b8f6c81c85 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Sat, 17 Oct 2020 15:53:07 -0500 Subject: [PATCH 11/12] Verifying presence of wallet warning on store list --- BTCPayServer.Tests/SeleniumTester.cs | 4 ++++ BTCPayServer.Tests/SeleniumTests.cs | 11 ++++++++--- BTCPayServer/Views/UserStores/ListStores.cshtml | 5 ++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/BTCPayServer.Tests/SeleniumTester.cs b/BTCPayServer.Tests/SeleniumTester.cs index 224a60349..0113bc6f5 100644 --- a/BTCPayServer.Tests/SeleniumTester.cs +++ b/BTCPayServer.Tests/SeleniumTester.cs @@ -228,7 +228,11 @@ namespace BTCPayServer.Tests Driver.FindElement(By.Id("Email")).SendKeys(user); Driver.FindElement(By.Id("Password")).SendKeys(password); Driver.FindElement(By.Id("LoginButton")).Click(); + } + public void GoToStores() + { + Driver.FindElement(By.Id("Stores")).Click(); } public void GoToStore(string storeId, StoreNavPages storeNavPage = StoreNavPages.Index) diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index 583599a5e..7fb42e173 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -300,13 +300,18 @@ namespace BTCPayServer.Tests { await s.StartAsync(); var alice = s.RegisterNewUser(); - var store = s.CreateNewStore().storeName; + var storeData = s.CreateNewStore(); // verify that hints are displayed on the store page Assert.True(s.Driver.PageSource.Contains("Wallet not setup for the store, please provide Derviation Scheme"), "Wallet hint not present"); Assert.True(s.Driver.PageSource.Contains("Review settings if you want to receive Lightning payments"), "Lightning hint not present"); + s.GoToStores(); + Assert.True(s.Driver.PageSource.Contains("warninghint_" + storeData.storeId), + "Warning hint on list not present"); + + s.GoToStore(storeData.storeId); s.AddDerivationScheme(); // wallet hint should be dismissed s.Driver.AssertNoError(); Assert.False(s.Driver.PageSource.Contains("Wallet not setup for the store, please provide Derviation Scheme"), @@ -314,11 +319,11 @@ namespace BTCPayServer.Tests s.Driver.FindElement(By.Id("dismissLightningHint")).Click(); // dismiss lightning hint - Assert.Contains(store, s.Driver.PageSource); + Assert.Contains(storeData.storeName, s.Driver.PageSource); var storeUrl = s.Driver.Url; s.ClickOnAllSideMenus(); s.GoToInvoices(); - var invoiceId = s.CreateInvoice(store); + var invoiceId = s.CreateInvoice(storeData.storeName); s.AssertHappyMessage(); s.Driver.FindElement(By.ClassName("invoice-details-link")).Click(); var invoiceUrl = s.Driver.Url; diff --git a/BTCPayServer/Views/UserStores/ListStores.cshtml b/BTCPayServer/Views/UserStores/ListStores.cshtml index a2b54678e..4b1c847ad 100644 --- a/BTCPayServer/Views/UserStores/ListStores.cshtml +++ b/BTCPayServer/Views/UserStores/ListStores.cshtml @@ -66,16 +66,15 @@ @if (store.IsOwner) { - @store.Name + @store.Name } else { @store.Name } - @if (store.HintWalletWarning) { - + } From 2f25f1790e20af6c82fe8a1abc410481d828ddc5 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Sat, 17 Oct 2020 16:03:46 -0500 Subject: [PATCH 12/12] Trying to prevent ocassional chrome crashes Error: The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed. --- BTCPayServer.Tests/SeleniumTester.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/BTCPayServer.Tests/SeleniumTester.cs b/BTCPayServer.Tests/SeleniumTester.cs index 0113bc6f5..12dd261ba 100644 --- a/BTCPayServer.Tests/SeleniumTester.cs +++ b/BTCPayServer.Tests/SeleniumTester.cs @@ -42,18 +42,19 @@ namespace BTCPayServer.Tests { await Server.StartAsync(); ChromeOptions options = new ChromeOptions(); - var isDebug = !Server.PayTester.InContainer; + if (Server.PayTester.InContainer) + { + // this must be first option https://stackoverflow.com/questions/53073411/selenium-webdriverexceptionchrome-failed-to-start-crashed-as-google-chrome-is#comment102570662_53073789 + options.AddArgument("no-sandbox"); + } + var isDebug = !Server.PayTester.InContainer; if (!isDebug) { options.AddArguments("headless"); // Comment to view browser options.AddArguments("window-size=1200x1000"); // Comment to view browser } options.AddArgument("shm-size=2g"); - if (Server.PayTester.InContainer) - { - options.AddArgument("no-sandbox"); - } Driver = new ChromeDriver(Server.PayTester.InContainer ? "/usr/bin" : Directory.GetCurrentDirectory(), options); if (isDebug) {