remove unused code, remove derivationscheme specific logic from InvoiceEntity

This commit is contained in:
nicolas.dorier 2018-02-19 22:41:47 +09:00
parent a6b92a0dd5
commit b4f4401cdc
3 changed files with 9 additions and 26 deletions

View file

@ -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);

View file

@ -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<InvoiceEntity> ReceivedPayment(BTCPayWallet wallet, string invoiceId, PaymentEntity payment, DerivationStrategyBase strategy)
{
var paymentData = (BitcoinLikePaymentData)payment.GetCryptoPaymentData();

View file

@ -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<string>(), 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<DerivationStrategy> GetDerivationStrategies(BTCPayNetworkProvider networks)
{
#pragma warning disable CS0618