From 20d653798cebc898fdcc4f17036efa604196a672 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Fri, 27 May 2022 16:26:31 +0900 Subject: [PATCH] After a utxo rescan, the cached balance should be invalidated --- BTCPayServer/Controllers/UIAppsPublicController.cs | 2 +- BTCPayServer/Controllers/UIWalletsController.cs | 1 + .../Models/AppViewModels/ViewPointOfSaleViewModel.cs | 4 +--- BTCPayServer/Views/UIAppsPublic/PointOfSale/Print.cshtml | 9 ++++++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/BTCPayServer/Controllers/UIAppsPublicController.cs b/BTCPayServer/Controllers/UIAppsPublicController.cs index 5d4e57f7b..7b96f3a66 100644 --- a/BTCPayServer/Controllers/UIAppsPublicController.cs +++ b/BTCPayServer/Controllers/UIAppsPublicController.cs @@ -102,7 +102,7 @@ namespace BTCPayServer.Controllers CustomCSSLink = settings.CustomCSSLink, CustomLogoLink = storeBlob.CustomLogo, AppId = appId, - Store = store, + StoreId = store.Id, Description = settings.Description, EmbeddedCSS = settings.EmbeddedCSS, RequiresRefundEmail = settings.RequiresRefundEmail diff --git a/BTCPayServer/Controllers/UIWalletsController.cs b/BTCPayServer/Controllers/UIWalletsController.cs index 4237d00a5..433ac562e 100644 --- a/BTCPayServer/Controllers/UIWalletsController.cs +++ b/BTCPayServer/Controllers/UIWalletsController.cs @@ -1158,6 +1158,7 @@ namespace BTCPayServer.Controllers { await explorer.ScanUTXOSetAsync(paymentMethod.AccountDerivation, vm.BatchSize, vm.GapLimit, vm.StartingIndex); + _walletProvider.GetWallet(walletId.CryptoCode).InvalidateCache(paymentMethod.AccountDerivation); } catch (NBXplorerException ex) when (ex.Error.Code == "scanutxoset-in-progress") { diff --git a/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs b/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs index e8480925f..2435eb651 100644 --- a/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs +++ b/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs @@ -1,5 +1,4 @@ using System.ComponentModel.DataAnnotations; -using BTCPayServer.Data; using BTCPayServer.Services.Apps; namespace BTCPayServer.Models.AppViewModels @@ -66,7 +65,6 @@ namespace BTCPayServer.Models.AppViewModels [Display(Name = "Custom CSS Code")] public string EmbeddedCSS { get; set; } public RequiresRefundEmail RequiresRefundEmail { get; set; } = RequiresRefundEmail.InheritFromStore; - - public StoreData Store { get; set; } + public string StoreId { get; set; } } } diff --git a/BTCPayServer/Views/UIAppsPublic/PointOfSale/Print.cshtml b/BTCPayServer/Views/UIAppsPublic/PointOfSale/Print.cshtml index 1516af2a0..e9be9bf8c 100644 --- a/BTCPayServer/Views/UIAppsPublic/PointOfSale/Print.cshtml +++ b/BTCPayServer/Views/UIAppsPublic/PointOfSale/Print.cshtml @@ -1,7 +1,9 @@ @using BTCPayServer.Models.AppViewModels @using BTCPayServer.Payments.Lightning +@using BTCPayServer.Services.Stores @using LNURL @inject BTCPayNetworkProvider BTCPayNetworkProvider +@inject StoreRepository StoreRepository @model BTCPayServer.Models.AppViewModels.ViewPointOfSaleViewModel @{ + var store = await StoreRepository.FindStore(Model.StoreId); Layout = "_LayoutPos"; Context.Request.Query.TryGetValue("cryptocode", out var cryptoCodeValues); var cryptoCode = cryptoCodeValues.FirstOrDefault() ?? "BTC"; - var supported = Model.Store.GetSupportedPaymentMethods(BTCPayNetworkProvider).OfType().OrderBy(method => method.CryptoCode == cryptoCode).FirstOrDefault(); - if (supported != null && !Model.Store.GetEnabledPaymentIds(BTCPayNetworkProvider).Contains(supported.PaymentId)) + var supported = store.GetSupportedPaymentMethods(BTCPayNetworkProvider).OfType().OrderBy(method => method.CryptoCode == cryptoCode).FirstOrDefault(); + if (supported != null && !store.GetEnabledPaymentIds(BTCPayNetworkProvider).Contains(supported.PaymentId)) { supported = null; } @@ -30,7 +33,7 @@ {