mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 22:11:48 +01:00
Prepare BTCPayServer for .netcore 3.0
This commit is contained in:
parent
275fbc81e7
commit
4d84343a80
9 changed files with 61 additions and 23 deletions
|
@ -60,7 +60,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.9" />
|
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.9" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
|
||||||
<PackageReference Include="TwentyTwenty.Storage" Version="2.11.2" />
|
<PackageReference Include="TwentyTwenty.Storage" Version="2.11.2" />
|
||||||
<PackageReference Include="TwentyTwenty.Storage.Amazon" Version="2.11.2" />
|
<PackageReference Include="TwentyTwenty.Storage.Amazon" Version="2.11.2" />
|
||||||
<PackageReference Include="TwentyTwenty.Storage.Azure" Version="2.11.2" />
|
<PackageReference Include="TwentyTwenty.Storage.Azure" Version="2.11.2" />
|
||||||
|
@ -70,6 +70,10 @@
|
||||||
<PackageReference Include="YamlDotNet" Version="5.2.1" />
|
<PackageReference Include="YamlDotNet" Version="5.2.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1'">
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
|
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -20,6 +20,9 @@ using System.Globalization;
|
||||||
using BTCPayServer.Security;
|
using BTCPayServer.Security;
|
||||||
using BTCPayServer.U2F;
|
using BTCPayServer.U2F;
|
||||||
using BTCPayServer.Data;
|
using BTCPayServer.Data;
|
||||||
|
#if NETCOREAPP21
|
||||||
|
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace BTCPayServer.Controllers
|
namespace BTCPayServer.Controllers
|
||||||
{
|
{
|
||||||
|
@ -33,7 +36,7 @@ namespace BTCPayServer.Controllers
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly UrlEncoder _urlEncoder;
|
private readonly UrlEncoder _urlEncoder;
|
||||||
TokenRepository _TokenRepository;
|
TokenRepository _TokenRepository;
|
||||||
IHostingEnvironment _Env;
|
IWebHostEnvironment _Env;
|
||||||
private readonly U2FService _u2FService;
|
private readonly U2FService _u2FService;
|
||||||
private readonly BTCPayServerEnvironment _btcPayServerEnvironment;
|
private readonly BTCPayServerEnvironment _btcPayServerEnvironment;
|
||||||
StoreRepository _StoreRepository;
|
StoreRepository _StoreRepository;
|
||||||
|
@ -49,7 +52,7 @@ namespace BTCPayServer.Controllers
|
||||||
TokenRepository tokenRepository,
|
TokenRepository tokenRepository,
|
||||||
BTCPayWalletProvider walletProvider,
|
BTCPayWalletProvider walletProvider,
|
||||||
StoreRepository storeRepository,
|
StoreRepository storeRepository,
|
||||||
IHostingEnvironment env,
|
IWebHostEnvironment env,
|
||||||
U2FService u2FService,
|
U2FService u2FService,
|
||||||
BTCPayServerEnvironment btcPayServerEnvironment)
|
BTCPayServerEnvironment btcPayServerEnvironment)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,10 @@ using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using NBitcoin;
|
using NBitcoin;
|
||||||
using NBitcoin.DataEncoders;
|
using NBitcoin.DataEncoders;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
#if NETCOREAPP21
|
||||||
|
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace BTCPayServer.Controllers
|
namespace BTCPayServer.Controllers
|
||||||
{
|
{
|
||||||
|
@ -57,8 +61,7 @@ namespace BTCPayServer.Controllers
|
||||||
IFeeProviderFactory feeRateProvider,
|
IFeeProviderFactory feeRateProvider,
|
||||||
LanguageService langService,
|
LanguageService langService,
|
||||||
ChangellyClientProvider changellyClientProvider,
|
ChangellyClientProvider changellyClientProvider,
|
||||||
IOptions<MvcJsonOptions> mvcJsonOptions,
|
IWebHostEnvironment env, IHttpClientFactory httpClientFactory,
|
||||||
IHostingEnvironment env, IHttpClientFactory httpClientFactory,
|
|
||||||
PaymentMethodHandlerDictionary paymentMethodHandlerDictionary,
|
PaymentMethodHandlerDictionary paymentMethodHandlerDictionary,
|
||||||
CssThemeManager cssThemeManager)
|
CssThemeManager cssThemeManager)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +71,6 @@ namespace BTCPayServer.Controllers
|
||||||
_UserManager = userManager;
|
_UserManager = userManager;
|
||||||
_LangService = langService;
|
_LangService = langService;
|
||||||
_changellyClientProvider = changellyClientProvider;
|
_changellyClientProvider = changellyClientProvider;
|
||||||
MvcJsonOptions = mvcJsonOptions;
|
|
||||||
_TokenController = tokenController;
|
_TokenController = tokenController;
|
||||||
_WalletProvider = walletProvider;
|
_WalletProvider = walletProvider;
|
||||||
_Env = env;
|
_Env = env;
|
||||||
|
@ -95,7 +97,7 @@ namespace BTCPayServer.Controllers
|
||||||
UserManager<ApplicationUser> _UserManager;
|
UserManager<ApplicationUser> _UserManager;
|
||||||
private LanguageService _LangService;
|
private LanguageService _LangService;
|
||||||
private readonly ChangellyClientProvider _changellyClientProvider;
|
private readonly ChangellyClientProvider _changellyClientProvider;
|
||||||
IHostingEnvironment _Env;
|
IWebHostEnvironment _Env;
|
||||||
private IHttpClientFactory _httpClientFactory;
|
private IHttpClientFactory _httpClientFactory;
|
||||||
private readonly PaymentMethodHandlerDictionary _paymentMethodHandlerDictionary;
|
private readonly PaymentMethodHandlerDictionary _paymentMethodHandlerDictionary;
|
||||||
private readonly CssThemeManager _CssThemeManager;
|
private readonly CssThemeManager _CssThemeManager;
|
||||||
|
@ -731,7 +733,6 @@ namespace BTCPayServer.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GeneratedPairingCode { get; set; }
|
public string GeneratedPairingCode { get; set; }
|
||||||
public IOptions<MvcJsonOptions> MvcJsonOptions { get; }
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("/api-tokens")]
|
[Route("/api-tokens")]
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace BTCPayServer.Controllers
|
||||||
public ExplorerClientProvider ExplorerClientProvider { get; }
|
public ExplorerClientProvider ExplorerClientProvider { get; }
|
||||||
|
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
private readonly IOptions<MvcJsonOptions> _mvcJsonOptions;
|
private readonly JsonSerializerSettings _serializerSettings;
|
||||||
private readonly NBXplorerDashboard _dashboard;
|
private readonly NBXplorerDashboard _dashboard;
|
||||||
|
|
||||||
private readonly IFeeProviderFactory _feeRateProvider;
|
private readonly IFeeProviderFactory _feeRateProvider;
|
||||||
|
@ -59,7 +59,7 @@ namespace BTCPayServer.Controllers
|
||||||
CurrencyNameTable currencyTable,
|
CurrencyNameTable currencyTable,
|
||||||
BTCPayNetworkProvider networkProvider,
|
BTCPayNetworkProvider networkProvider,
|
||||||
UserManager<ApplicationUser> userManager,
|
UserManager<ApplicationUser> userManager,
|
||||||
IOptions<MvcJsonOptions> mvcJsonOptions,
|
MvcNewtonsoftJsonOptions mvcJsonOptions,
|
||||||
NBXplorerDashboard dashboard,
|
NBXplorerDashboard dashboard,
|
||||||
RateFetcher rateProvider,
|
RateFetcher rateProvider,
|
||||||
ExplorerClientProvider explorerProvider,
|
ExplorerClientProvider explorerProvider,
|
||||||
|
@ -72,7 +72,7 @@ namespace BTCPayServer.Controllers
|
||||||
RateFetcher = rateProvider;
|
RateFetcher = rateProvider;
|
||||||
NetworkProvider = networkProvider;
|
NetworkProvider = networkProvider;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_mvcJsonOptions = mvcJsonOptions;
|
_serializerSettings = mvcJsonOptions.SerializerSettings;
|
||||||
_dashboard = dashboard;
|
_dashboard = dashboard;
|
||||||
ExplorerClientProvider = explorerProvider;
|
ExplorerClientProvider = explorerProvider;
|
||||||
_feeRateProvider = feeRateProvider;
|
_feeRateProvider = feeRateProvider;
|
||||||
|
@ -795,7 +795,7 @@ namespace BTCPayServer.Controllers
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
UTF8Encoding UTF8NOBOM = new UTF8Encoding(false);
|
UTF8Encoding UTF8NOBOM = new UTF8Encoding(false);
|
||||||
var bytes = UTF8NOBOM.GetBytes(JsonConvert.SerializeObject(result, _mvcJsonOptions.Value.SerializerSettings));
|
var bytes = UTF8NOBOM.GetBytes(JsonConvert.SerializeObject(result, _serializerSettings));
|
||||||
await webSocket.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Text, true, new CancellationTokenSource(2000).Token);
|
await webSocket.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Text, true, new CancellationTokenSource(2000).Token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,12 @@ namespace BTCPayServer.Hosting
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddBTCPayServer(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddBTCPayServer(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
#if NETCOREAPP21
|
||||||
|
services.AddSingleton<IConfigureOptions<MvcJsonOptions>, MVCConfigureOptions>();
|
||||||
|
services.AddSingleton<MvcNewtonsoftJsonOptions>();
|
||||||
|
#else
|
||||||
|
services.AddSingleton<MvcNewtonsoftJsonOptions>(o => o.GetRequiredService<IOptions<MvcNewtonsoftJsonOptions>>().Value);
|
||||||
|
#endif
|
||||||
services.AddDbContext<ApplicationDbContext>((provider, o) =>
|
services.AddDbContext<ApplicationDbContext>((provider, o) =>
|
||||||
{
|
{
|
||||||
var factory = provider.GetRequiredService<ApplicationDbContextFactory>();
|
var factory = provider.GetRequiredService<ApplicationDbContextFactory>();
|
||||||
|
@ -329,5 +335,13 @@ namespace BTCPayServer.Hosting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if NETCOREAPP21
|
||||||
|
class MVCConfigureOptions : IConfigureOptions<MvcJsonOptions>
|
||||||
|
{
|
||||||
|
public void Configure(MvcJsonOptions options)
|
||||||
|
{
|
||||||
|
new Serializer(null).ConfigureSerializer(options.SerializerSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,12 @@ using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BundlerMinifier.TagHelpers;
|
using BundlerMinifier.TagHelpers;
|
||||||
|
#if NETCOREAPP21
|
||||||
|
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||||
|
#else
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
#endif
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace BTCPayServer.Hosting
|
namespace BTCPayServer.Hosting
|
||||||
|
@ -15,7 +20,7 @@ namespace BTCPayServer.Hosting
|
||||||
{
|
{
|
||||||
BundleProvider _InnerProvider;
|
BundleProvider _InnerProvider;
|
||||||
Lazy<Dictionary<string, Bundle>> _BundlesByName;
|
Lazy<Dictionary<string, Bundle>> _BundlesByName;
|
||||||
public ResourceBundleProvider(IHostingEnvironment hosting, BundleOptions options)
|
public ResourceBundleProvider(IWebHostEnvironment hosting, BundleOptions options)
|
||||||
{
|
{
|
||||||
if (options.UseBundles)
|
if (options.UseBundles)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
#if NETCOREAPP21
|
||||||
|
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||||
|
#endif
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
@ -31,13 +34,13 @@ namespace BTCPayServer.Hosting
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IConfiguration conf, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
public Startup(IConfiguration conf, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
Configuration = conf;
|
Configuration = conf;
|
||||||
_Env = env;
|
_Env = env;
|
||||||
LoggerFactory = loggerFactory;
|
LoggerFactory = loggerFactory;
|
||||||
}
|
}
|
||||||
IHostingEnvironment _Env;
|
IWebHostEnvironment _Env;
|
||||||
public IConfiguration Configuration
|
public IConfiguration Configuration
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
|
@ -199,7 +202,7 @@ namespace BTCPayServer.Hosting
|
||||||
|
|
||||||
public void Configure(
|
public void Configure(
|
||||||
IApplicationBuilder app,
|
IApplicationBuilder app,
|
||||||
IHostingEnvironment env,
|
IWebHostEnvironment env,
|
||||||
IServiceProvider prov,
|
IServiceProvider prov,
|
||||||
BTCPayServerOptions options,
|
BTCPayServerOptions options,
|
||||||
ILoggerFactory loggerFactory)
|
ILoggerFactory loggerFactory)
|
||||||
|
@ -218,7 +221,7 @@ namespace BTCPayServer.Hosting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureCore(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider prov, ILoggerFactory loggerFactory, BTCPayServerOptions options)
|
private static void ConfigureCore(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider prov, ILoggerFactory loggerFactory, BTCPayServerOptions options)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -8,6 +7,10 @@ using System.Text;
|
||||||
using NBXplorer;
|
using NBXplorer;
|
||||||
using NBitcoin;
|
using NBitcoin;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
#if NETCOREAPP21
|
||||||
|
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace BTCPayServer.Services
|
namespace BTCPayServer.Services
|
||||||
{
|
{
|
||||||
|
@ -15,7 +18,7 @@ namespace BTCPayServer.Services
|
||||||
{
|
{
|
||||||
IHttpContextAccessor httpContext;
|
IHttpContextAccessor httpContext;
|
||||||
TorServices torServices;
|
TorServices torServices;
|
||||||
public BTCPayServerEnvironment(IHostingEnvironment env, BTCPayNetworkProvider provider, IHttpContextAccessor httpContext, TorServices torServices)
|
public BTCPayServerEnvironment(IWebHostEnvironment env, BTCPayNetworkProvider provider, IHttpContextAccessor httpContext, TorServices torServices)
|
||||||
{
|
{
|
||||||
this.httpContext = httpContext;
|
this.httpContext = httpContext;
|
||||||
Version = typeof(BTCPayServerEnvironment).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
|
Version = typeof(BTCPayServerEnvironment).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
|
||||||
|
@ -28,7 +31,7 @@ namespace BTCPayServer.Services
|
||||||
NetworkType = provider.NetworkType;
|
NetworkType = provider.NetworkType;
|
||||||
this.torServices = torServices;
|
this.torServices = torServices;
|
||||||
}
|
}
|
||||||
public IHostingEnvironment Environment
|
public IWebHostEnvironment Environment
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,11 @@ using Microsoft.Extensions.Hosting;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
|
#if NETCOREAPP21
|
||||||
|
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||||
|
#else
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace BTCPayServer.Services
|
namespace BTCPayServer.Services
|
||||||
{
|
{
|
||||||
|
@ -27,7 +32,7 @@ namespace BTCPayServer.Services
|
||||||
{
|
{
|
||||||
private readonly Language[] _languages;
|
private readonly Language[] _languages;
|
||||||
|
|
||||||
public LanguageService(IHostingEnvironment environment)
|
public LanguageService(IWebHostEnvironment environment)
|
||||||
{
|
{
|
||||||
var path = (environment as HostingEnvironment)?.WebRootPath;
|
var path = (environment as HostingEnvironment)?.WebRootPath;
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
|
|
Loading…
Add table
Reference in a new issue