diff --git a/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.LiquidAssets.cs b/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.LiquidAssets.cs index d257e8b72..e02e2275b 100644 --- a/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.LiquidAssets.cs +++ b/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.LiquidAssets.cs @@ -19,7 +19,7 @@ namespace BTCPayServer "USDT_X = USDT_BTC * BTC_X", "USDT_BTC = bitfinex(UST_BTC)", }, - AssetId = new uint256("ce091c998b83c78bb71a632313ba3760f1763d9cfcffae02258ffa9865a37bd2"), + AssetId = NetworkType == ChainName.Regtest? null: new uint256("ce091c998b83c78bb71a632313ba3760f1763d9cfcffae02258ffa9865a37bd2"), DisplayName = "Liquid Tether", BlockExplorerLink = NetworkType == ChainName.Mainnet ? "https://liquid.network/tx/{0}" : "https://liquid.network/testnet/tx/{0}", NBXplorerNetwork = nbxplorerNetwork, @@ -42,7 +42,7 @@ namespace BTCPayServer "ETB_BTC = bitpay(ETB_BTC)" }, Divisibility = 2, - AssetId = new uint256("aa775044c32a7df391902b3659f46dfe004ccb2644ce2ddc7dba31e889391caf"), + AssetId = NetworkType == ChainName.Regtest? null: new uint256("aa775044c32a7df391902b3659f46dfe004ccb2644ce2ddc7dba31e889391caf"), DisplayName = "Ethiopian Birr", BlockExplorerLink = NetworkType == ChainName.Mainnet ? "https://liquid.network/tx/{0}" : "https://liquid.network/testnet/tx/{0}", NBXplorerNetwork = nbxplorerNetwork, @@ -65,7 +65,7 @@ namespace BTCPayServer "LCAD_BTC = bylls(CAD_BTC)", "CAD_BTC = LCAD_BTC" }, - AssetId = new uint256("0e99c1a6da379d1f4151fb9df90449d40d0608f6cb33a5bcbfc8c265f42bab0a"), + AssetId = NetworkType == ChainName.Regtest? null: new uint256("0e99c1a6da379d1f4151fb9df90449d40d0608f6cb33a5bcbfc8c265f42bab0a"), DisplayName = "Liquid CAD", BlockExplorerLink = NetworkType == ChainName.Mainnet ? "https://liquid.network/tx/{0}" : "https://liquid.network/testnet/tx/{0}", NBXplorerNetwork = nbxplorerNetwork, diff --git a/BTCPayServer.Common/Altcoins/Liquid/ElementsLikeBtcPayNetwork.cs b/BTCPayServer.Common/Altcoins/Liquid/ElementsLikeBtcPayNetwork.cs index 9aa863470..1a9358321 100644 --- a/BTCPayServer.Common/Altcoins/Liquid/ElementsLikeBtcPayNetwork.cs +++ b/BTCPayServer.Common/Altcoins/Liquid/ElementsLikeBtcPayNetwork.cs @@ -19,7 +19,8 @@ namespace BTCPayServer NewTransactionEvent evtOutputs) { return evtOutputs.Outputs.Where(output => - output.Value is AssetMoney assetMoney && assetMoney.AssetId == AssetId).Select(output => + (output.Value is not AssetMoney && NetworkCryptoCode.Equals(evtOutputs.CryptoCode, StringComparison.InvariantCultureIgnoreCase)) || + (output.Value is AssetMoney assetMoney && assetMoney.AssetId == AssetId)).Select(output => { var outpoint = new OutPoint(evtOutputs.TransactionData.TransactionHash, output.Index); return (output, outpoint); diff --git a/BTCPayServer.Rating/CurrencyNameTable.cs b/BTCPayServer.Rating/CurrencyNameTable.cs index 56aada94a..f26279301 100644 --- a/BTCPayServer.Rating/CurrencyNameTable.cs +++ b/BTCPayServer.Rating/CurrencyNameTable.cs @@ -20,13 +20,13 @@ namespace BTCPayServer.Services.Rates } public class CurrencyNameTable { - public static CurrencyNameTable Instance = new CurrencyNameTable(); + public static CurrencyNameTable Instance = new(); public CurrencyNameTable() { - _Currencies = LoadCurrency().ToDictionary(k => k.Code); + _Currencies = LoadCurrency().ToDictionary(k => k.Code, StringComparer.InvariantCultureIgnoreCase); } - static readonly Dictionary _CurrencyProviders = new Dictionary(); + static readonly Dictionary _CurrencyProviders = new(); public NumberFormatInfo GetNumberFormatInfo(string currency, bool useFallback) { diff --git a/BTCPayServer.Rating/CurrencyPair.cs b/BTCPayServer.Rating/CurrencyPair.cs index de6e0fb52..bd761d627 100644 --- a/BTCPayServer.Rating/CurrencyPair.cs +++ b/BTCPayServer.Rating/CurrencyPair.cs @@ -19,7 +19,7 @@ namespace BTCPayServer.Rating public static CurrencyPair Parse(string str) { if (!TryParse(str, out var result)) - throw new FormatException("Invalid currency pair"); + throw new FormatException($"Invalid currency pair ({str})"); return result; } public static bool TryParse(string str, out CurrencyPair value) diff --git a/BTCPayServer.Tests/AltcoinTests/ElementsTests.cs b/BTCPayServer.Tests/AltcoinTests/ElementsTests.cs index bf48dc56f..71a911c7b 100644 --- a/BTCPayServer.Tests/AltcoinTests/ElementsTests.cs +++ b/BTCPayServer.Tests/AltcoinTests/ElementsTests.cs @@ -52,11 +52,12 @@ namespace BTCPayServer.Tests { tester.ActivateLBTC(); await tester.StartAsync(); + + //https://github.com/ElementsProject/elements/issues/956 + await tester.LBTCExplorerNode.SendCommandAsync("rescanblockchain"); var user = tester.NewAccount(); - user.GrantAccess(); - user.RegisterDerivationScheme("LBTC"); - user.RegisterDerivationScheme("USDT"); - user.RegisterDerivationScheme("ETB"); + await user.GrantAccessAsync(); + await tester.LBTCExplorerNode.GenerateAsync(4); //no tether on our regtest, lets create it and set it var tether = tester.NetworkProvider.GetNetwork("USDT"); @@ -75,6 +76,10 @@ namespace BTCPayServer.Tests .AssetId = etb.AssetId; + user.RegisterDerivationScheme("LBTC"); + user.RegisterDerivationScheme("USDT"); + user.RegisterDerivationScheme("ETB"); + //test: register 2 assets on the same elements network and make sure paying an invoice on one does not affect the other in any way var invoice = await user.BitPay.CreateInvoiceAsync(new Invoice(0.1m, "BTC")); Assert.Equal(3, invoice.SupportedTransactionCurrencies.Count); @@ -82,7 +87,7 @@ namespace BTCPayServer.Tests //1 lbtc = 1 btc Assert.Equal(1, ci.Rate); var star = await tester.LBTCExplorerNode.SendCommandAsync("sendtoaddress", ci.Address, ci.Due, "", "", false, true, - 1, "UNSET", lbtc.AssetId); + 1, "UNSET",false, lbtc.AssetId.ToString()); TestUtils.Eventually(() => { @@ -95,8 +100,7 @@ namespace BTCPayServer.Tests ci = invoice.CryptoInfo.Single(info => info.CryptoCode.Equals("USDT")); Assert.Equal(3, invoice.SupportedTransactionCurrencies.Count); - star = await tester.LBTCExplorerNode.SendCommandAsync("sendtoaddress", ci.Address, ci.Due, "", "", false, true, - 1, "UNSET", tether.AssetId); + star = tester.LBTCExplorerNode.SendCommand("sendtoaddress", ci.Address, decimal.Parse(ci.Due), "x", "z", false, true, 1, "unset", false, tether.AssetId.ToString()); TestUtils.Eventually(() => { diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 7e6784974..ce6d2848b 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -386,11 +386,11 @@ namespace BTCPayServer.Tests var newBolt11 = newInvoice.CryptoInfo.First(o => o.PaymentUrls.BOLT11 != null).PaymentUrls.BOLT11; var oldBolt11 = invoice.CryptoInfo.First(o => o.PaymentUrls.BOLT11 != null).PaymentUrls.BOLT11; Assert.NotEqual(newBolt11, oldBolt11); - Assert.Equal(newInvoice.BtcDue.GetValue(), + Assert.Equal(newInvoice.BtcDue.ToDecimal(MoneyUnit.BTC), BOLT11PaymentRequest.Parse(newBolt11, Network.RegTest).MinimumAmount.ToDecimal(LightMoneyUnit.BTC)); }, 40000); - TestLogs.LogInformation($"Paying invoice {newInvoice.Id} remaining due amount {newInvoice.BtcDue.GetValue()} via lightning"); + TestLogs.LogInformation($"Paying invoice {newInvoice.Id} remaining due amount {newInvoice.BtcDue.GetValue((BTCPayNetwork) tester.DefaultNetwork)} via lightning"); var evt = await tester.WaitForEvent(async () => { await tester.SendLightningPaymentAsync(newInvoice); diff --git a/BTCPayServer.Tests/docker-compose.altcoins.yml b/BTCPayServer.Tests/docker-compose.altcoins.yml index c87e674ff..b516e54f4 100644 --- a/BTCPayServer.Tests/docker-compose.altcoins.yml +++ b/BTCPayServer.Tests/docker-compose.altcoins.yml @@ -99,7 +99,7 @@ services: custom: nbxplorer: - image: nicolasdorier/nbxplorer:2.3.63 + image: nicolasdorier/nbxplorer:2.3.66 restart: unless-stopped ports: - "32838:32838" @@ -307,7 +307,7 @@ services: - "torrcdir:/usr/local/etc/tor" - "tor_servicesdir:/var/lib/tor/hidden_services" monerod: - image: btcpayserver/monero:0.17.0.0-amd64 + image: btcpayserver/monero:0.18.2.2-5 restart: unless-stopped container_name: xmr_monerod entrypoint: sleep 999999 @@ -317,7 +317,7 @@ services: ports: - "18081:18081" monero_wallet: - image: btcpayserver/monero:0.17.0.0-amd64 + image: btcpayserver/monero:0.18.2.2-5 restart: unless-stopped container_name: xmr_wallet_rpc entrypoint: monero-wallet-rpc --testnet --rpc-bind-ip=0.0.0.0 --disable-rpc-login --confirm-external-bind --rpc-bind-port=18082 --non-interactive --trusted-daemon --daemon-address=monerod:18081 --wallet-file=/wallet/wallet.keys --password-file=/wallet/password --tx-notify="/bin/sh ./scripts/notifier.sh -k -X GET https://host.docker.internal:14142/monerolikedaemoncallback/tx?cryptoCode=xmr&hash=%s" @@ -349,7 +349,7 @@ services: elementsd-liquid: restart: always container_name: btcpayserver_elementsd_liquid - image: btcpayserver/elements:0.21.0.1 + image: btcpayserver/elements:0.21.0.2-4 environment: ELEMENTS_CHAIN: elementsregtest ELEMENTS_EXTRA_ARGS: | @@ -364,11 +364,9 @@ services: whitelist=0.0.0.0/0 rpcallowip=0.0.0.0/0 validatepegin=0 - initialfreecoins=210000000000000 + initialfreecoins=2100000000000000 con_dyna_deploy_signal=1 - con_dyna_deploy_start=0 - con_nminerconfirmationwindow=1 - con_nrulechangeactivationthreshold=1 + con_dyna_deploy_start=10 expose: - "19332" - "19444" diff --git a/BTCPayServer.Tests/docker-compose.yml b/BTCPayServer.Tests/docker-compose.yml index 22305ace9..0bbacfd9e 100644 --- a/BTCPayServer.Tests/docker-compose.yml +++ b/BTCPayServer.Tests/docker-compose.yml @@ -96,7 +96,7 @@ services: custom: nbxplorer: - image: nicolasdorier/nbxplorer:2.3.63 + image: nicolasdorier/nbxplorer:2.3.66 restart: unless-stopped ports: - "32838:32838" diff --git a/BTCPayServer/Components/StoreWalletBalance/Default.cshtml b/BTCPayServer/Components/StoreWalletBalance/Default.cshtml index d135e5707..70cf19e4b 100644 --- a/BTCPayServer/Components/StoreWalletBalance/Default.cshtml +++ b/BTCPayServer/Components/StoreWalletBalance/Default.cshtml @@ -1,6 +1,7 @@ @using BTCPayServer.Services.Wallets +@using BTCPayServer.Payments @model BTCPayServer.Components.StoreWalletBalance.StoreWalletBalanceViewModel - +@inject BTCPayNetworkProvider NetworkProvider
Wallet Balance
@@ -38,6 +39,12 @@ {
} + else if (!Model.Store.GetSupportedPaymentMethods(NetworkProvider).Any(method => method.PaymentId.PaymentType == BitcoinPaymentType.Instance && method.PaymentId.CryptoCode == Model.CryptoCode)) + { +

+ We would like to show you a chart of your balance but you have not yet configured a wallet. +

+ } else {

diff --git a/BTCPayServer/Components/StoreWalletBalance/StoreWalletBalance.cs b/BTCPayServer/Components/StoreWalletBalance/StoreWalletBalance.cs index 62df01fae..d070028a0 100644 --- a/BTCPayServer/Components/StoreWalletBalance/StoreWalletBalance.cs +++ b/BTCPayServer/Components/StoreWalletBalance/StoreWalletBalance.cs @@ -75,7 +75,7 @@ public class StoreWalletBalance : ViewComponent if (derivation is not null) { var balance = await wallet.GetBalance(derivation.AccountDerivation, cts.Token); - vm.Balance = balance.Available.GetValue(); + vm.Balance = balance.Available.GetValue(derivation.Network); } } diff --git a/BTCPayServer/Components/WalletNav/WalletNav.cs b/BTCPayServer/Components/WalletNav/WalletNav.cs index 5dd2607ef..2fe8230bb 100644 --- a/BTCPayServer/Components/WalletNav/WalletNav.cs +++ b/BTCPayServer/Components/WalletNav/WalletNav.cs @@ -74,7 +74,7 @@ namespace BTCPayServer.Components.WalletNav if (bid is decimal b) { var currencyData = _currencies.GetCurrencyData(defaultCurrency, true); - vm.BalanceDefaultCurrency = (balance.GetValue() * b).ShowMoney(currencyData.Divisibility); + vm.BalanceDefaultCurrency = (balance.GetValue(network) * b).ShowMoney(currencyData.Divisibility); } } diff --git a/BTCPayServer/Controllers/UIWalletsController.cs b/BTCPayServer/Controllers/UIWalletsController.cs index c5704e940..7de358d52 100644 --- a/BTCPayServer/Controllers/UIWalletsController.cs +++ b/BTCPayServer/Controllers/UIWalletsController.cs @@ -383,10 +383,18 @@ namespace BTCPayServer.Controllers private async Task SendFreeMoney(Cheater cheater, WalletId walletId, DerivationSchemeSettings paymentMethod) { var c = this.ExplorerClientProvider.GetExplorerClient(walletId.CryptoCode); + var cashCow = cheater.GetCashCow(walletId.CryptoCode); +#if ALTCOINS + if (walletId.CryptoCode == "LBTC") + { + await cashCow.SendCommandAsync("rescanblockchain"); + } +#endif var addresses = Enumerable.Range(0, 200).Select(_ => c.GetUnusedAsync(paymentMethod.AccountDerivation, DerivationFeature.Deposit, reserve: true)).ToArray(); + await Task.WhenAll(addresses); - await cheater.CashCow.GenerateAsync(addresses.Length / 8); - var b = cheater.CashCow.PrepareBatch(); + await cashCow.GenerateAsync(addresses.Length / 8); + var b = cashCow.PrepareBatch(); Random r = new Random(); List> sending = new List>(); foreach (var a in addresses) @@ -394,7 +402,7 @@ namespace BTCPayServer.Controllers sending.Add(b.SendToAddressAsync((await a).Address, Money.Coins(0.1m) + Money.Satoshis(r.Next(0, 90_000_000)))); } await b.SendBatchAsync(); - await cheater.CashCow.GenerateAsync(1); + await cashCow.GenerateAsync(1); var factory = ServiceProvider.GetRequiredService(); diff --git a/BTCPayServer/Extensions/MoneyExtensions.cs b/BTCPayServer/Extensions/MoneyExtensions.cs index 5db82f6b9..81496d7c4 100644 --- a/BTCPayServer/Extensions/MoneyExtensions.cs +++ b/BTCPayServer/Extensions/MoneyExtensions.cs @@ -8,7 +8,7 @@ namespace BTCPayServer { public static class MoneyExtensions { - public static decimal GetValue(this IMoney m, BTCPayNetwork network = null) + public static decimal GetValue(this IMoney m, BTCPayNetwork network) { switch (m) { diff --git a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs index 1b29c56b1..73aa6061e 100644 --- a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs +++ b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs @@ -55,21 +55,26 @@ namespace BTCPayServer.Services.Altcoins.Monero.UI [HttpGet()] public async Task GetStoreMoneroLikePaymentMethods() { - var monero = StoreData.GetSupportedPaymentMethods(_BtcPayNetworkProvider) + return View(await GetVM(StoreData)); + } +[NonAction] + public async Task GetVM(StoreData storeData) + { + var monero = storeData.GetSupportedPaymentMethods(_BtcPayNetworkProvider) .OfType(); - var excludeFilters = StoreData.GetStoreBlob().GetExcludedPaymentMethods(); + var excludeFilters = storeData.GetStoreBlob().GetExcludedPaymentMethods(); var accountsList = _MoneroLikeConfiguration.MoneroLikeConfigurationItems.ToDictionary(pair => pair.Key, pair => GetAccounts(pair.Key)); await Task.WhenAll(accountsList.Values); - return View(new MoneroLikePaymentMethodListViewModel() + return new MoneroLikePaymentMethodListViewModel() { Items = _MoneroLikeConfiguration.MoneroLikeConfigurationItems.Select(pair => GetMoneroLikePaymentMethodViewModel(monero, pair.Key, excludeFilters, accountsList[pair.Key].Result)) - }); + }; } private Task GetAccounts(string cryptoCode) diff --git a/BTCPayServer/Services/Cheater.cs b/BTCPayServer/Services/Cheater.cs index 0651c38d5..2c9f5c631 100644 --- a/BTCPayServer/Services/Cheater.cs +++ b/BTCPayServer/Services/Cheater.cs @@ -1,14 +1,17 @@ using System; +using System.Linq; using System.Threading; using System.Threading.Tasks; using BTCPayServer.Services.Invoices; using Microsoft.Extensions.Hosting; +using NBitcoin; using NBitcoin.RPC; namespace BTCPayServer.Services { public class Cheater : IHostedService { + private readonly ExplorerClientProvider _prov; private readonly InvoiceRepository _invoiceRepository; public RPCClient CashCow { get; set; } @@ -17,18 +20,47 @@ namespace BTCPayServer.Services InvoiceRepository invoiceRepository) { CashCow = prov.GetExplorerClient("BTC")?.RPCClient; + _prov = prov; _invoiceRepository = invoiceRepository; } + public RPCClient GetCashCow(string cryptoCode) + { + return _prov.GetExplorerClient(cryptoCode)?.RPCClient; + } + public async Task UpdateInvoiceExpiry(string invoiceId, TimeSpan seconds) { await _invoiceRepository.UpdateInvoiceExpiry(invoiceId, seconds); } - Task IHostedService.StartAsync(CancellationToken cancellationToken) + async Task IHostedService.StartAsync(CancellationToken cancellationToken) { _ = CashCow?.ScanRPCCapabilitiesAsync(cancellationToken); - return Task.CompletedTask; +#if ALTCOINS + var liquid = _prov.GetNetwork("LBTC"); + if (liquid is not null) + { + var lbtcrpc = GetCashCow(liquid.CryptoCode); + await lbtcrpc.SendCommandAsync("rescanblockchain"); + var elements = _prov.NetworkProviders.GetAll().OfType(); + foreach (ElementsBTCPayNetwork element in elements) + { + try + { + if (element.AssetId is null) + { + var issueAssetResult = await lbtcrpc.SendCommandAsync("issueasset", 100000, 0); + element.AssetId = uint256.Parse(issueAssetResult.Result["asset"].ToString()); + } + } + catch (Exception e) + { + } + } + } + +#endif } Task IHostedService.StopAsync(CancellationToken cancellationToken) diff --git a/BTCPayServer/Services/Reporting/OnChainWalletReportProvider.cs b/BTCPayServer/Services/Reporting/OnChainWalletReportProvider.cs index aef1b921b..2cdf3172f 100644 --- a/BTCPayServer/Services/Reporting/OnChainWalletReportProvider.cs +++ b/BTCPayServer/Services/Reporting/OnChainWalletReportProvider.cs @@ -81,7 +81,7 @@ public class OnChainWalletReportProvider : ReportProvider var walletId = new WalletId(store.Id, settings.Network.CryptoCode); var command = new CommandDefinition( commandText: - "SELECT r.tx_id, r.seen_at, t.blk_id, t.blk_height, r.balance_change " + + "SELECT r.tx_id, r.seen_at, t.blk_id, t.blk_height, r.balance_change, r.asset_id " + "FROM get_wallets_recent(@wallet_id, @code, @interval, NULL, NULL) r " + "JOIN txs t USING (code, tx_id) " + "ORDER BY r.seen_at", @@ -99,6 +99,24 @@ public class OnChainWalletReportProvider : ReportProvider var date = (DateTimeOffset)r.seen_at; if (date > queryContext.To) continue; + +#if ALTCOINS + if (settings.Network is ElementsBTCPayNetwork elementsBTCPayNetwork) + { + var assetId = (string?)r.asset_id; + // if this is an asset scheme, check if the asset id is the same as the network asset id + if (elementsBTCPayNetwork.CryptoCode != elementsBTCPayNetwork.NetworkCryptoCode && + assetId is not null && assetId != elementsBTCPayNetwork.AssetId?.ToString()) + { + continue; + } + else if (elementsBTCPayNetwork.CryptoCode == elementsBTCPayNetwork.NetworkCryptoCode && + !(assetId is null || assetId == elementsBTCPayNetwork.AssetId?.ToString())) + { + continue; + } + } +#endif var values = queryContext.AddData(); var balanceChange = Money.Satoshis((long)r.balance_change).ToDecimal(MoneyUnit.BTC); values.Add(date); diff --git a/BTCPayServer/Services/Reporting/PaymentsReportProvider.cs b/BTCPayServer/Services/Reporting/PaymentsReportProvider.cs index 6392f3426..b817515b5 100644 --- a/BTCPayServer/Services/Reporting/PaymentsReportProvider.cs +++ b/BTCPayServer/Services/Reporting/PaymentsReportProvider.cs @@ -158,6 +158,13 @@ public class PaymentsReportProvider : ReportProvider { cryptoAmount = LightMoney.MilliSatoshis(v).ToDecimal(LightMoneyUnit.BTC); } +#if ALTCOINS + //assetmoney is an object + else if (data.SelectToken("$.value") is JObject valueObject && valueObject.SelectToken("$.value")?.Value() is long amountObj) + { + cryptoAmount = Money.Satoshis(amountObj).ToDecimal(MoneyUnit.BTC); + } +#endif else if (data.SelectToken("$.value")?.Value() is long amount) { cryptoAmount = Money.Satoshis(amount).ToDecimal(MoneyUnit.BTC); diff --git a/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml b/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml index 2160f8ef7..2c5bcaa2e 100644 --- a/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml +++ b/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml @@ -1,22 +1,34 @@ @using BTCPayServer.Services.Altcoins.Monero.Configuration @using BTCPayServer.Services.Altcoins.Monero.UI -@using Microsoft.AspNetCore.Mvc.TagHelpers -@using BTCPayServer.Client -@using BTCPayServer.Abstractions.TagHelpers @using BTCPayServer.Abstractions.Contracts +@inject SignInManager SignInManager; @inject MoneroLikeConfiguration MoneroLikeConfiguration; @inject IScopeProvider ScopeProvider +@inject UIMoneroLikeStoreController UIMoneroLikeStore; @{ var storeId = ScopeProvider.GetCurrentStoreId(); - var isActive = !string.IsNullOrEmpty(storeId) && ViewContext.RouteData.Values.TryGetValue("Controller", out var controller) && controller is not null && - nameof(UIMoneroLikeStoreController).StartsWith(controller.ToString() ?? string.Empty, StringComparison.InvariantCultureIgnoreCase); + } -@if (MoneroLikeConfiguration.MoneroLikeConfigurationItems.Any()) +@if (SignInManager.IsSignedIn(User) && User.IsInRole(Roles.ServerAdmin) && MoneroLikeConfiguration.MoneroLikeConfigurationItems.Any()) { -

+ var store = Context.GetStoreData(); + var result = await UIMoneroLikeStore.GetVM(store); + + foreach (var item in result.Items) + { + + var isActive = !string.IsNullOrEmpty(storeId) && ViewContext.RouteData.Values.TryGetValue("Controller", out var controller) && controller is not null && + nameof(UIMoneroLikeStoreController).StartsWith(controller.ToString() ?? string.Empty, StringComparison.InvariantCultureIgnoreCase) && + ViewContext.RouteData.Values.TryGetValue("cryptoCode", out var cryptoCode) && cryptoCode is not null && cryptoCode.ToString() == item.CryptoCode; + + } } diff --git a/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethod.cshtml b/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethod.cshtml index ea02629a3..9924fe376 100644 --- a/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethod.cshtml +++ b/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethod.cshtml @@ -5,7 +5,7 @@ @{ Layout = "../Shared/_NavLayout.cshtml"; ViewData["NavPartialName"] = "../UIStores/_Nav"; - ViewData.SetActivePage(StoreNavPages.OnchainSettings, $"{Model.CryptoCode} Settings"); + ViewData.SetActivePage(Model.CryptoCode, $"{Model.CryptoCode} Settings", Model.CryptoCode); }
diff --git a/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml b/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml index 62c601ecf..3cebbe6d8 100644 --- a/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml +++ b/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml @@ -4,7 +4,7 @@ @{ Layout = "../Shared/_NavLayout.cshtml"; - ViewData.SetActivePage(StoreNavPages.OnchainSettings, "Monero Settings"); + ViewData.SetActivePage("Monero Settings", "Monero Settings", "Monero Settings"); ViewData["NavPartialName"] = "../UIStores/_Nav"; }