Dotnet reformat

This commit is contained in:
nicolas.dorier
2023-04-10 11:07:03 +09:00
parent f598c70a4f
commit 7546ef7a8e
110 changed files with 518 additions and 486 deletions

View File

@@ -1,8 +1,8 @@
using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System;
using Newtonsoft.Json;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using Newtonsoft.Json;
namespace BTCPayServer.Client.Models; namespace BTCPayServer.Client.Models;

View File

@@ -1,4 +1,4 @@
using System; using System;
using BTCPayServer.Data; using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;

View File

@@ -302,7 +302,8 @@ namespace BTCPayServer.Tests
{ {
await client.GetApp("some random ID lol"); await client.GetApp("some random ID lol");
}); });
await AssertHttpError(404, async () => { await AssertHttpError(404, async () =>
{
await client.GetPosApp("some random ID lol"); await client.GetPosApp("some random ID lol");
}); });
@@ -462,10 +463,12 @@ namespace BTCPayServer.Tests
Assert.Equal("Crowdfund", app.AppType); Assert.Equal("Crowdfund", app.AppType);
// Make sure we return a 404 if we try to get an app that doesn't exist // Make sure we return a 404 if we try to get an app that doesn't exist
await AssertHttpError(404, async () => { await AssertHttpError(404, async () =>
{
await client.GetApp("some random ID lol"); await client.GetApp("some random ID lol");
}); });
await AssertHttpError(404, async () => { await AssertHttpError(404, async () =>
{
await client.GetCrowdfundApp("some random ID lol"); await client.GetCrowdfundApp("some random ID lol");
}); });
@@ -488,7 +491,8 @@ namespace BTCPayServer.Tests
// Test deleting the newly created app // Test deleting the newly created app
await client.DeleteApp(retrievedApp.Id); await client.DeleteApp(retrievedApp.Id);
await AssertHttpError(404, async () => { await AssertHttpError(404, async () =>
{
await client.GetApp(retrievedApp.Id); await client.GetApp(retrievedApp.Id);
}); });
} }
@@ -1256,7 +1260,10 @@ namespace BTCPayServer.Tests
//update store //update store
Assert.Empty(newStore.PaymentMethodCriteria); Assert.Empty(newStore.PaymentMethodCriteria);
await client.GenerateOnChainWallet(newStore.Id, "BTC", new GenerateOnChainWalletRequest()); await client.GenerateOnChainWallet(newStore.Id, "BTC", new GenerateOnChainWalletRequest());
var updatedStore = await client.UpdateStore(newStore.Id, new UpdateStoreRequest() { Name = "B", PaymentMethodCriteria = new List<PaymentMethodCriteriaData>() var updatedStore = await client.UpdateStore(newStore.Id, new UpdateStoreRequest()
{
Name = "B",
PaymentMethodCriteria = new List<PaymentMethodCriteriaData>()
{ {
new() new()
{ {
@@ -1265,7 +1272,8 @@ namespace BTCPayServer.Tests
PaymentMethod = "BTC", PaymentMethod = "BTC",
CurrencyCode = "USD" CurrencyCode = "USD"
} }
}}); }
});
Assert.Equal("B", updatedStore.Name); Assert.Equal("B", updatedStore.Name);
var s = (await client.GetStore(newStore.Id)); var s = (await client.GetStore(newStore.Id));
Assert.Equal("B", s.Name); Assert.Equal("B", s.Name);

View File

