diff --git a/BTCPayServer/HostedServices/InvoiceWatcher.cs b/BTCPayServer/HostedServices/InvoiceWatcher.cs index 5a3ea8992..62b4efd20 100644 --- a/BTCPayServer/HostedServices/InvoiceWatcher.cs +++ b/BTCPayServer/HostedServices/InvoiceWatcher.cs @@ -70,7 +70,6 @@ namespace BTCPayServer.HostedServices invoice.Status = "expired"; } - var derivationStrategies = invoice.GetDerivationStrategies(_NetworkProvider).ToArray(); var payments = invoice.GetPayments().Where(p => p.Accounted).ToArray(); var allPaymentMethods = invoice.GetPaymentMethods(_NetworkProvider); var paymentMethod = GetNearestClearedPayment(allPaymentMethods, out var accounting, _NetworkProvider); diff --git a/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs b/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs index dba0b6e71..a8fb4c28b 100644 --- a/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs +++ b/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs @@ -327,7 +327,7 @@ namespace BTCPayServer.Payments.Bitcoin { var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId, true); var alreadyAccounted = GetAllBitcoinPaymentData(invoice).Select(p => p.Outpoint).ToHashSet(); - var strategy = invoice.GetDerivationStrategy(network); + var strategy = GetDerivationStrategy(invoice, network); if (strategy == null) continue; var cryptoId = new PaymentMethodId(network.CryptoCode, PaymentTypes.BTCLike); @@ -349,6 +349,14 @@ namespace BTCPayServer.Payments.Bitcoin return totalPayment; } + private DerivationStrategyBase GetDerivationStrategy(InvoiceEntity invoice, BTCPayNetwork network) + { + return invoice.GetDerivationStrategies(_ExplorerClients.NetworkProviders) + .Where(d => d.Network.CryptoCode == network.CryptoCode) + .Select(d => d.DerivationStrategyBase) + .FirstOrDefault(); + } + private async Task ReceivedPayment(BTCPayWallet wallet, string invoiceId, PaymentEntity payment, DerivationStrategyBase strategy) { var paymentData = (BitcoinLikePaymentData)payment.GetCryptoPaymentData(); diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index ccad2f4e9..182f2550b 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -169,30 +169,6 @@ namespace BTCPayServer.Services.Invoices set; } - public DerivationStrategyBase GetDerivationStrategy(BTCPayNetwork network) - { -#pragma warning disable CS0618 - if (!string.IsNullOrEmpty(DerivationStrategies)) - { - JObject strategies = JObject.Parse(DerivationStrategies); -#pragma warning restore CS0618 - foreach (var strat in strategies.Properties()) - { - if (strat.Name == network.CryptoCode) - { - return BTCPayServer.DerivationStrategy.Parse(strat.Value.Value(), network).DerivationStrategyBase; - } - } - } -#pragma warning disable CS0618 - if (network.IsBTC && !string.IsNullOrEmpty(DerivationStrategy)) - { - return BTCPayServer.DerivationStrategy.Parse(DerivationStrategy, network).DerivationStrategyBase; - } - return null; -#pragma warning restore CS0618 - } - public IEnumerable GetDerivationStrategies(BTCPayNetworkProvider networks) { #pragma warning disable CS0618