Run dotnet format (#3244)

This commit is contained in:
Nicolas Dorier
2021-12-31 16:59:02 +09:00
committed by GitHub
parent e2d0b7c5f7
commit 04b8eafacb
259 changed files with 1613 additions and 1491 deletions

View File

@@ -37,11 +37,13 @@ namespace BTCPayServer.Client
if (status != null) if (status != null)
queryPayload.Add(nameof(status), status.Select(s => s.ToString().ToLower()).ToArray()); queryPayload.Add(nameof(status), status.Select(s => s.ToString().ToLower()).ToArray());
if(skip != null) { if (skip != null)
{
queryPayload.Add(nameof(skip), skip); queryPayload.Add(nameof(skip), skip);
} }
if(take != null) { if (take != null)
{
queryPayload.Add(nameof(take), take); queryPayload.Add(nameof(take), take);
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using NBitcoin; using NBitcoin;
using NBitcoin.JsonConverters; using NBitcoin.JsonConverters;
using Newtonsoft.Json; using Newtonsoft.Json;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;

View File

@@ -1,4 +1,4 @@
using BTCPayServer.Client.JsonConverters; using BTCPayServer.Client.JsonConverters;
using NBitcoin; using NBitcoin;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;

View File

@@ -1,4 +1,4 @@
namespace BTCPayServer.Client.Models namespace BTCPayServer.Client.Models
{ {
public class GenericPaymentMethodData public class GenericPaymentMethodData
{ {

View File

@@ -1,4 +1,4 @@
namespace BTCPayServer.Client.Models namespace BTCPayServer.Client.Models
{ {
public class LNURLPayPaymentMethodBaseData public class LNURLPayPaymentMethodBaseData
{ {

View File

@@ -1,4 +1,4 @@
namespace BTCPayServer.Client.Models namespace BTCPayServer.Client.Models
{ {
public class LNURLPayPaymentMethodData : LNURLPayPaymentMethodBaseData public class LNURLPayPaymentMethodData : LNURLPayPaymentMethodBaseData
{ {

View File

@@ -1,4 +1,4 @@
namespace BTCPayServer.Client.Models namespace BTCPayServer.Client.Models
{ {
public class LightningNetworkPaymentMethodBaseData public class LightningNetworkPaymentMethodBaseData
{ {

View File

@@ -1,4 +1,4 @@
using NBitcoin; using NBitcoin;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace BTCPayServer.Client.Models namespace BTCPayServer.Client.Models

View File

@@ -1,4 +1,4 @@
using BTCPayServer.Client.JsonConverters; using BTCPayServer.Client.JsonConverters;
using NBitcoin; using NBitcoin;
using Newtonsoft.Json; using Newtonsoft.Json;

View File

@@ -1,4 +1,4 @@
using NBXplorer; using NBXplorer;
namespace BTCPayServer.Common namespace BTCPayServer.Common
{ {

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations;
using BTCPayServer.Data; using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace BTCPayServer.Migrations namespace BTCPayServer.Migrations
{ {

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

@@ -1,4 +1,4 @@
using System; using System;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;

View File

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

View File

@@ -1,4 +1,4 @@
using System; using System;
using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Abstractions.Models; using BTCPayServer.Abstractions.Models;
using BTCPayServer.Abstractions.Services; using BTCPayServer.Abstractions.Services;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Net.Http; using System.Net.Http;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;

View File

@@ -28,7 +28,8 @@ namespace BTCPayServer.Tests
public static void AssertNoError(this IWebDriver driver) public static void AssertNoError(this IWebDriver driver)
{ {
if (!driver.PageSource.Contains("alert-danger")) return; if (!driver.PageSource.Contains("alert-danger"))
return;
foreach (var dangerAlert in driver.FindElements(By.ClassName("alert-danger"))) foreach (var dangerAlert in driver.FindElements(By.ClassName("alert-danger")))
Assert.False(dangerAlert.Displayed, $"No alert should be displayed, but found this on {driver.Url}: {dangerAlert.Text}"); Assert.False(dangerAlert.Displayed, $"No alert should be displayed, but found this on {driver.Url}: {dangerAlert.Text}");
} }

View File

@@ -4,6 +4,7 @@ using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Abstractions.Models; using BTCPayServer.Abstractions.Models;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.Controllers; using BTCPayServer.Controllers;
using BTCPayServer.Data; using BTCPayServer.Data;
@@ -16,11 +17,10 @@ using BTCPayServer.Services;
using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Wallets; using BTCPayServer.Services.Wallets;
using BTCPayServer.Tests.Logging; using BTCPayServer.Tests.Logging;
using BTCPayServer.Views.Stores;
using BTCPayServer.Views.Wallets; using BTCPayServer.Views.Wallets;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using NBitcoin; using NBitcoin;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.Views.Stores;
using NBitcoin.Payment; using NBitcoin.Payment;
using NBitpayClient; using NBitpayClient;
using NBXplorer.DerivationStrategy; using NBXplorer.DerivationStrategy;

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Abstractions.Models; using BTCPayServer.Abstractions.Models;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.Lightning; using BTCPayServer.Lightning;
using BTCPayServer.Lightning.CLightning; using BTCPayServer.Lightning.CLightning;
using BTCPayServer.Views.Manage; using BTCPayServer.Views.Manage;
@@ -12,11 +13,10 @@ using BTCPayServer.Views.Stores;
using BTCPayServer.Views.Wallets; using BTCPayServer.Views.Wallets;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using NBitcoin; using NBitcoin;
using BTCPayServer.BIP78.Sender;
using OpenQA.Selenium; using OpenQA.Selenium;
using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Chrome;
using Xunit;
using OpenQA.Selenium.Support.UI; using OpenQA.Selenium.Support.UI;
using Xunit;
namespace BTCPayServer.Tests namespace BTCPayServer.Tests
{ {

View File

@@ -5,6 +5,7 @@ using System.Net.Http;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.Client; using BTCPayServer.Client;
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.Controllers; using BTCPayServer.Controllers;
@@ -14,6 +15,7 @@ using BTCPayServer.Lightning;
using BTCPayServer.Lightning.CLightning; using BTCPayServer.Lightning.CLightning;
using BTCPayServer.Models.AccountViewModels; using BTCPayServer.Models.AccountViewModels;
using BTCPayServer.Models.StoreViewModels; using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Payments.Lightning;
using BTCPayServer.Payments.PayJoin.Sender; using BTCPayServer.Payments.PayJoin.Sender;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Services.Stores; using BTCPayServer.Services.Stores;
@@ -23,8 +25,6 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.Operations; using Microsoft.CodeAnalysis.Operations;
using NBitcoin; using NBitcoin;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.Payments.Lightning;
using NBitcoin.Payment; using NBitcoin.Payment;
using NBitpayClient; using NBitpayClient;
using NBXplorer.DerivationStrategy; using NBXplorer.DerivationStrategy;

View File

@@ -1,8 +1,8 @@
using System; using System;
using BTCPayServer.Configuration;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using BTCPayServer.Configuration;
using BTCPayServer.Logging; using BTCPayServer.Logging;
using BTCPayServer.SSH; using BTCPayServer.SSH;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;

View File

@@ -464,8 +464,13 @@ namespace BTCPayServer.Controllers
return RedirectToAction(nameof(HomeController.Index), "Home"); return RedirectToAction(nameof(HomeController.Index), "Home");
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
var user = new ApplicationUser { UserName = model.Email, Email = model.Email, RequiresEmailConfirmation = policies.RequiresConfirmedEmail, var user = new ApplicationUser
Created = DateTimeOffset.UtcNow }; {
UserName = model.Email,
Email = model.Email,
RequiresEmailConfirmation = policies.RequiresConfirmedEmail,
Created = DateTimeOffset.UtcNow
};
var result = await _userManager.CreateAsync(user, model.Password); var result = await _userManager.CreateAsync(user, model.Password);
if (result.Succeeded) if (result.Succeeded)
{ {
@@ -583,7 +588,8 @@ namespace BTCPayServer.Controllers
} }
_eventAggregator.Publish(new UserPasswordResetRequestedEvent() _eventAggregator.Publish(new UserPasswordResetRequestedEvent()
{ {
User = user, RequestUri = Request.GetAbsoluteRootUri() User = user,
RequestUri = Request.GetAbsoluteRootUri()
}); });
return RedirectToAction(nameof(ForgotPasswordConfirmation)); return RedirectToAction(nameof(ForgotPasswordConfirmation));
} }
@@ -639,7 +645,8 @@ namespace BTCPayServer.Controllers
{ {
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel()
{ {
Severity = StatusMessageModel.StatusSeverity.Success, Message = "Password successfully set." Severity = StatusMessageModel.StatusSeverity.Success,
Message = "Password successfully set."
}); });
return RedirectToAction(nameof(Login)); return RedirectToAction(nameof(Login));
} }

View File

@@ -1,9 +1,9 @@
using System; using System;
using BTCPayServer.Data;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Constants;
using BTCPayServer.Client; using BTCPayServer.Client;
using BTCPayServer.Data;
using BTCPayServer.Models; using BTCPayServer.Models;
using BTCPayServer.Models.AppViewModels; using BTCPayServer.Models.AppViewModels;
using BTCPayServer.Services.Apps; using BTCPayServer.Services.Apps;

View File

@@ -37,7 +37,10 @@ namespace BTCPayServer.Controllers.GreenField
{ {
var items = await _notificationManager.GetNotifications(new NotificationsQuery() var items = await _notificationManager.GetNotifications(new NotificationsQuery()
{ {
Seen = seen, UserId = _userManager.GetUserId(User), Skip = skip, Take = take Seen = seen,
UserId = _userManager.GetUserId(User),
Skip = skip,
Take = take
}); });
return Ok(items.Items.Select(ToModel)); return Ok(items.Items.Select(ToModel));
@@ -50,7 +53,8 @@ namespace BTCPayServer.Controllers.GreenField
{ {
var items = await _notificationManager.GetNotifications(new NotificationsQuery() var items = await _notificationManager.GetNotifications(new NotificationsQuery()
{ {
Ids = new[] {id}, UserId = _userManager.GetUserId(User) Ids = new[] { id },
UserId = _userManager.GetUserId(User)
}); });
if (items.Count == 0) if (items.Count == 0)
@@ -84,7 +88,8 @@ namespace BTCPayServer.Controllers.GreenField
{ {
await _notificationManager.Remove(new NotificationsQuery() await _notificationManager.Remove(new NotificationsQuery()
{ {
Ids = new[] {id}, UserId = _userManager.GetUserId(User) Ids = new[] { id },
UserId = _userManager.GetUserId(User)
}); });
return Ok(); return Ok();

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Constants;
using BTCPayServer.Client; using BTCPayServer.Client;

View File

@@ -85,7 +85,8 @@ namespace BTCPayServer.Controllers.GreenField
public async Task<IActionResult> ShowOnChainWalletOverview(string storeId, string cryptoCode) public async Task<IActionResult> ShowOnChainWalletOverview(string storeId, string cryptoCode)
{ {
if (IsInvalidWalletRequest(cryptoCode, out var network, if (IsInvalidWalletRequest(cryptoCode, out var network,
out var derivationScheme, out var actionResult)) return actionResult; out var derivationScheme, out var actionResult))
return actionResult;
var wallet = _btcPayWalletProvider.GetWallet(network); var wallet = _btcPayWalletProvider.GetWallet(network);
var balance = await wallet.GetBalance(derivationScheme.AccountDerivation); var balance = await wallet.GetBalance(derivationScheme.AccountDerivation);
@@ -104,7 +105,8 @@ namespace BTCPayServer.Controllers.GreenField
public async Task<IActionResult> GetOnChainFeeRate(string storeId, string cryptoCode, int? blockTarget = null) public async Task<IActionResult> GetOnChainFeeRate(string storeId, string cryptoCode, int? blockTarget = null)
{ {
if (IsInvalidWalletRequest(cryptoCode, out var network, if (IsInvalidWalletRequest(cryptoCode, out var network,
out var derivationScheme, out var actionResult)) return actionResult; out var derivationScheme, out var actionResult))
return actionResult;
var feeRateTarget = blockTarget ?? Store.GetStoreBlob().RecommendedFeeBlockTarget; var feeRateTarget = blockTarget ?? Store.GetStoreBlob().RecommendedFeeBlockTarget;
return Ok(new OnChainWalletFeeRateData() return Ok(new OnChainWalletFeeRateData()
@@ -119,7 +121,8 @@ namespace BTCPayServer.Controllers.GreenField
public async Task<IActionResult> GetOnChainWalletReceiveAddress(string storeId, string cryptoCode, bool forceGenerate = false) public async Task<IActionResult> GetOnChainWalletReceiveAddress(string storeId, string cryptoCode, bool forceGenerate = false)
{ {
if (IsInvalidWalletRequest(cryptoCode, out var network, if (IsInvalidWalletRequest(cryptoCode, out var network,
out var derivationScheme, out var actionResult)) return actionResult; out var derivationScheme, out var actionResult))
return actionResult;
var kpi = await _walletReceiveService.GetOrGenerate(new WalletId(storeId, cryptoCode), forceGenerate); var kpi = await _walletReceiveService.GetOrGenerate(new WalletId(storeId, cryptoCode), forceGenerate);
if (kpi is null) if (kpi is null)
@@ -146,7 +149,8 @@ namespace BTCPayServer.Controllers.GreenField
public async Task<IActionResult> UnReserveOnChainWalletReceiveAddress(string storeId, string cryptoCode) public async Task<IActionResult> UnReserveOnChainWalletReceiveAddress(string storeId, string cryptoCode)
{ {
if (IsInvalidWalletRequest(cryptoCode, out var network, if (IsInvalidWalletRequest(cryptoCode, out var network,
out var derivationScheme, out var actionResult)) return actionResult; out var derivationScheme, out var actionResult))
return actionResult;
var addr = await _walletReceiveService.UnReserveAddress(new WalletId(storeId, cryptoCode)); var addr = await _walletReceiveService.UnReserveAddress(new WalletId(storeId, cryptoCode));
if (addr is null) if (addr is null)
@@ -168,7 +172,8 @@ namespace BTCPayServer.Controllers.GreenField
) )
{ {
if (IsInvalidWalletRequest(cryptoCode, out var network, if (IsInvalidWalletRequest(cryptoCode, out var network,
out var derivationScheme, out var actionResult)) return actionResult; out var derivationScheme, out var actionResult))
return actionResult;
var wallet = _btcPayWalletProvider.GetWallet(network); var wallet = _btcPayWalletProvider.GetWallet(network);
var walletId = new WalletId(storeId, cryptoCode); var walletId = new WalletId(storeId, cryptoCode);
@@ -205,7 +210,8 @@ namespace BTCPayServer.Controllers.GreenField
string transactionId) string transactionId)
{ {
if (IsInvalidWalletRequest(cryptoCode, out var network, if (IsInvalidWalletRequest(cryptoCode, out var network,
out var derivationScheme, out var actionResult)) return actionResult; out var derivationScheme, out var actionResult))
return actionResult;
var wallet = _btcPayWalletProvider.GetWallet(network); var wallet = _btcPayWalletProvider.GetWallet(network);
var tx = await wallet.FetchTransaction(derivationScheme.AccountDerivation, uint256.Parse(transactionId)); var tx = await wallet.FetchTransaction(derivationScheme.AccountDerivation, uint256.Parse(transactionId));
@@ -227,7 +233,8 @@ namespace BTCPayServer.Controllers.GreenField
public async Task<IActionResult> GetOnChainWalletUTXOs(string storeId, string cryptoCode) public async Task<IActionResult> GetOnChainWalletUTXOs(string storeId, string cryptoCode)
{ {
if (IsInvalidWalletRequest(cryptoCode, out var network, if (IsInvalidWalletRequest(cryptoCode, out var network,
out var derivationScheme, out var actionResult)) return actionResult; out var derivationScheme, out var actionResult))
return actionResult;
var wallet = _btcPayWalletProvider.GetWallet(network); var wallet = _btcPayWalletProvider.GetWallet(network);
@@ -260,7 +267,8 @@ namespace BTCPayServer.Controllers.GreenField
[FromBody] CreateOnChainTransactionRequest request) [FromBody] CreateOnChainTransactionRequest request)
{ {
if (IsInvalidWalletRequest(cryptoCode, out var network, if (IsInvalidWalletRequest(cryptoCode, out var network,
out var derivationScheme, out var actionResult)) return actionResult; out var derivationScheme, out var actionResult))
return actionResult;
if (network.ReadonlyWallet) if (network.ReadonlyWallet)
{ {
return this.CreateAPIError("not-available", return this.CreateAPIError("not-available",

View File

@@ -36,7 +36,8 @@ namespace BTCPayServer.Controllers.GreenField
var storeBlob = Store.GetStoreBlob(); var storeBlob = Store.GetStoreBlob();
var excludedPaymentMethods = storeBlob.GetExcludedPaymentMethods(); var excludedPaymentMethods = storeBlob.GetExcludedPaymentMethods();
var canModifyStore = (await _authorizationService.AuthorizeAsync(User, null, var canModifyStore = (await _authorizationService.AuthorizeAsync(User, null,
new PolicyRequirement(Policies.CanModifyStoreSettings))).Succeeded;; new PolicyRequirement(Policies.CanModifyStoreSettings))).Succeeded;
;
return Ok(Store.GetSupportedPaymentMethods(_btcPayNetworkProvider) return Ok(Store.GetSupportedPaymentMethods(_btcPayNetworkProvider)
.Where(method => .Where(method =>
enabled is null || (enabled is false && excludedPaymentMethods.Match(method.PaymentId))) enabled is null || (enabled is false && excludedPaymentMethods.Match(method.PaymentId)))

View File

@@ -10,17 +10,17 @@ using BTCPayServer.Configuration;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Events; using BTCPayServer.Events;
using BTCPayServer.HostedServices; using BTCPayServer.HostedServices;
using BTCPayServer.Logging;
using BTCPayServer.Security; using BTCPayServer.Security;
using BTCPayServer.Security.GreenField; using BTCPayServer.Security.GreenField;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Storage.Services;
using BTCPayServer.Services.Stores; using BTCPayServer.Services.Stores;
using BTCPayServer.Storage.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NicolasDorier.RateLimits; using NicolasDorier.RateLimits;
using BTCPayServer.Logging;
namespace BTCPayServer.Controllers.GreenField namespace BTCPayServer.Controllers.GreenField
{ {
@@ -169,7 +169,8 @@ namespace BTCPayServer.Controllers.GreenField
if (!anyAdmin) if (!anyAdmin)
{ {
var settings = await _settingsRepository.GetSettingAsync<ThemeSettings>(); var settings = await _settingsRepository.GetSettingAsync<ThemeSettings>();
if (settings != null) { if (settings != null)
{
settings.FirstRun = false; settings.FirstRun = false;
await _settingsRepository.UpdateSetting(settings); await _settingsRepository.UpdateSetting(settings);
} }
@@ -234,7 +235,8 @@ namespace BTCPayServer.Controllers.GreenField
private async Task<bool> IsUserTheOnlyOneAdmin(ApplicationUser user) private async Task<bool> IsUserTheOnlyOneAdmin(ApplicationUser user)
{ {
var isUserAdmin = await _userService.IsAdminUser(user); var isUserAdmin = await _userService.IsAdminUser(user);
if (!isUserAdmin) { if (!isUserAdmin)
{
return false; return false;
} }

View File

@@ -4,9 +4,9 @@ using System.Threading.Tasks;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Filters; using BTCPayServer.Filters;
using BTCPayServer.Payments; using BTCPayServer.Payments;
using BTCPayServer.Services;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NBitcoin; using NBitcoin;
using BTCPayServer.Services;
namespace BTCPayServer.Controllers namespace BTCPayServer.Controllers
{ {

View File

@@ -283,7 +283,8 @@ namespace BTCPayServer.Controllers
case RefundSteps.SelectRate: case RefundSteps.SelectRate:
createPullPayment = new CreatePullPayment createPullPayment = new CreatePullPayment
{ {
Name = $"Refund {invoice.Id}", PaymentMethodIds = new[] { paymentMethodId }, Name = $"Refund {invoice.Id}",
PaymentMethodIds = new[] { paymentMethodId },
StoreId = invoice.StoreId StoreId = invoice.StoreId
}; };
switch (model.SelectedRefundOption) switch (model.SelectedRefundOption)
@@ -343,7 +344,8 @@ namespace BTCPayServer.Controllers
createPullPayment = new CreatePullPayment createPullPayment = new CreatePullPayment
{ {
Name = $"Refund {invoice.Id}", PaymentMethodIds = new[] { paymentMethodId }, Name = $"Refund {invoice.Id}",
PaymentMethodIds = new[] { paymentMethodId },
StoreId = invoice.StoreId, StoreId = invoice.StoreId,
Currency = model.CustomCurrency, Currency = model.CustomCurrency,
Amount = model.CustomAmount Amount = model.CustomAmount

View File

@@ -201,14 +201,19 @@ namespace BTCPayServer.Controllers
* Go over each permission and associated store IDs and * Go over each permission and associated store IDs and
* join them so that permission for a specific store is parsed correctly * join them so that permission for a specific store is parsed correctly
*/ */
for (var i = 0; i < permissions.Length; i++) { for (var i = 0; i < permissions.Length; i++)
{
var currPerm = permissions[i]; var currPerm = permissions[i];
var storeIds = vm.PermissionValues[i].SpecificStores.ToArray(); var storeIds = vm.PermissionValues[i].SpecificStores.ToArray();
if (storeIds.Length > 0) { if (storeIds.Length > 0)
for (var x = 0; x < storeIds.Length; x++) { {
for (var x = 0; x < storeIds.Length; x++)
{
permissionsWithStoreIDs.Add($"{currPerm}:{storeIds[x]}"); permissionsWithStoreIDs.Add($"{currPerm}:{storeIds[x]}");
} }
} else { }
else
{
permissionsWithStoreIDs.Add(currPerm); permissionsWithStoreIDs.Add(currPerm);
} }
} }
@@ -232,7 +237,8 @@ namespace BTCPayServer.Controllers
var command = commandParts.Length > 1 ? commandParts[1] : null; var command = commandParts.Length > 1 ? commandParts[1] : null;
var isPerformingAnAction = command == "change-store-mode" || command == "add-store"; var isPerformingAnAction = command == "change-store-mode" || command == "add-store";
// Don't want to accidentally change mode for the user if they are explicitly performing some action // Don't want to accidentally change mode for the user if they are explicitly performing some action
if (isPerformingAnAction) { if (isPerformingAnAction)
{
continue; continue;
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;

View File

@@ -56,7 +56,8 @@ namespace BTCPayServer.Controllers
await _userManager.UpdateAsync(user); await _userManager.UpdateAsync(user);
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel()
{ {
Message = "Updated successfully.", Severity = StatusMessageModel.StatusSeverity.Success Message = "Updated successfully.",
Severity = StatusMessageModel.StatusSeverity.Success
}); });
return RedirectToAction("NotificationSettings"); return RedirectToAction("NotificationSettings");
} }

View File

@@ -110,7 +110,9 @@ namespace BTCPayServer.Controllers
var res = await _notificationManager.GetNotifications(new NotificationsQuery() var res = await _notificationManager.GetNotifications(new NotificationsQuery()
{ {
Skip = skip, Take = count, UserId = userId Skip = skip,
Take = count,
UserId = userId
}); });
var model = new IndexViewModel() { Skip = skip, Count = count, Items = res.Items, Total = res.Count }; var model = new IndexViewModel() { Skip = skip, Count = count, Items = res.Items, Total = res.Count };
@@ -148,7 +150,8 @@ namespace BTCPayServer.Controllers
var items = await var items = await
_notificationManager.ToggleSeen(new NotificationsQuery() _notificationManager.ToggleSeen(new NotificationsQuery()
{ {
Ids = new[] {id}, UserId = userId Ids = new[] { id },
UserId = userId
}, true); }, true);
var link = items.FirstOrDefault()?.ActionLink ?? ""; var link = items.FirstOrDefault()?.ActionLink ?? "";
@@ -185,21 +188,26 @@ namespace BTCPayServer.Controllers
case "delete": case "delete":
await _notificationManager.Remove(new NotificationsQuery() await _notificationManager.Remove(new NotificationsQuery()
{ {
UserId = userId, Ids = selectedItems UserId = userId,
Ids = selectedItems
}); });
break; break;
case "mark-seen": case "mark-seen":
await _notificationManager.ToggleSeen(new NotificationsQuery() await _notificationManager.ToggleSeen(new NotificationsQuery()
{ {
UserId = userId, Ids = selectedItems, Seen = false UserId = userId,
Ids = selectedItems,
Seen = false
}, true); }, true);
break; break;
case "mark-unseen": case "mark-unseen":
await _notificationManager.ToggleSeen(new NotificationsQuery() await _notificationManager.ToggleSeen(new NotificationsQuery()
{ {
UserId = userId, Ids = selectedItems, Seen = true UserId = userId,
Ids = selectedItems,
Seen = true
}, false); }, false);
break; break;
} }

View File

@@ -279,7 +279,8 @@ namespace BTCPayServer.Controllers
return NotFound(); return NotFound();
} }
if (!result.AllowCustomPaymentAmounts) { if (!result.AllowCustomPaymentAmounts)
{
return BadRequest("Not allowed to cancel this invoice"); return BadRequest("Not allowed to cancel this invoice");
} }

View File

@@ -107,7 +107,8 @@ namespace BTCPayServer.Controllers
{ {
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel()
{ {
Message = "The plugin could not be downloaded. Try again later.", Severity = StatusMessageModel.StatusSeverity.Error Message = "The plugin could not be downloaded. Try again later.",
Severity = StatusMessageModel.StatusSeverity.Error
}); });
} }

View File

@@ -138,8 +138,14 @@ namespace BTCPayServer.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
IdentityResult result; IdentityResult result;
var user = new ApplicationUser { UserName = model.Email, Email = model.Email, EmailConfirmed = model.EmailConfirmed, RequiresEmailConfirmation = requiresConfirmedEmail, var user = new ApplicationUser
Created = DateTimeOffset.UtcNow }; {
UserName = model.Email,
Email = model.Email,
EmailConfirmed = model.EmailConfirmed,
RequiresEmailConfirmation = requiresConfirmedEmail,
Created = DateTimeOffset.UtcNow
};
if (!string.IsNullOrEmpty(model.Password)) if (!string.IsNullOrEmpty(model.Password))
{ {
@@ -159,7 +165,10 @@ namespace BTCPayServer.Controllers
_eventAggregator.Publish(new UserRegisteredEvent() _eventAggregator.Publish(new UserRegisteredEvent()
{ {
RequestUri = Request.GetAbsoluteRootUri(), User = user, Admin = model.IsAdmin is true, CallbackUrlGenerated = tcs RequestUri = Request.GetAbsoluteRootUri(),
User = user,
Admin = model.IsAdmin is true,
CallbackUrlGenerated = tcs
}); });
var callbackUrl = await tcs.Task; var callbackUrl = await tcs.Task;
@@ -173,7 +182,8 @@ namespace BTCPayServer.Controllers
Html = Html =
$"Account created without a set password. An email will be sent (if configured) to set the password.<br/> You may alternatively share this link with them: <a class='alert-link' href='{callbackUrl}'>{callbackUrl}</a>" $"Account created without a set password. An email will be sent (if configured) to set the password.<br/> You may alternatively share this link with them: <a class='alert-link' href='{callbackUrl}'>{callbackUrl}</a>"
}); });
}else if (!await _UserManager.HasPasswordAsync(user)) }
else if (!await _UserManager.HasPasswordAsync(user))
{ {
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel()
{ {

View File

@@ -172,7 +172,9 @@ namespace BTCPayServer.Controllers
var vm = this.ParseListQuery(new PullPaymentsModel() var vm = this.ParseListQuery(new PullPaymentsModel()
{ {
Skip = skip, Count = count, Total = await ppsQuery.CountAsync() Skip = skip,
Count = count,
Total = await ppsQuery.CountAsync()
}); });
var pps = (await ppsQuery var pps = (await ppsQuery
.Skip(vm.Skip) .Skip(vm.Skip)
@@ -186,7 +188,8 @@ namespace BTCPayServer.Controllers
.Select(o => o.GetBlob(_jsonSerializerSettings).Amount).Sum(); .Select(o => o.GetBlob(_jsonSerializerSettings).Amount).Sum();
var totalAwaiting = pp.Payouts.Where(p => (p.State == PayoutState.AwaitingPayment || var totalAwaiting = pp.Payouts.Where(p => (p.State == PayoutState.AwaitingPayment ||
p.State == PayoutState.AwaitingApproval) && p.State == PayoutState.AwaitingApproval) &&
p.IsInPeriod(pp, now)).Select(o => o.GetBlob(_jsonSerializerSettings).Amount).Sum();; p.IsInPeriod(pp, now)).Select(o => o.GetBlob(_jsonSerializerSettings).Amount).Sum();
;
var ppBlob = pp.GetBlob(); var ppBlob = pp.GetBlob();
var ni = _currencyNameTable.GetCurrencyData(ppBlob.Currency, true); var ni = _currencyNameTable.GetCurrencyData(ppBlob.Currency, true);
var nfi = _currencyNameTable.GetNumberFormatInfo(ppBlob.Currency, true); var nfi = _currencyNameTable.GetNumberFormatInfo(ppBlob.Currency, true);
@@ -331,17 +334,20 @@ namespace BTCPayServer.Controllers
} }
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel()
{ {
Message = "Payouts approved", Severity = StatusMessageModel.StatusSeverity.Success Message = "Payouts approved",
Severity = StatusMessageModel.StatusSeverity.Success
}); });
break; break;
} }
case "pay": case "pay":
{ {
if (handler is { }) return await handler?.InitiatePayment(paymentMethodId, payoutIds); if (handler is { })
return await handler?.InitiatePayment(paymentMethodId, payoutIds);
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel()
{ {
Message = "Paying via this payment method is not supported", Severity = StatusMessageModel.StatusSeverity.Error Message = "Paying via this payment method is not supported",
Severity = StatusMessageModel.StatusSeverity.Error
}); });
break; break;
} }
@@ -379,7 +385,8 @@ namespace BTCPayServer.Controllers
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel()
{ {
Message = "Payouts marked as paid", Severity = StatusMessageModel.StatusSeverity.Success Message = "Payouts marked as paid",
Severity = StatusMessageModel.StatusSeverity.Success
}); });
break; break;
} }
@@ -389,7 +396,8 @@ namespace BTCPayServer.Controllers
new PullPaymentHostedService.CancelRequest(payoutIds)); new PullPaymentHostedService.CancelRequest(payoutIds));
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel()
{ {
Message = "Payouts archived", Severity = StatusMessageModel.StatusSeverity.Success Message = "Payouts archived",
Severity = StatusMessageModel.StatusSeverity.Success
}); });
break; break;
} }

View File

@@ -1,10 +1,10 @@
#nullable enable #nullable enable
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Client.Models;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Models; using BTCPayServer.Models;
using BTCPayServer.Models.StoreViewModels; using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Client.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NBitcoin; using NBitcoin;
using NBitcoin.DataEncoders; using NBitcoin.DataEncoders;
@@ -30,7 +30,8 @@ namespace BTCPayServer.Controllers
var webhooks = await _Repo.GetWebhooks(CurrentStore.Id); var webhooks = await _Repo.GetWebhooks(CurrentStore.Id);
return View(nameof(Webhooks), new WebhooksViewModel() return View(nameof(Webhooks), new WebhooksViewModel()
{ {
Webhooks = webhooks.Select(async w => { Webhooks = webhooks.Select(async w =>
{
var lastDelivery = await LastDeliveryForWebhook(w.Id); var lastDelivery = await LastDeliveryForWebhook(w.Id);
var lastDeliveryBlob = lastDelivery?.GetBlob(); var lastDeliveryBlob = lastDelivery?.GetBlob();
@@ -135,9 +136,12 @@ namespace BTCPayServer.Controllers
{ {
var result = await WebhookNotificationManager.TestWebhook(CurrentStore.Id, webhookId, viewModel.Type); var result = await WebhookNotificationManager.TestWebhook(CurrentStore.Id, webhookId, viewModel.Type);
if (result.Success) { if (result.Success)
{
TempData[WellKnownTempData.SuccessMessage] = $"{viewModel.Type.ToString()} event delivered successfully! Delivery ID is {result.DeliveryId}"; TempData[WellKnownTempData.SuccessMessage] = $"{viewModel.Type.ToString()} event delivered successfully! Delivery ID is {result.DeliveryId}";
} else { }
else
{
TempData[WellKnownTempData.ErrorMessage] = $"{viewModel.Type.ToString()} event could not be delivered. Error message received: {(result.ErrorMessage ?? "unknown")}"; TempData[WellKnownTempData.ErrorMessage] = $"{viewModel.Type.ToString()} event could not be delivered. Error message received: {(result.ErrorMessage ?? "unknown")}";
} }

View File

@@ -5,6 +5,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Abstractions.Models; using BTCPayServer.Abstractions.Models;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.HostedServices; using BTCPayServer.HostedServices;
using BTCPayServer.ModelBinders; using BTCPayServer.ModelBinders;
using BTCPayServer.Models; using BTCPayServer.Models;
@@ -13,7 +14,6 @@ using BTCPayServer.Payments.PayJoin.Sender;
using BTCPayServer.Services; using BTCPayServer.Services;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NBitcoin; using NBitcoin;
using BTCPayServer.BIP78.Sender;
using NBitcoin.Payment; using NBitcoin.Payment;
using NBXplorer; using NBXplorer;
using NBXplorer.Models; using NBXplorer.Models;

View File

@@ -7,13 +7,16 @@ using System.Threading.Tasks;
using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Constants;
using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Abstractions.Models; using BTCPayServer.Abstractions.Models;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.Client; using BTCPayServer.Client;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.HostedServices; using BTCPayServer.HostedServices;
using BTCPayServer.ModelBinders; using BTCPayServer.ModelBinders;
using BTCPayServer.Models; using BTCPayServer.Models;
using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Models.WalletViewModels; using BTCPayServer.Models.WalletViewModels;
using BTCPayServer.Payments; using BTCPayServer.Payments;
using BTCPayServer.Payments.PayJoin;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Services.Labels; using BTCPayServer.Services.Labels;
using BTCPayServer.Services.Rates; using BTCPayServer.Services.Rates;
@@ -23,9 +26,6 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NBitcoin; using NBitcoin;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Payments.PayJoin;
using NBXplorer; using NBXplorer;
using NBXplorer.DerivationStrategy; using NBXplorer.DerivationStrategy;
using NBXplorer.Models; using NBXplorer.Models;
@@ -177,7 +177,8 @@ namespace BTCPayServer.Controllers
allColors allColors
.GroupBy(k => k) .GroupBy(k => k)
.OrderBy(k => k.Count()) .OrderBy(k => k.Count())
.ThenBy(k => { .ThenBy(k =>
{
var indexInColorScheme = Array.IndexOf(LabelColorScheme, k.Key); var indexInColorScheme = Array.IndexOf(LabelColorScheme, k.Key);
// Ensures that any label color which may not be in our label color scheme is given the least priority // Ensures that any label color which may not be in our label color scheme is given the least priority

View File

@@ -106,7 +106,8 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
var res = raw.ToObject<PayoutTransactionOnChainBlob>( var res = raw.ToObject<PayoutTransactionOnChainBlob>(
JsonSerializer.Create(_jsonSerializerSettings.GetSerializer(paymentMethodId.CryptoCode))); JsonSerializer.Create(_jsonSerializerSettings.GetSerializer(paymentMethodId.CryptoCode)));
var network = _btcPayNetworkProvider.GetNetwork<BTCPayNetwork>(paymentMethodId.CryptoCode); var network = _btcPayNetworkProvider.GetNetwork<BTCPayNetwork>(paymentMethodId.CryptoCode);
if (res == null) return null; if (res == null)
return null;
res.LinkTemplate = network.BlockExplorerLink; res.LinkTemplate = network.BlockExplorerLink;
return res; return res;
} }
@@ -392,7 +393,8 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
var proof = ParseProof(payout) as PayoutTransactionOnChainBlob ?? var proof = ParseProof(payout) as PayoutTransactionOnChainBlob ??
new PayoutTransactionOnChainBlob() { Accounted = isInternal }; new PayoutTransactionOnChainBlob() { Accounted = isInternal };
var txId = newTransaction.NewTransactionEvent.TransactionData.TransactionHash; var txId = newTransaction.NewTransactionEvent.TransactionData.TransactionHash;
if (!proof.Candidates.Add(txId)) return; if (!proof.Candidates.Add(txId))
return;
if (isInternal) if (isInternal)
{ {
payout.State = PayoutState.InProgress; payout.State = PayoutState.InProgress;

View File

@@ -5,8 +5,8 @@ using BTCPayServer.Abstractions.Models;
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Payments; using BTCPayServer.Payments;
using PayoutData = BTCPayServer.Data.PayoutData;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using PayoutData = BTCPayServer.Data.PayoutData;
using StoreData = BTCPayServer.Data.StoreData; using StoreData = BTCPayServer.Data.StoreData;
public interface IPayoutHandler public interface IPayoutHandler

View File

@@ -1,4 +1,4 @@
namespace BTCPayServer.Data.Payouts.LightningLike namespace BTCPayServer.Data.Payouts.LightningLike
{ {
public class LNURLPayClaimDestinaton : ILightningLikeLikeClaimDestination public class LNURLPayClaimDestinaton : ILightningLikeLikeClaimDestination
{ {

View File

@@ -76,7 +76,8 @@ namespace BTCPayServer.Data.Payouts.LightningLike
.ToListAsync()) .ToListAsync())
.Where(payout => .Where(payout =>
{ {
if (approvedStores.TryGetValue(payout.PullPaymentData.StoreId, out var value)) return value; if (approvedStores.TryGetValue(payout.PullPaymentData.StoreId, out var value))
return value;
value = payout.PullPaymentData.StoreData.UserStores value = payout.PullPaymentData.StoreData.UserStores
.Any(store => store.Role == StoreRoles.Owner && store.ApplicationUserId == userId); .Any(store => store.Role == StoreRoles.Owner && store.ApplicationUserId == userId);
approvedStores.Add(payout.PullPaymentData.StoreId, value); approvedStores.Add(payout.PullPaymentData.StoreId, value);
@@ -98,7 +99,9 @@ namespace BTCPayServer.Data.Payouts.LightningLike
return new ConfirmVM() return new ConfirmVM()
{ {
Amount = blob.CryptoAmount.Value, Destination = blob.Destination, PayoutId = payoutData.Id Amount = blob.CryptoAmount.Value,
Destination = blob.Destination,
PayoutId = payoutData.Id
}; };
}).ToList(); }).ToList();
return View(vm); return View(vm);
@@ -136,7 +139,9 @@ namespace BTCPayServer.Data.Payouts.LightningLike
{ {
results.Add(new ResultVM() results.Add(new ResultVM()
{ {
PayoutId = payoutData.Id, Result = result.Result, Destination = payoutBlob.Destination PayoutId = payoutData.Id,
Result = result.Result,
Destination = payoutBlob.Destination
}); });
payoutData.State = PayoutState.Completed; payoutData.State = PayoutState.Completed;
} }
@@ -144,7 +149,9 @@ namespace BTCPayServer.Data.Payouts.LightningLike
{ {
results.Add(new ResultVM() results.Add(new ResultVM()
{ {
PayoutId = payoutData.Id, Result = result.Result, Destination = payoutBlob.Destination PayoutId = payoutData.Id,
Result = result.Result,
Destination = payoutBlob.Destination
}); });
} }
} }
@@ -249,7 +256,9 @@ namespace BTCPayServer.Data.Payouts.LightningLike
{ {
results.Add(new ResultVM() results.Add(new ResultVM()
{ {
PayoutId = payoutData.Id, Result = PayResult.Error, Destination = blob.Destination PayoutId = payoutData.Id,
Result = PayResult.Error,
Destination = blob.Destination
}); });
} }
} }

View File

@@ -92,7 +92,8 @@ namespace BTCPayServer.Data.Payouts.LightningLike
? new BoltInvoiceClaimDestination(destination, invoice) ? new BoltInvoiceClaimDestination(destination, invoice)
: null; : null;
if (result == null) return (null, "A valid BOLT11 invoice (with 30+ day expiry) or LNURL Pay or Lightning address was not provided."); if (result == null)
return (null, "A valid BOLT11 invoice (with 30+ day expiry) or LNURL Pay or Lightning address was not provided.");
if (validate && (invoice.ExpiryDate.UtcDateTime - DateTime.UtcNow).Days < 30) if (validate && (invoice.ExpiryDate.UtcDateTime - DateTime.UtcNow).Days < 30)
{ {
return (null, return (null,
@@ -150,7 +151,8 @@ namespace BTCPayServer.Data.Payouts.LightningLike
foreach (UserStore storeDataUserStore in storeData.UserStores) foreach (UserStore storeDataUserStore in storeData.UserStores)
{ {
if (!await _userService.IsAdminUser(storeDataUserStore.ApplicationUserId)) continue; if (!await _userService.IsAdminUser(storeDataUserStore.ApplicationUserId))
continue;
result.Add(supportedPaymentMethod.PaymentId); result.Add(supportedPaymentMethod.PaymentId);
break; break;
} }

View File

@@ -4,11 +4,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BTCPayServer.Payments; using BTCPayServer.Payments;
using BTCPayServer.Payments.Lightning;
using BTCPayServer.Services.Rates; using BTCPayServer.Services.Rates;
using NBitcoin; using NBitcoin;
using NBXplorer; using NBXplorer;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using BTCPayServer.Payments.Lightning;
namespace BTCPayServer.Data namespace BTCPayServer.Data
{ {

View File

@@ -1,4 +1,4 @@
using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Invoices;
namespace BTCPayServer.Events namespace BTCPayServer.Events
{ {

View File

@@ -12,6 +12,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Abstractions.Models; using BTCPayServer.Abstractions.Models;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.Configuration; using BTCPayServer.Configuration;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Lightning; using BTCPayServer.Lightning;
@@ -29,7 +30,6 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NBitcoin; using NBitcoin;
using BTCPayServer.BIP78.Sender;
using NBitcoin.Payment; using NBitcoin.Payment;
using NBitpayClient; using NBitpayClient;
using NBXplorer.DerivationStrategy; using NBXplorer.DerivationStrategy;

View File

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

View File

@@ -12,7 +12,8 @@ namespace BTCPayServer
{ {
return input.Substring(0, input.Length - suffixToRemove.Length); return input.Substring(0, input.Length - suffixToRemove.Length);
} }
else return input; else
return input;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Linq; using System.Linq;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Invoices;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;

View File

@@ -50,7 +50,8 @@ namespace BTCPayServer.Fido2
// 3. Create options // 3. Create options
var authenticatorSelection = new AuthenticatorSelection var authenticatorSelection = new AuthenticatorSelection
{ {
RequireResidentKey = false, UserVerification = UserVerificationRequirement.Preferred RequireResidentKey = false,
UserVerification = UserVerificationRequirement.Preferred
}; };
var exts = new AuthenticationExtensionsClientInputs() var exts = new AuthenticationExtensionsClientInputs()
@@ -61,7 +62,8 @@ namespace BTCPayServer.Fido2
UserVerificationMethod = true, UserVerificationMethod = true,
BiometricAuthenticatorPerformanceBounds = new AuthenticatorBiometricPerfBounds BiometricAuthenticatorPerformanceBounds = new AuthenticatorBiometricPerfBounds
{ {
FAR = float.MaxValue, FRR = float.MaxValue FAR = float.MaxValue,
FRR = float.MaxValue
}, },
}; };
@@ -183,7 +185,8 @@ namespace BTCPayServer.Fido2
return options; return options;
} }
public async Task<bool> CompleteLogin(string userId, AuthenticatorAssertionRawResponse response){ public async Task<bool> CompleteLogin(string userId, AuthenticatorAssertionRawResponse response)
{
await using var dbContext = _contextFactory.CreateContext(); await using var dbContext = _contextFactory.CreateContext();
var user = await dbContext.Users.Include(applicationUser => applicationUser.Fido2Credentials) var user = await dbContext.Users.Include(applicationUser => applicationUser.Fido2Credentials)
.FirstOrDefaultAsync(applicationUser => applicationUser.Id == userId); .FirstOrDefaultAsync(applicationUser => applicationUser.Id == userId);

View File

@@ -40,7 +40,8 @@ namespace BTCPayServer.Fido2
} }
public string Verify(string code) public string Verify(string code)
{ {
if (!_memoryCache.TryGetValue(code, out var userId)) return null; if (!_memoryCache.TryGetValue(code, out var userId))
return null;
_memoryCache.Remove(GetCacheKey((string)userId)); _memoryCache.Remove(GetCacheKey((string)userId));
_memoryCache.Remove(code); _memoryCache.Remove(code);
return (string)userId; return (string)userId;

View File

@@ -1,10 +1,10 @@
using System; using System;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.ActionConstraints;
using BTCPayServer.Services; using BTCPayServer.Services;
using Microsoft.AspNetCore.Mvc.ActionConstraints;
using Microsoft.Extensions.DependencyInjection;
namespace BTCPayServer.Filters namespace BTCPayServer.Filters
{ {

View File

@@ -44,7 +44,8 @@ namespace BTCPayServer.Filters
return true; return true;
} }
if (AppType == policies.RootAppType) { if (AppType == policies.RootAppType)
{
context.RouteContext.RouteData.Values.Add("appId", policies.RootAppId); context.RouteContext.RouteData.Values.Add("appId", policies.RootAppId);
return true; return true;

View File

@@ -8,8 +8,8 @@ using BTCPayServer.Data;
using BTCPayServer.Logging; using BTCPayServer.Logging;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Invoices;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace BTCPayServer.HostedServices namespace BTCPayServer.HostedServices
{ {

View File

@@ -6,8 +6,8 @@ using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Abstractions.Models; using BTCPayServer.Abstractions.Models;
using BTCPayServer.Abstractions.Services; using BTCPayServer.Abstractions.Services;
using BTCPayServer.Common;
using BTCPayServer.Client; using BTCPayServer.Client;
using BTCPayServer.Common;
using BTCPayServer.Configuration; using BTCPayServer.Configuration;
using BTCPayServer.Controllers; using BTCPayServer.Controllers;
using BTCPayServer.Controllers.GreenField; using BTCPayServer.Controllers.GreenField;
@@ -51,12 +51,12 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using NBitcoin; using NBitcoin;
using NBitcoin.RPC;
using NBitpayClient; using NBitpayClient;
using NBXplorer.DerivationStrategy; using NBXplorer.DerivationStrategy;
using Newtonsoft.Json; using Newtonsoft.Json;
using NicolasDorier.RateLimits; using NicolasDorier.RateLimits;
using Serilog; using Serilog;
using NBitcoin.RPC;
#if ALTCOINS #if ALTCOINS
using BTCPayServer.Services.Altcoins.Monero; using BTCPayServer.Services.Altcoins.Monero;
#endif #endif

View File

@@ -545,12 +545,16 @@ retry:
null when paymentMethodId.PaymentType == LightningPaymentType.Instance && null when paymentMethodId.PaymentType == LightningPaymentType.Instance &&
lightningMaxValue != null => new PaymentMethodCriteria() lightningMaxValue != null => new PaymentMethodCriteria()
{ {
Above = false, PaymentMethod = paymentMethodId, Value = lightningMaxValue Above = false,
PaymentMethod = paymentMethodId,
Value = lightningMaxValue
}, },
null when paymentMethodId.PaymentType == BitcoinPaymentType.Instance && null when paymentMethodId.PaymentType == BitcoinPaymentType.Instance &&
onChainMinValue != null => new PaymentMethodCriteria() onChainMinValue != null => new PaymentMethodCriteria()
{ {
Above = true, PaymentMethod = paymentMethodId, Value = onChainMinValue Above = true,
PaymentMethod = paymentMethodId,
Value = onChainMinValue
}, },
_ => new PaymentMethodCriteria() _ => new PaymentMethodCriteria()
{ {

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using BTCPayServer.Configuration; using BTCPayServer.Configuration;
using BTCPayServer.Controllers.GreenField;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Fido2; using BTCPayServer.Fido2;
using BTCPayServer.Filters; using BTCPayServer.Filters;
@@ -13,15 +14,16 @@ using BTCPayServer.Plugins;
using BTCPayServer.Security; using BTCPayServer.Security;
using BTCPayServer.Services.Apps; using BTCPayServer.Services.Apps;
using BTCPayServer.Storage; using BTCPayServer.Storage;
using Fido2NetLib;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Fido2NetLib;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@@ -30,8 +32,6 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
using Microsoft.AspNetCore.Mvc;
using BTCPayServer.Controllers.GreenField;
namespace BTCPayServer.Hosting namespace BTCPayServer.Hosting
{ {

View File

@@ -26,8 +26,8 @@ using BTCPayServer.Services.Stores;
using LNURL; using LNURL;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Routing;
using NBitcoin; using NBitcoin;
using NBitcoin.Crypto; using NBitcoin.Crypto;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -340,7 +340,8 @@ namespace BTCPayServer
{ {
return BadRequest(new LNUrlStatusResponse return BadRequest(new LNUrlStatusResponse
{ {
Status = "ERROR", Reason = "Amount is out of bounds." Status = "ERROR",
Reason = "Amount is out of bounds."
}); });
} }
@@ -404,7 +405,9 @@ namespace BTCPayServer
paymentMethodDetails, pmi)); paymentMethodDetails, pmi));
return Ok(new LNURLPayRequest.LNURLPayRequestCallbackResponse return Ok(new LNURLPayRequest.LNURLPayRequestCallbackResponse
{ {
Disposable = true, Routes = Array.Empty<string>(), Pr = paymentMethodDetails.BOLT11 Disposable = true,
Routes = Array.Empty<string>(),
Pr = paymentMethodDetails.BOLT11
}); });
} }
@@ -419,7 +422,9 @@ namespace BTCPayServer
return Ok(new LNURLPayRequest.LNURLPayRequestCallbackResponse return Ok(new LNURLPayRequest.LNURLPayRequestCallbackResponse
{ {
Disposable = true, Routes = Array.Empty<string>(), Pr = paymentMethodDetails.BOLT11 Disposable = true,
Routes = Array.Empty<string>(),
Pr = paymentMethodDetails.BOLT11
}); });
} }
@@ -439,7 +444,8 @@ namespace BTCPayServer
return BadRequest(new LNUrlStatusResponse return BadRequest(new LNUrlStatusResponse
{ {
Status = "ERROR", Reason = "Invoice not in a valid payable state" Status = "ERROR",
Reason = "Invoice not in a valid payable state"
}); });
} }

View File

@@ -2,9 +2,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using BTCPayServer.Services.Apps;
using BTCPayServer.Validation; using BTCPayServer.Validation;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using BTCPayServer.Services.Apps;
namespace BTCPayServer.Models.InvoicingModels namespace BTCPayServer.Models.InvoicingModels
{ {

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using BTCPayServer.Abstractions.Extensions;
using System.Linq; using System.Linq;
using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Payments; using BTCPayServer.Payments;

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using NBitcoin;
using BTCPayServer; using BTCPayServer;
using NBitcoin;
namespace BTCPayServer.Models.WalletViewModels namespace BTCPayServer.Models.WalletViewModels
{ {

View File

@@ -5,6 +5,7 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Client.Models;
using BTCPayServer.Configuration; using BTCPayServer.Configuration;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.HostedServices; using BTCPayServer.HostedServices;
@@ -12,7 +13,6 @@ using BTCPayServer.Lightning;
using BTCPayServer.Logging; using BTCPayServer.Logging;
using BTCPayServer.Models; using BTCPayServer.Models;
using BTCPayServer.Models.InvoicingModels; using BTCPayServer.Models.InvoicingModels;
using BTCPayServer.Client.Models;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Rates; using BTCPayServer.Services.Rates;
@@ -67,7 +67,8 @@ namespace BTCPayServer.Payments.Lightning
return new LNURLPayPaymentMethodDetails() return new LNURLPayPaymentMethodDetails()
{ {
Activated = false, LightningSupportedPaymentMethod = lnSupported Activated = false,
LightningSupportedPaymentMethod = lnSupported
}; };
} }

View File

@@ -1,4 +1,4 @@
using BTCPayServer.Client.JsonConverters; using BTCPayServer.Client.JsonConverters;
using BTCPayServer.Lightning; using BTCPayServer.Lightning;
using BTCPayServer.Payments.Lightning; using BTCPayServer.Payments.Lightning;
using Newtonsoft.Json; using Newtonsoft.Json;

View File

@@ -5,6 +5,7 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Client.Models;
using BTCPayServer.Configuration; using BTCPayServer.Configuration;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.HostedServices; using BTCPayServer.HostedServices;
@@ -12,7 +13,6 @@ using BTCPayServer.Lightning;
using BTCPayServer.Logging; using BTCPayServer.Logging;
using BTCPayServer.Models; using BTCPayServer.Models;
using BTCPayServer.Models.InvoicingModels; using BTCPayServer.Models.InvoicingModels;
using BTCPayServer.Client.Models;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Rates; using BTCPayServer.Services.Rates;
@@ -59,7 +59,8 @@ namespace BTCPayServer.Payments.Lightning
{ {
throw new PaymentMethodUnavailableException("BOLT11 payment method is disabled"); throw new PaymentMethodUnavailableException("BOLT11 payment method is disabled");
} }
if (paymentMethod.ParentEntity.Type == InvoiceType.TopUp) { if (paymentMethod.ParentEntity.Type == InvoiceType.TopUp)
{
throw new PaymentMethodUnavailableException("Lightning Network payment method is not available for top-up invoices"); throw new PaymentMethodUnavailableException("Lightning Network payment method is not available for top-up invoices");
} }

View File

@@ -1,9 +1,9 @@
using BTCPayServer.BIP78.Sender;
using BTCPayServer.HostedServices; using BTCPayServer.HostedServices;
using BTCPayServer.Payments.PayJoin.Sender; using BTCPayServer.Payments.PayJoin.Sender;
using BTCPayServer.Services; using BTCPayServer.Services;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using BTCPayServer.BIP78.Sender;
namespace BTCPayServer.Payments.PayJoin namespace BTCPayServer.Payments.PayJoin
{ {

View File

@@ -1,11 +1,11 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.Client.Models;
using BTCPayServer.Payments.Bitcoin; using BTCPayServer.Payments.Bitcoin;
using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Invoices;
using NBitcoin; using NBitcoin;
using BTCPayServer.BIP78.Sender;
using BTCPayServer.Client.Models;
using NBitpayClient; using NBitpayClient;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using InvoiceCryptoInfo = BTCPayServer.Services.Invoices.InvoiceCryptoInfo; using InvoiceCryptoInfo = BTCPayServer.Services.Invoices.InvoiceCryptoInfo;

View File

@@ -9,7 +9,8 @@ namespace BTCPayServer.Plugins.Shopify.ApiModels
public ScriptTag ScriptTag { get; set; } public ScriptTag ScriptTag { get; set; }
} }
public class ScriptTag { public class ScriptTag
{
[JsonProperty("id")] [JsonProperty("id")]
public int Id { get; set; } public int Id { get; set; }

View File

@@ -111,7 +111,8 @@ namespace BTCPayServer.Plugins.Shopify
var invoiceOrderId = $"{ShopifyOrderMarkerHostedService.SHOPIFY_ORDER_ID_PREFIX}{orderId}"; var invoiceOrderId = $"{ShopifyOrderMarkerHostedService.SHOPIFY_ORDER_ID_PREFIX}{orderId}";
var matchedExistingInvoices = await _invoiceRepository.GetInvoices(new InvoiceQuery() var matchedExistingInvoices = await _invoiceRepository.GetInvoices(new InvoiceQuery()
{ {
OrderId = new[] {invoiceOrderId}, StoreId = new[] {storeId} OrderId = new[] { invoiceOrderId },
StoreId = new[] { storeId }
}); });
matchedExistingInvoices = matchedExistingInvoices.Where(entity => matchedExistingInvoices = matchedExistingInvoices.Where(entity =>
entity.GetInternalTags(ShopifyOrderMarkerHostedService.SHOPIFY_ORDER_ID_PREFIX) entity.GetInternalTags(ShopifyOrderMarkerHostedService.SHOPIFY_ORDER_ID_PREFIX)

View File

@@ -164,9 +164,12 @@ namespace BTCPayServer.Security
_httpContext.SetStoreData(store); _httpContext.SetStoreData(store);
// cache associated entities if present // cache associated entities if present
if (app != null) _httpContext.SetAppData(app); if (app != null)
if (invoice != null) _httpContext.SetInvoiceData(invoice); _httpContext.SetAppData(app);
if (paymentRequest != null) _httpContext.SetPaymentRequestData(paymentRequest); if (invoice != null)
_httpContext.SetInvoiceData(invoice);
if (paymentRequest != null)
_httpContext.SetPaymentRequestData(paymentRequest);
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.AspNetCore.Razor.TagHelpers;

View File

@@ -59,67 +59,80 @@ namespace BTCPayServer.Services.Invoices
set => SetMetadata("paymentRequestId", value); set => SetMetadata("paymentRequestId", value);
} }
[JsonIgnore] [JsonIgnore]
public string BuyerName{ public string BuyerName
{
get => GetMetadata<string>("buyerName"); get => GetMetadata<string>("buyerName");
set => SetMetadata("buyerName", value); set => SetMetadata("buyerName", value);
} }
[JsonIgnore] [JsonIgnore]
public string BuyerEmail { public string BuyerEmail
{
get => GetMetadata<string>("buyerEmail"); get => GetMetadata<string>("buyerEmail");
set => SetMetadata("buyerEmail", value); set => SetMetadata("buyerEmail", value);
} }
[JsonIgnore] [JsonIgnore]
public string BuyerCountry { public string BuyerCountry
{
get => GetMetadata<string>("buyerCountry"); get => GetMetadata<string>("buyerCountry");
set => SetMetadata("buyerCountry", value); set => SetMetadata("buyerCountry", value);
} }
[JsonIgnore] [JsonIgnore]
public string BuyerZip { public string BuyerZip
{
get => GetMetadata<string>("buyerZip"); get => GetMetadata<string>("buyerZip");
set => SetMetadata("buyerZip", value); set => SetMetadata("buyerZip", value);
} }
[JsonIgnore] [JsonIgnore]
public string BuyerState{ public string BuyerState
{
get => GetMetadata<string>("buyerState"); get => GetMetadata<string>("buyerState");
set => SetMetadata("buyerState", value); set => SetMetadata("buyerState", value);
} }
[JsonIgnore] [JsonIgnore]
public string BuyerCity { public string BuyerCity
{
get => GetMetadata<string>("buyerCity"); get => GetMetadata<string>("buyerCity");
set => SetMetadata("buyerCity", value); set => SetMetadata("buyerCity", value);
} }
[JsonIgnore] [JsonIgnore]
public string BuyerAddress2{ public string BuyerAddress2
{
get => GetMetadata<string>("buyerAddress2"); get => GetMetadata<string>("buyerAddress2");
set => SetMetadata("buyerAddress2", value); set => SetMetadata("buyerAddress2", value);
} }
[JsonIgnore] [JsonIgnore]
public string BuyerAddress1 { public string BuyerAddress1
{
get => GetMetadata<string>("buyerAddress1"); get => GetMetadata<string>("buyerAddress1");
set => SetMetadata("buyerAddress1", value); set => SetMetadata("buyerAddress1", value);
} }
[JsonIgnore] [JsonIgnore]
public string BuyerPhone { public string BuyerPhone
{
get => GetMetadata<string>("buyerPhone"); get => GetMetadata<string>("buyerPhone");
set => SetMetadata("buyerPhone", value); set => SetMetadata("buyerPhone", value);
} }
[JsonIgnore] [JsonIgnore]
public string ItemDesc { public string ItemDesc
{
get => GetMetadata<string>("itemDesc"); get => GetMetadata<string>("itemDesc");
set => SetMetadata("itemDesc", value); set => SetMetadata("itemDesc", value);
} }
[JsonIgnore] [JsonIgnore]
public string ItemCode{ public string ItemCode
{
get => GetMetadata<string>("itemCode"); get => GetMetadata<string>("itemCode");
set => SetMetadata("itemCode", value); set => SetMetadata("itemCode", value);
} }
[JsonIgnore] [JsonIgnore]
public bool? Physical { public bool? Physical
{
get => GetMetadata<bool?>("physical"); get => GetMetadata<bool?>("physical");
set => SetMetadata("physical", value); set => SetMetadata("physical", value);
} }
[JsonIgnore] [JsonIgnore]
public decimal? TaxIncluded { public decimal? TaxIncluded
{
get => GetMetadata<decimal?>("taxIncluded"); get => GetMetadata<decimal?>("taxIncluded");
set => SetMetadata("taxIncluded", value); set => SetMetadata("taxIncluded", value);
} }
@@ -134,7 +147,8 @@ namespace BTCPayServer.Services.Invoices
public T GetMetadata<T>(string propName) public T GetMetadata<T>(string propName)
{ {
if (AdditionalData == null || !(AdditionalData.TryGetValue(propName, out var jt) is true)) return default; if (AdditionalData == null || !(AdditionalData.TryGetValue(propName, out var jt) is true))
return default;
if (jt.Type == JTokenType.Null) if (jt.Type == JTokenType.Null)
return default; return default;
if (typeof(T) == typeof(string)) if (typeof(T) == typeof(string))

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;

View File

@@ -1,12 +1,12 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Net; using System.Net;
using Newtonsoft.Json;
using MailKit.Net.Smtp;
using MimeKit;
using System.Threading.Tasks;
using System.Threading;
using System.Net.Security; using System.Net.Security;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
using MailKit.Net.Smtp;
using MimeKit;
using Newtonsoft.Json;
namespace BTCPayServer.Services.Mails namespace BTCPayServer.Services.Mails
{ {

View File

@@ -32,7 +32,8 @@ namespace BTCPayServer.Services.Mails
return emailSettings; return emailSettings;
} }
if (FallbackSender != null) return await FallbackSender?.GetEmailSettings(); if (FallbackSender != null)
return await FallbackSender?.GetEmailSettings();
return null; return null;
} }
} }

View File

@@ -42,7 +42,10 @@ namespace BTCPayServer.Services.Notifications
{ {
var resp = await GetNotifications(new NotificationsQuery() var resp = await GetNotifications(new NotificationsQuery()
{ {
Seen = false, Skip = 0, Take = 5, UserId = userId Seen = false,
Skip = 0,
Take = 5,
UserId = userId
}); });
entry.SetAbsoluteExpiration(TimeSpan.FromMilliseconds(_cacheExpiryMs)); entry.SetAbsoluteExpiration(TimeSpan.FromMilliseconds(_cacheExpiryMs));
var res = new NotificationSummaryViewModel() { Last5 = resp.Items, UnseenCount = resp.Count }; var res = new NotificationSummaryViewModel() { Last5 = resp.Items, UnseenCount = resp.Count };

View File

@@ -3,11 +3,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Data;
using BTCPayServer.Services.Stores;
using BTCPayServer.Storage.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using BTCPayServer.Data;
using BTCPayServer.Storage.Services;
using BTCPayServer.Services.Stores;
namespace BTCPayServer.Services namespace BTCPayServer.Services
{ {