@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Http;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace BTCPayServer namespace BTCPayServer
{ {

View File

@@ -11,8 +11,8 @@ using BTCPayServer.Security;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using StoreData = BTCPayServer.Data.StoreData;
using PayoutProcessorData = BTCPayServer.Client.Models.PayoutProcessorData; using PayoutProcessorData = BTCPayServer.Client.Models.PayoutProcessorData;
using StoreData = BTCPayServer.Data.StoreData;
namespace BTCPayServer.Controllers.Greenfield namespace BTCPayServer.Controllers.Greenfield
{ {

View File

@@ -264,7 +264,8 @@ namespace BTCPayServer.Controllers.Greenfield
pullPaymentId = pullPaymentId pullPaymentId = pullPaymentId
}, Request.Scheme, Request.Host.ToString())!); }, Request.Scheme, Request.Host.ToString())!);
return base.Ok(new PullPaymentLNURL() { return base.Ok(new PullPaymentLNURL()
{
LNURLBech32 = LNURL.LNURL.EncodeUri(lnurlEndpoint, "withdrawRequest", true).ToString(), LNURLBech32 = LNURL.LNURL.EncodeUri(lnurlEndpoint, "withdrawRequest", true).ToString(),
LNURLUri = LNURL.LNURL.EncodeUri(lnurlEndpoint, "withdrawRequest", false).ToString() LNURLUri = LNURL.LNURL.EncodeUri(lnurlEndpoint, "withdrawRequest", false).ToString()
}); });

View File

@@ -33,7 +33,10 @@ namespace BTCPayServer.Controllers.Greenfield
return new LightningAddressData(); return new LightningAddressData();
return new LightningAddressData() return new LightningAddressData()
{ {
Username = data.Username, Max = blob.Max, Min = blob.Min, CurrencyCode = blob.CurrencyCode Username = data.Username,
Max = blob.Max,
Min = blob.Min,
CurrencyCode = blob.CurrencyCode
}; };
} }
@@ -64,7 +67,8 @@ namespace BTCPayServer.Controllers.Greenfield
{ {
var res = await _lightningAddressService.Get(new LightningAddressQuery() var res = await _lightningAddressService.Get(new LightningAddressQuery()
{ {
Usernames = new[] {username}, StoreIds = new[] {storeId}, Usernames = new[] { username },
StoreIds = new[] { storeId },
}); });
return res?.Any() is true ? Ok(ToModel(res.First())) : this.CreateAPIError(404, "lightning-address-not-found", "The lightning address was not present."); return res?.Any() is true ? Ok(ToModel(res.First())) : this.CreateAPIError(404, "lightning-address-not-found", "The lightning address was not present.");
} }

View File

@@ -249,7 +249,8 @@ namespace BTCPayServer.Controllers.Greenfield
if (string.IsNullOrEmpty(pmc.CurrencyCode)) if (string.IsNullOrEmpty(pmc.CurrencyCode))
{ {
request.AddModelError(data => data.PaymentMethodCriteria[index].CurrencyCode, "CurrencyCode is required", this); request.AddModelError(data => data.PaymentMethodCriteria[index].CurrencyCode, "CurrencyCode is required", this);
}else if (CurrencyNameTable.Instance.GetCurrencyData(pmc.CurrencyCode, false) is null) }
else if (CurrencyNameTable.Instance.GetCurrencyData(pmc.CurrencyCode, false) is null)
{ {
request.AddModelError(data => data.PaymentMethodCriteria[index].CurrencyCode, "CurrencyCode is invalid", this); request.AddModelError(data => data.PaymentMethodCriteria[index].CurrencyCode, "CurrencyCode is invalid", this);
} }

View File

