mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Support the new LN lib (#5422)
* Support the new LN lib * fix test * do not cache factories * try without useless userinfo in lnd * Remove monero wallet files * support simpler DI too --------- Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Abstractions.Contracts;
|
||||
using BTCPayServer.Client;
|
||||
using BTCPayServer.Client.Models;
|
||||
using BTCPayServer.Configuration;
|
||||
using BTCPayServer.Data;
|
||||
@@ -27,12 +25,10 @@ using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NBitcoin;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PeterO.Cbor;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
using YamlDotNet.Serialization;
|
||||
using LightningAddressData = BTCPayServer.Data.LightningAddressData;
|
||||
using Serializer = NBXplorer.Serializer;
|
||||
|
||||
@@ -50,6 +46,7 @@ namespace BTCPayServer.Hosting
|
||||
private readonly BTCPayNetworkJsonSerializerSettings _btcPayNetworkJsonSerializerSettings;
|
||||
private readonly LightningAddressService _lightningAddressService;
|
||||
private readonly ILogger<MigrationStartupTask> _logger;
|
||||
private readonly LightningClientFactoryService _lightningClientFactoryService;
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
|
||||
public IOptions<LightningNetworkOptions> LightningOptions { get; }
|
||||
@@ -65,7 +62,8 @@ namespace BTCPayServer.Hosting
|
||||
IEnumerable<IPayoutHandler> payoutHandlers,
|
||||
BTCPayNetworkJsonSerializerSettings btcPayNetworkJsonSerializerSettings,
|
||||
LightningAddressService lightningAddressService,
|
||||
ILogger<MigrationStartupTask> logger)
|
||||
ILogger<MigrationStartupTask> logger,
|
||||
LightningClientFactoryService lightningClientFactoryService)
|
||||
{
|
||||
_DBContextFactory = dbContextFactory;
|
||||
_StoreRepository = storeRepository;
|
||||
@@ -76,6 +74,7 @@ namespace BTCPayServer.Hosting
|
||||
_btcPayNetworkJsonSerializerSettings = btcPayNetworkJsonSerializerSettings;
|
||||
_lightningAddressService = lightningAddressService;
|
||||
_logger = logger;
|
||||
_lightningClientFactoryService = lightningClientFactoryService;
|
||||
_userManager = userManager;
|
||||
LightningOptions = lightningOptions;
|
||||
}
|
||||
@@ -1052,15 +1051,20 @@ retry:
|
||||
|
||||
private async Task DeprecatedLightningConnectionStringCheck()
|
||||
{
|
||||
using var ctx = _DBContextFactory.CreateContext();
|
||||
await using var ctx = _DBContextFactory.CreateContext();
|
||||
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
||||
{
|
||||
foreach (var method in store.GetSupportedPaymentMethods(_NetworkProvider).OfType<Payments.Lightning.LightningSupportedPaymentMethod>())
|
||||
foreach (var method in store.GetSupportedPaymentMethods(_NetworkProvider)
|
||||
.OfType<LightningSupportedPaymentMethod>())
|
||||
{
|
||||
var lightning = method.GetExternalLightningUrl();
|
||||
if (lightning?.IsLegacy is true)
|
||||
if (lightning is null)
|
||||
continue;
|
||||
var client = _lightningClientFactoryService.Create(lightning,
|
||||
_NetworkProvider.GetNetwork<BTCPayNetwork>(method.PaymentId.CryptoCode));
|
||||
if (client?.ToString() != lightning)
|
||||
{
|
||||
method.SetLightningUrl(lightning);
|
||||
method.SetLightningUrl(client);
|
||||
store.SetSupportedPaymentMethod(method);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user