mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
Fix warnings
This commit is contained in:
@@ -24,7 +24,9 @@ namespace BTCPayServer.Abstractions.Contracts
|
|||||||
|
|
||||||
class CustomNpgsqlMigrationsSqlGenerator : NpgsqlMigrationsSqlGenerator
|
class CustomNpgsqlMigrationsSqlGenerator : NpgsqlMigrationsSqlGenerator
|
||||||
{
|
{
|
||||||
|
#pragma warning disable EF1001 // Internal EF Core API usage.
|
||||||
public CustomNpgsqlMigrationsSqlGenerator(MigrationsSqlGeneratorDependencies dependencies, Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.INpgsqlOptions opts) : base(dependencies, opts)
|
public CustomNpgsqlMigrationsSqlGenerator(MigrationsSqlGeneratorDependencies dependencies, Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.INpgsqlOptions opts) : base(dependencies, opts)
|
||||||
|
#pragma warning restore EF1001 // Internal EF Core API usage.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,104 +10,59 @@ namespace BTCPayServer.Services.Rates
|
|||||||
{
|
{
|
||||||
internal class HttpClientRequestMaker : IAPIRequestMaker
|
internal class HttpClientRequestMaker : IAPIRequestMaker
|
||||||
{
|
{
|
||||||
class InternalHttpWebRequest : IHttpWebRequest
|
#nullable enable
|
||||||
|
internal class InternalHttpWebRequest : IHttpWebRequest
|
||||||
{
|
{
|
||||||
internal readonly HttpWebRequest Request;
|
internal readonly HttpRequestMessage Request;
|
||||||
|
internal HttpResponseMessage? Response;
|
||||||
|
private string? contentType;
|
||||||
|
|
||||||
public Uri RequestUri => Request.RequestUri;
|
public InternalHttpWebRequest(string method, Uri fullUri)
|
||||||
|
|
||||||
public string Method
|
|
||||||
{
|
{
|
||||||
get
|
Request = new HttpRequestMessage(new HttpMethod(method), fullUri);
|
||||||
{
|
|
||||||
return Request.Method;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Request.Method = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Timeout
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Request.Timeout;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Request.Timeout = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ReadWriteTimeout
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Request.ReadWriteTimeout;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Request.ReadWriteTimeout = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public InternalHttpWebRequest(Uri fullUri)
|
|
||||||
{
|
|
||||||
Request = ((WebRequest.Create(fullUri) as HttpWebRequest) ?? throw new NullReferenceException("Failed to create HttpWebRequest"));
|
|
||||||
Request.KeepAlive = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddHeader(string header, string value)
|
public void AddHeader(string header, string value)
|
||||||
{
|
{
|
||||||
switch (header.ToStringLowerInvariant())
|
switch (header.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
case "content-type":
|
case "content-type":
|
||||||
Request.ContentType = value;
|
contentType = value;
|
||||||
break;
|
|
||||||
case "content-length":
|
|
||||||
Request.ContentLength = value.ConvertInvariant<long>(0L);
|
|
||||||
break;
|
|
||||||
case "user-agent":
|
|
||||||
Request.UserAgent = value;
|
|
||||||
break;
|
|
||||||
case "accept":
|
|
||||||
Request.Accept = value;
|
|
||||||
break;
|
|
||||||
case "connection":
|
|
||||||
Request.Connection = value;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Request.Headers[header] = value;
|
Request.Headers.TryAddWithoutValidation(header, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Uri RequestUri
|
||||||
|
{
|
||||||
|
get { return Request.RequestUri!; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Method
|
||||||
|
{
|
||||||
|
get { return Request.Method.Method; }
|
||||||
|
set { Request.Method = new HttpMethod(value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Timeout { get; set; }
|
||||||
|
|
||||||
|
public int ReadWriteTimeout
|
||||||
|
{
|
||||||
|
get => Timeout;
|
||||||
|
set => Timeout = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Task WriteAllAsync(byte[] data, int index, int length)
|
public Task WriteAllAsync(byte[] data, int index, int length)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
Request.Content = new ByteArrayContent(data, index, length);
|
||||||
}
|
Request.Content.Headers.Add("content-type", contentType);
|
||||||
|
return Task.CompletedTask;
|
||||||
public HttpRequestMessage ToHttpRequestMessage()
|
|
||||||
{
|
|
||||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, Request.RequestUri);
|
|
||||||
CopyHeadersFrom(httpRequest, Request);
|
|
||||||
return httpRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void CopyHeadersFrom(HttpRequestMessage message, HttpWebRequest request)
|
|
||||||
{
|
|
||||||
foreach (string headerName in request.Headers)
|
|
||||||
{
|
|
||||||
string[] headerValues = request.Headers.GetValues(headerName);
|
|
||||||
if (!message.Headers.TryAddWithoutValidation(headerName, headerValues))
|
|
||||||
{
|
|
||||||
if (message.Content != null)
|
|
||||||
message.Content.Headers.TryAddWithoutValidation(headerName, headerValues);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#nullable restore
|
||||||
class InternalHttpWebResponse : IHttpWebResponse
|
class InternalHttpWebResponse : IHttpWebResponse
|
||||||
{
|
{
|
||||||
public InternalHttpWebResponse(HttpResponseMessage httpResponseMessage)
|
public InternalHttpWebResponse(HttpResponseMessage httpResponseMessage)
|
||||||
@@ -164,44 +119,61 @@ namespace BTCPayServer.Services.Rates
|
|||||||
{
|
{
|
||||||
url = "/" + url;
|
url = "/" + url;
|
||||||
}
|
}
|
||||||
string uri2 = (baseUrl ?? api.BaseUrl) + url;
|
|
||||||
if (method == null)
|
// prepare the request
|
||||||
{
|
string fullUrl = (baseUrl ?? api.BaseUrl) + url;
|
||||||
method = api.RequestMethod;
|
method ??= api.RequestMethod;
|
||||||
}
|
Uri uri = api.ProcessRequestUrl(new UriBuilder(fullUrl), payload, method);
|
||||||
Uri uri = api.ProcessRequestUrl(new UriBuilder(uri2), payload, method);
|
InternalHttpWebRequest request = new InternalHttpWebRequest(method, uri);
|
||||||
InternalHttpWebRequest request = new InternalHttpWebRequest(uri)
|
request.AddHeader("accept-language", "en-US,en;q=0.5");
|
||||||
{
|
|
||||||
Method = method
|
|
||||||
};
|
|
||||||
request.AddHeader("content-type", api.RequestContentType);
|
request.AddHeader("content-type", api.RequestContentType);
|
||||||
request.AddHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36");
|
request.AddHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36");
|
||||||
int num3 = request.Timeout = (request.ReadWriteTimeout = (int)api.RequestTimeout.TotalMilliseconds);
|
request.Timeout = (int)api.RequestTimeout.TotalMilliseconds;
|
||||||
await api.ProcessRequestAsync(request, payload);
|
await api.ProcessRequestAsync(request, payload);
|
||||||
|
|
||||||
|
// send the request
|
||||||
|
var response = request.Response;
|
||||||
|
string responseString;
|
||||||
|
using var cancel = new CancellationTokenSource(request.Timeout);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RequestStateChanged?.Invoke(this, RequestMakerState.Begin, uri.AbsoluteUri);
|
RequestStateChanged?.Invoke(this, RequestMakerState.Begin, uri.AbsoluteUri);// when start make a request we send the uri, this helps developers to track the http requests.
|
||||||
using var webHttpRequest = request.ToHttpRequestMessage();
|
response = await _httpClient.SendAsync(request.Request, cancel.Token);
|
||||||
using var webHttpResponse = await _httpClient.SendAsync(webHttpRequest, _cancellationToken);
|
if (response == null)
|
||||||
string text = await webHttpResponse.Content.ReadAsStringAsync();
|
|
||||||
if (!webHttpResponse.IsSuccessStatusCode)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(text))
|
throw new APIException("Unknown response from server");
|
||||||
{
|
|
||||||
throw new APIException($"{webHttpResponse.StatusCode.ConvertInvariant<int>(0)} - {webHttpResponse.StatusCode}");
|
|
||||||
}
|
|
||||||
throw new APIException(text);
|
|
||||||
}
|
}
|
||||||
api.ProcessResponse(new InternalHttpWebResponse(webHttpResponse));
|
responseString = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
RequestStateChanged?.Invoke(this, RequestMakerState.Finished, text);
|
if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.Created)
|
||||||
return text;
|
{
|
||||||
|
// 404 maybe return empty responseString
|
||||||
|
if (string.IsNullOrWhiteSpace(responseString))
|
||||||
|
{
|
||||||
|
throw new APIException(string.Format("{0} - {1}", response.StatusCode.ConvertInvariant<int>(), response.StatusCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new APIException(responseString);
|
||||||
|
}
|
||||||
|
|
||||||
|
api.ProcessResponse(new InternalHttpWebResponse(response));
|
||||||
|
RequestStateChanged?.Invoke(this, RequestMakerState.Finished, responseString);
|
||||||
}
|
}
|
||||||
catch (Exception arg)
|
catch (OperationCanceledException ex) when (cancel.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
RequestStateChanged?.Invoke(this, RequestMakerState.Error, arg);
|
RequestStateChanged?.Invoke(this, RequestMakerState.Error, ex);
|
||||||
|
throw new TimeoutException("APIRequest timeout", ex);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
RequestStateChanged?.Invoke(this, RequestMakerState.Error, ex);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
response?.Dispose();
|
||||||
|
}
|
||||||
|
return responseString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2881,8 +2881,8 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
|
|
||||||
//verify file is available and the same
|
//verify file is available and the same
|
||||||
var net = new System.Net.WebClient();
|
using var net = new HttpClient();
|
||||||
var data = await net.DownloadStringTaskAsync(new Uri(viewFilesViewModel.DirectUrlByFiles[fileId]));
|
var data = await net.GetStringAsync(new Uri(viewFilesViewModel.DirectUrlByFiles[fileId]));
|
||||||
Assert.Equal(fileContent, data);
|
Assert.Equal(fileContent, data);
|
||||||
|
|
||||||
//create a temporary link to file
|
//create a temporary link to file
|
||||||
@@ -2901,7 +2901,7 @@ namespace BTCPayServer.Tests
|
|||||||
.Replace("</a>", string.Empty)
|
.Replace("</a>", string.Empty)
|
||||||
.Replace("target='_blank'>", string.Empty);
|
.Replace("target='_blank'>", string.Empty);
|
||||||
//verify tmpfile is available and the same
|
//verify tmpfile is available and the same
|
||||||
data = await net.DownloadStringTaskAsync(new Uri(url));
|
data = await net.GetStringAsync(new Uri(url));
|
||||||
Assert.Equal(fileContent, data);
|
Assert.Equal(fileContent, data);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@@ -134,12 +135,12 @@ namespace BTCPayServer.Configuration
|
|||||||
builder.AppendLine("### NBXplorer settings ###");
|
builder.AppendLine("### NBXplorer settings ###");
|
||||||
foreach (var n in new BTCPayNetworkProvider(networkType).GetAll().OfType<BTCPayNetwork>())
|
foreach (var n in new BTCPayNetworkProvider(networkType).GetAll().OfType<BTCPayNetwork>())
|
||||||
{
|
{
|
||||||
builder.AppendLine($"#{n.CryptoCode}.explorer.url={n.NBXplorerNetwork.DefaultSettings.DefaultUrl}");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"#{n.CryptoCode}.explorer.url={n.NBXplorerNetwork.DefaultSettings.DefaultUrl}");
|
||||||
builder.AppendLine($"#{n.CryptoCode}.explorer.cookiefile={ n.NBXplorerNetwork.DefaultSettings.DefaultCookieFile}");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"#{n.CryptoCode}.explorer.cookiefile={ n.NBXplorerNetwork.DefaultSettings.DefaultCookieFile}");
|
||||||
if (n.SupportLightning)
|
if (n.SupportLightning)
|
||||||
{
|
{
|
||||||
builder.AppendLine($"#{n.CryptoCode}.lightning=/root/.lightning/lightning-rpc");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"#{n.CryptoCode}.lightning=/root/.lightning/lightning-rpc");
|
||||||
builder.AppendLine($"#{n.CryptoCode}.lightning=https://apitoken:API_TOKEN_SECRET@charge.example.com/");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"#{n.CryptoCode}.lightning=https://apitoken:API_TOKEN_SECRET@charge.example.com/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
@@ -129,7 +130,7 @@ namespace BTCPayServer.Controllers
|
|||||||
if (settings.ShowCustomAmount)
|
if (settings.ShowCustomAmount)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.AppendLine($"<form method=\"POST\" action=\"{encoder.Encode(appUrl)}\">");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"<form method=\"POST\" action=\"{encoder.Encode(appUrl)}\">");
|
||||||
builder.AppendLine($" <input type=\"hidden\" name=\"amount\" value=\"100\" />");
|
builder.AppendLine($" <input type=\"hidden\" name=\"amount\" value=\"100\" />");
|
||||||
builder.AppendLine($" <input type=\"hidden\" name=\"email\" value=\"customer@example.com\" />");
|
builder.AppendLine($" <input type=\"hidden\" name=\"email\" value=\"customer@example.com\" />");
|
||||||
builder.AppendLine($" <input type=\"hidden\" name=\"orderId\" value=\"CustomOrderId\" />");
|
builder.AppendLine($" <input type=\"hidden\" name=\"orderId\" value=\"CustomOrderId\" />");
|
||||||
@@ -143,12 +144,12 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
var items = _appService.Parse(settings.Template, settings.Currency);
|
var items = _appService.Parse(settings.Template, settings.Currency);
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
builder.AppendLine($"<form method=\"POST\" action=\"{encoder.Encode(appUrl)}\">");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"<form method=\"POST\" action=\"{encoder.Encode(appUrl)}\">");
|
||||||
builder.AppendLine($" <input type=\"hidden\" name=\"email\" value=\"customer@example.com\" />");
|
builder.AppendLine($" <input type=\"hidden\" name=\"email\" value=\"customer@example.com\" />");
|
||||||
builder.AppendLine($" <input type=\"hidden\" name=\"orderId\" value=\"CustomOrderId\" />");
|
builder.AppendLine($" <input type=\"hidden\" name=\"orderId\" value=\"CustomOrderId\" />");
|
||||||
builder.AppendLine($" <input type=\"hidden\" name=\"notificationUrl\" value=\"https://example.com/callbacks\" />");
|
builder.AppendLine($" <input type=\"hidden\" name=\"notificationUrl\" value=\"https://example.com/callbacks\" />");
|
||||||
builder.AppendLine($" <input type=\"hidden\" name=\"redirectUrl\" value=\"https://example.com/thanksyou\" />");
|
builder.AppendLine($" <input type=\"hidden\" name=\"redirectUrl\" value=\"https://example.com/thanksyou\" />");
|
||||||
builder.AppendLine($" <button type=\"submit\" name=\"choiceKey\" value=\"{items[0].Id}\">Buy now</button>");
|
builder.AppendLine(CultureInfo.InvariantCulture, $" <button type=\"submit\" name=\"choiceKey\" value=\"{items[0].Id}\">Buy now</button>");
|
||||||
builder.AppendLine($"</form>");
|
builder.AppendLine($"</form>");
|
||||||
vm.Example2 = builder.ToString();
|
vm.Example2 = builder.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -732,9 +732,9 @@ namespace BTCPayServer.Controllers.GreenField
|
|||||||
return GetFromActionResult(await _storesController.GetStores());
|
return GetFromActionResult(await _storesController.GetStores());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<StoreData> GetStore(string storeId, CancellationToken token = default)
|
public override Task<StoreData> GetStore(string storeId, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
return GetFromActionResult<StoreData>(_storesController.GetStore(storeId));
|
return Task.FromResult(GetFromActionResult<StoreData>(_storesController.GetStore(storeId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task RemoveStore(string storeId, CancellationToken token = default)
|
public override async Task RemoveStore(string storeId, CancellationToken token = default)
|
||||||
|
|||||||
@@ -538,7 +538,8 @@ namespace BTCPayServer.Controllers.GreenField
|
|||||||
derivationScheme = GetDerivationSchemeSettings(cryptoCode);
|
derivationScheme = GetDerivationSchemeSettings(cryptoCode);
|
||||||
if (derivationScheme?.AccountDerivation is null)
|
if (derivationScheme?.AccountDerivation is null)
|
||||||
{
|
{
|
||||||
actionResult = NotFound();
|
actionResult = this.CreateAPIError("not-available",
|
||||||
|
$"{cryptoCode} doesn't have any derivation scheme set");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,7 +547,7 @@ namespace BTCPayServer.Controllers.GreenField
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DerivationSchemeSettings GetDerivationSchemeSettings(string cryptoCode)
|
private DerivationSchemeSettings? GetDerivationSchemeSettings(string cryptoCode)
|
||||||
{
|
{
|
||||||
var paymentMethod = Store
|
var paymentMethod = Store
|
||||||
.GetSupportedPaymentMethods(_btcPayNetworkProvider)
|
.GetSupportedPaymentMethods(_btcPayNetworkProvider)
|
||||||
|
|||||||
@@ -91,11 +91,12 @@ namespace BTCPayServer.Controllers.GreenField
|
|||||||
}
|
}
|
||||||
if (request.Password is null)
|
if (request.Password is null)
|
||||||
ModelState.AddModelError(nameof(request.Password), "Password is missing");
|
ModelState.AddModelError(nameof(request.Password), "Password is missing");
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
return this.CreateValidationError(ModelState);
|
return this.CreateValidationError(ModelState);
|
||||||
}
|
}
|
||||||
|
if (User.Identity is null)
|
||||||
|
throw new JsonHttpException(this.StatusCode(401));
|
||||||
var anyAdmin = (await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin)).Any();
|
var anyAdmin = (await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin)).Any();
|
||||||
var policies = await _settingsRepository.GetSettingAsync<PoliciesSettings>() ?? new PoliciesSettings();
|
var policies = await _settingsRepository.GetSettingAsync<PoliciesSettings>() ?? new PoliciesSettings();
|
||||||
var isAuth = User.Identity.AuthenticationType == GreenFieldConstants.AuthenticationType;
|
var isAuth = User.Identity.AuthenticationType == GreenFieldConstants.AuthenticationType;
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ namespace BTCPayServer.Controllers
|
|||||||
Html = "Refund successfully created!<br />Share the link to this page with a customer.<br />The customer needs to enter their address and claim the refund.<br />Once a customer claims the refund, you will get a notification and would need to approve and initiate it from your Store > Payouts.",
|
Html = "Refund successfully created!<br />Share the link to this page with a customer.<br />The customer needs to enter their address and claim the refund.<br />Once a customer claims the refund, you will get a notification and would need to approve and initiate it from your Store > Payouts.",
|
||||||
Severity = StatusMessageModel.StatusSeverity.Success
|
Severity = StatusMessageModel.StatusSeverity.Success
|
||||||
});
|
});
|
||||||
(await ctx.Invoices.FindAsync(new[] { invoice.Id }, cancellationToken)).CurrentRefundId = ppId;
|
(await ctx.Invoices.FindAsync(new[] { invoice.Id }, cancellationToken))!.CurrentRefundId = ppId;
|
||||||
ctx.Refunds.Add(new RefundData()
|
ctx.Refunds.Add(new RefundData()
|
||||||
{
|
{
|
||||||
InvoiceDataId = invoice.Id,
|
InvoiceDataId = invoice.Id,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -159,7 +160,7 @@ namespace BTCPayServer.Controllers
|
|||||||
if (!first)
|
if (!first)
|
||||||
currencyPairsBuilder.Append(',');
|
currencyPairsBuilder.Append(',');
|
||||||
first = false;
|
first = false;
|
||||||
currencyPairsBuilder.Append($"{baseCrypto}_{currencyCode}");
|
currencyPairsBuilder.Append(CultureInfo.InvariantCulture, $"{baseCrypto}_{currencyCode}");
|
||||||
}
|
}
|
||||||
return currencyPairsBuilder.ToString();
|
return currencyPairsBuilder.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using BTCPayServer.Client.JsonConverters;
|
using BTCPayServer.Client.JsonConverters;
|
||||||
@@ -144,7 +145,7 @@ namespace BTCPayServer.Data
|
|||||||
{
|
{
|
||||||
if (network.DefaultRateRules.Length != 0)
|
if (network.DefaultRateRules.Length != 0)
|
||||||
{
|
{
|
||||||
builder.AppendLine($"// Default rate rules for {network.CryptoCode}");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"// Default rate rules for {network.CryptoCode}");
|
||||||
foreach (var line in network.DefaultRateRules)
|
foreach (var line in network.DefaultRateRules)
|
||||||
{
|
{
|
||||||
builder.AppendLine(line);
|
builder.AppendLine(line);
|
||||||
@@ -155,7 +156,7 @@ namespace BTCPayServer.Data
|
|||||||
}
|
}
|
||||||
|
|
||||||
var preferredExchange = string.IsNullOrEmpty(PreferredExchange) ? CoinGeckoRateProvider.CoinGeckoName : PreferredExchange;
|
var preferredExchange = string.IsNullOrEmpty(PreferredExchange) ? CoinGeckoRateProvider.CoinGeckoName : PreferredExchange;
|
||||||
builder.AppendLine($"X_X = {preferredExchange}(X_X);");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"X_X = {preferredExchange}(X_X);");
|
||||||
|
|
||||||
BTCPayServer.Rating.RateRules.TryParse(builder.ToString(), out var rules);
|
BTCPayServer.Rating.RateRules.TryParse(builder.ToString(), out var rules);
|
||||||
rules.Spread = Spread;
|
rules.Spread = Spread;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace BTCPayServer
|
|||||||
builder.Append(expiration.Days.ToString(CultureInfo.InvariantCulture));
|
builder.Append(expiration.Days.ToString(CultureInfo.InvariantCulture));
|
||||||
if (expiration.Hours >= 1)
|
if (expiration.Hours >= 1)
|
||||||
builder.Append(expiration.Hours.ToString("00", CultureInfo.InvariantCulture));
|
builder.Append(expiration.Hours.ToString("00", CultureInfo.InvariantCulture));
|
||||||
builder.Append($"{expiration.Minutes.ToString("00", CultureInfo.InvariantCulture)}:{expiration.Seconds.ToString("00", CultureInfo.InvariantCulture)}");
|
builder.Append(CultureInfo.InvariantCulture, $"{expiration.Minutes.ToString("00", CultureInfo.InvariantCulture)}:{expiration.Seconds.ToString("00", CultureInfo.InvariantCulture)}");
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
public static decimal RoundUp(decimal value, int precision)
|
public static decimal RoundUp(decimal value, int precision)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -161,7 +162,7 @@ namespace BTCPayServer.HostedServices
|
|||||||
var result = new StringBuilder();
|
var result = new StringBuilder();
|
||||||
foreach (var transactionLabel in TransactionLabels)
|
foreach (var transactionLabel in TransactionLabels)
|
||||||
{
|
{
|
||||||
result.AppendLine(
|
result.AppendLine(CultureInfo.InvariantCulture,
|
||||||
$"Adding {transactionLabel.Value.Count} labels to {transactionLabel.Key} in wallet {WalletId}");
|
$"Adding {transactionLabel.Value.Count} labels to {transactionLabel.Key} in wallet {WalletId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,10 @@ namespace BTCPayServer.Plugins
|
|||||||
}
|
}
|
||||||
var filedest = Path.Join(dest, ext.Name);
|
var filedest = Path.Join(dest, ext.Name);
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(filedest));
|
Directory.CreateDirectory(Path.GetDirectoryName(filedest));
|
||||||
new WebClient().DownloadFile(new Uri(ext.DownloadUrl), filedest);
|
using var resp2 = await _githubClient.GetAsync(ext.DownloadUrl);
|
||||||
|
using var fs = new FileStream(filedest, FileMode.Create, FileAccess.ReadWrite);
|
||||||
|
await resp2.Content.CopyToAsync(fs);
|
||||||
|
await fs.FlushAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InstallPlugin(string plugin)
|
public void InstallPlugin(string plugin)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -82,12 +83,12 @@ namespace BTCPayServer.Services
|
|||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
StringBuilder txt = new StringBuilder();
|
StringBuilder txt = new StringBuilder();
|
||||||
txt.Append($"@Copyright BTCPayServer v{Version}");
|
txt.Append(CultureInfo.InvariantCulture, $"@Copyright BTCPayServer v{Version}");
|
||||||
if (AltcoinsVersion)
|
if (AltcoinsVersion)
|
||||||
txt.Append($" (altcoins)");
|
txt.Append($" (altcoins)");
|
||||||
if (!Environment.IsProduction() || !Build.Equals("Release", StringComparison.OrdinalIgnoreCase))
|
if (!Environment.IsProduction() || !Build.Equals("Release", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
txt.Append($" Environment: {Environment.EnvironmentName} Build: {Build}");
|
txt.Append(CultureInfo.InvariantCulture, $" Environment: {Environment.EnvironmentName} Build: {Build}");
|
||||||
}
|
}
|
||||||
return txt.ToString();
|
return txt.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user