@@ -30,11 +30,11 @@ using LightningAddressData = BTCPayServer.Client.Models.LightningAddressData;
using NotificationData = BTCPayServer.Client.Models.NotificationData; using NotificationData = BTCPayServer.Client.Models.NotificationData;
using PaymentRequestData = BTCPayServer.Client.Models.PaymentRequestData; using PaymentRequestData = BTCPayServer.Client.Models.PaymentRequestData;
using PayoutData = BTCPayServer.Client.Models.PayoutData; using PayoutData = BTCPayServer.Client.Models.PayoutData;
using PayoutProcessorData = BTCPayServer.Client.Models.PayoutProcessorData;
using PullPaymentData = BTCPayServer.Client.Models.PullPaymentData; using PullPaymentData = BTCPayServer.Client.Models.PullPaymentData;
using StoreData = BTCPayServer.Client.Models.StoreData; using StoreData = BTCPayServer.Client.Models.StoreData;
using StoreWebhookData = BTCPayServer.Client.Models.StoreWebhookData; using StoreWebhookData = BTCPayServer.Client.Models.StoreWebhookData;
using WebhookDeliveryData = BTCPayServer.Client.Models.WebhookDeliveryData; using WebhookDeliveryData = BTCPayServer.Client.Models.WebhookDeliveryData;
using PayoutProcessorData = BTCPayServer.Client.Models.PayoutProcessorData;
namespace BTCPayServer.Controllers.Greenfield namespace BTCPayServer.Controllers.Greenfield
{ {

View File

@@ -466,7 +466,7 @@ namespace BTCPayServer
lnurlRequest ??= new LNURLPayRequest(); lnurlRequest ??= new LNURLPayRequest();
lnUrlMetadata ??= new Dictionary<string, string>(); lnUrlMetadata ??= new Dictionary<string, string>();
if (lnUrlMetadata?.TryGetValue("text/identifier", out var lnAddress) is true && lnAddress is string) if (lnUrlMetadata?.TryGetValue("text/identifier", out var lnAddress) is true && lnAddress is not null)
{ {
var pm = i.GetPaymentMethod(pmi); var pm = i.GetPaymentMethod(pmi);
var paymentMethodDetails = (LNURLPayPaymentMethodDetails)pm.GetPaymentMethodDetails(); var paymentMethodDetails = (LNURLPayPaymentMethodDetails)pm.GetPaymentMethodDetails();

View File

@@ -448,7 +448,8 @@ namespace BTCPayServer.Controllers
WalletTransactionInfo ix = null; WalletTransactionInfo ix = null;
foreach (var key in keys) foreach (var key in keys)
{ {
if (!labelInfo.TryGetValue(key, out var i)) continue; if (!labelInfo.TryGetValue(key, out var i))
continue;
if (ix is null) if (ix is null)
{ {
ix = i; ix = i;
@@ -458,7 +459,8 @@ namespace BTCPayServer.Controllers
ix.Merge(i); ix.Merge(i);
} }
} }
if (ix is null) continue; if (ix is null)
continue;
var labels = _labelService.CreateTransactionTagModels(ix, Request); var labels = _labelService.CreateTransactionTagModels(ix, Request);
var input = vm.Inputs.First(model => model.Index == inputToObject.Key); var input = vm.Inputs.First(model => model.Index == inputToObject.Key);
@@ -466,7 +468,8 @@ namespace BTCPayServer.Controllers
} }
foreach (var outputToObject in outputToObjects) foreach (var outputToObject in outputToObjects)
{ {
if (!labelInfo.TryGetValue(outputToObject.Value.Id, out var ix)) continue; if (!labelInfo.TryGetValue(outputToObject.Value.Id, out var ix))
continue;
var labels = _labelService.CreateTransactionTagModels(ix, Request); var labels = _labelService.CreateTransactionTagModels(ix, Request);
var destination = vm.Destinations.First(model => model.Destination == outputToObject.Key); var destination = vm.Destinations.First(model => model.Destination == outputToObject.Key);
destination.Labels = labels; destination.Labels = labels;

View File

@@ -211,7 +211,9 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
{ {
var payouts = (await PullPaymentHostedService.GetPayouts(new PullPaymentHostedService.PayoutQuery() var payouts = (await PullPaymentHostedService.GetPayouts(new PullPaymentHostedService.PayoutQuery()
{ {
States = new[] {PayoutState.AwaitingPayment}, Stores = new[] {storeId}, PayoutIds = payoutIds States = new[] { PayoutState.AwaitingPayment },
Stores = new[] { storeId },
PayoutIds = payoutIds
}, context)).Where(data => }, context)).Where(data =>
PaymentMethodId.TryParse(data.PaymentMethodId, out var paymentMethodId) && PaymentMethodId.TryParse(data.PaymentMethodId, out var paymentMethodId) &&
CanHandle(paymentMethodId)) CanHandle(paymentMethodId))
@@ -234,7 +236,9 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
{ {
var payouts = (await PullPaymentHostedService.GetPayouts(new PullPaymentHostedService.PayoutQuery() var payouts = (await PullPaymentHostedService.GetPayouts(new PullPaymentHostedService.PayoutQuery()
{ {
States = new[] {PayoutState.AwaitingPayment}, Stores = new[] {storeId}, PayoutIds = payoutIds States = new[] { PayoutState.AwaitingPayment },
Stores = new[] { storeId },
PayoutIds = payoutIds
}, context)).Where(data => }, context)).Where(data =>
PaymentMethodId.TryParse(data.PaymentMethodId, out var paymentMethodId) && PaymentMethodId.TryParse(data.PaymentMethodId, out var paymentMethodId) &&
CanHandle(paymentMethodId)) CanHandle(paymentMethodId))

View File

@@ -87,9 +87,12 @@ namespace BTCPayServer
var match = derivationRegex.Match(xpub.Trim()); var match = derivationRegex.Match(xpub.Trim());
if (match.Success) if (match.Success)
{ {
if (!string.IsNullOrEmpty(match.Groups[1].Value)) rootFingerprint = HDFingerprint.Parse(match.Groups[1].Value); if (!string.IsNullOrEmpty(match.Groups[1].Value))
if (!string.IsNullOrEmpty(match.Groups[2].Value)) accountKeyPath = KeyPath.Parse(match.Groups[2].Value); rootFingerprint = HDFingerprint.Parse(match.Groups[1].Value);
if (!string.IsNullOrEmpty(match.Groups[3].Value)) xpub = match.Groups[3].Value; if (!string.IsNullOrEmpty(match.Groups[2].Value))
accountKeyPath = KeyPath.Parse(match.Groups[2].Value);
if (!string.IsNullOrEmpty(match.Groups[3].Value))
xpub = match.Groups[3].Value;
} }
derivationSchemeSettings.AccountOriginal = xpub.Trim(); derivationSchemeSettings.AccountOriginal = xpub.Trim();
derivationSchemeSettings.AccountDerivation = electrum ? derivationSchemeParser.ParseElectrum(derivationSchemeSettings.AccountOriginal) : derivationSchemeParser.Parse(derivationSchemeSettings.AccountOriginal); derivationSchemeSettings.AccountDerivation = electrum ? derivationSchemeParser.ParseElectrum(derivationSchemeSettings.AccountOriginal) : derivationSchemeParser.Parse(derivationSchemeSettings.AccountOriginal);

View File

@@ -39,7 +39,8 @@ namespace BTCPayServer.Filters
if (matchedDomainMapping != null && req.Method != "POST" && !req.HasFormContentType) if (matchedDomainMapping != null && req.Method != "POST" && !req.HasFormContentType)
{ {
var uri = new UriBuilder(req.Scheme, matchedDomainMapping.Domain); var uri = new UriBuilder(req.Scheme, matchedDomainMapping.Domain);
if (req.Host.Port.HasValue) uri.Port = req.Host.Port.Value; if (req.Host.Port.HasValue)
uri.Port = req.Host.Port.Value;
context.RouteContext.HttpContext.Response.Redirect(uri.ToString()); context.RouteContext.HttpContext.Response.Redirect(uri.ToString());
return true; return true;
} }

View File

@@ -57,7 +57,8 @@ public class UIFormsController : Controller
public async Task<IActionResult> Modify(string storeId, string id) public async Task<IActionResult> Modify(string storeId, string id)
{ {
var form = await _formDataService.GetForm(storeId, id); var form = await _formDataService.GetForm(storeId, id);
if (form is null) return NotFound(); if (form is null)
return NotFound();
var config = Form.Parse(form.Config); var config = Form.Parse(form.Config);
return View(new ModifyForm { Name = form.Name, FormConfig = config.ToString(), Public = form.Public }); return View(new ModifyForm { Name = form.Name, FormConfig = config.ToString(), Public = form.Public });
@@ -95,7 +96,11 @@ public class UIFormsController : Controller
{ {
var formData = new FormData var formData = new FormData
{ {
Id = id, StoreId = storeId, Name = modifyForm.Name, Config = modifyForm.FormConfig,Public = modifyForm.Public Id = id,
StoreId = storeId,
Name = modifyForm.Name,
Config = modifyForm.FormConfig,
Public = modifyForm.Public
}; };
var isNew = id is null; var isNew = id is null;
await _formDataService.AddOrUpdateForm(formData); await _formDataService.AddOrUpdateForm(formData);
@@ -123,7 +128,8 @@ public class UIFormsController : Controller
await _formDataService.RemoveForm(id, storeId); await _formDataService.RemoveForm(id, storeId);
TempData.SetStatusMessageModel(new StatusMessageModel TempData.SetStatusMessageModel(new StatusMessageModel
{ {
Severity = StatusMessageModel.StatusSeverity.Success, Message = "Form removed" Severity = StatusMessageModel.StatusSeverity.Success,
Message = "Form removed"
}); });
return RedirectToAction("FormsList", new { storeId }); return RedirectToAction("FormsList", new { storeId });
} }

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Configuration.Provider;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
@@ -26,6 +27,8 @@ using BTCPayServer.Payments.Lightning;
using BTCPayServer.Payments.PayJoin; using BTCPayServer.Payments.PayJoin;
using BTCPayServer.PayoutProcessors; using BTCPayServer.PayoutProcessors;
using BTCPayServer.Plugins; using BTCPayServer.Plugins;
using BTCPayServer.Rating;
using BTCPayServer.Rating.Providers;
using BTCPayServer.Security; using BTCPayServer.Security;
using BTCPayServer.Security.Bitpay; using BTCPayServer.Security.Bitpay;
using BTCPayServer.Security.Greenfield; using BTCPayServer.Security.Greenfield;
@@ -42,6 +45,7 @@ using BTCPayServer.Services.PaymentRequests;
using BTCPayServer.Services.Rates; using BTCPayServer.Services.Rates;
using BTCPayServer.Services.Stores; using BTCPayServer.Services.Stores;
using BTCPayServer.Services.Wallets; using BTCPayServer.Services.Wallets;
using ExchangeSharp;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@@ -61,10 +65,6 @@ using NBXplorer.DerivationStrategy;
using Newtonsoft.Json; using Newtonsoft.Json;
using NicolasDorier.RateLimits; using NicolasDorier.RateLimits;
using Serilog; using Serilog;
using ExchangeSharp;
using BTCPayServer.Rating;
using System.Configuration.Provider;
using BTCPayServer.Rating.Providers;
#if ALTCOINS #if ALTCOINS
using BTCPayServer.Services.Altcoins.Monero; using BTCPayServer.Services.Altcoins.Monero;
using BTCPayServer.Services.Altcoins.Zcash; using BTCPayServer.Services.Altcoins.Zcash;

View File

@@ -349,7 +349,8 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
} }
entity.Metadata.SetAdditionalData("receiptData", receiptData); entity.Metadata.SetAdditionalData("receiptData", receiptData);
if (formResponseJObject is null) return; if (formResponseJObject is null)
return;
var meta = entity.Metadata.ToJObject(); var meta = entity.Metadata.ToJObject();
meta.Merge(formResponseJObject); meta.Merge(formResponseJObject);
entity.Metadata = InvoiceMetadata.FromJObject(meta); entity.Metadata = InvoiceMetadata.FromJObject(meta);

View File

@@ -1,5 +1,5 @@
using System.Collections.Generic;
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace BTCPayServer namespace BTCPayServer

View File

@@ -1,4 +1,4 @@
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Plugins.Test.Services; using BTCPayServer.Plugins.Test.Services;