Harden invoice monitoring, subscription balances and API access (#7761)
What changed, and why it matters
This commit is a security hardening patch for BTCPay Server. It adds account lockout to password checks when users change their email or password, closes a JSON deserialization gap that could allow unexpected type information to be processed, limits how large Lightning payout responses can be, prevents subscription balances from growing beyond safe limits, and fixes invoice monitoring so it does not rely on stale invoice data while waiting for payments.
Treat this as a security hardening update and deploy promptly. Review whether any custom plugins or integrations rely on Newtonsoft.Json $type metadata deserialization, as the Ignore setting may break such flows. Monitor account lockout behavior for legitimate users entering wrong passwords.
Security signals we found
Account lockout now enforced on current-password verification for email and password changes
Newtonsoft.Json MetadataPropertyHandling.Ignore added to blob, metadata, store, and serializer settings
LNURL payout HTTP client response buffer capped at 256 KB
Subscription credit/charge bounded by GreenfieldConstants.MaxAmount in SQL, API, and UI
InvoiceWatcher.Wait refactored to avoid re-reading invoice entity during delayed waits
NBXplorer broadcast results cached and cleared on block/replacement events
LightningListener stores PaymentMethodId only, reducing held state
Evidence from the diff
The patch makes several defensive changes: (1) introduces CheckPasswordWithLockoutAsync to count failed password attempts toward ASP.NET Identity lockout for email/password changes in both UI and Greenfield API; (2) sets MetadataPropertyHandling.Ignore on multiple Newtonsoft.Json serializer settings to mitigate deserialization risks from $type metadata; (3) caps LNURL payout response buffer size at 256 KB; (4) enforces GreenfieldConstants.MaxAmount bounds on subscription credit/charge operations in SQL, controllers, and UI; (5) refactors InvoiceWatcher.Wait to use captured expiration values instead of re-fetching the InvoiceEntity, reducing race conditions; (6) caches NBXplorer broadcast results and clears the cache on new blocks or replacements to avoid redundant/replayed broadcasts; (7) changes LightningListener.ListenedInvoice to store PaymentMethodId instead of the full PaymentPrompt object, likely to avoid holding mutable or sensitive state.
Changed components
BTCPayServer/Controllers/GreenField/GreenfieldUsersController.csBTCPayServer/Controllers/UIManageController.csBTCPayServer/UserManagerExtensions.csBTCPayServer.Abstractions/CamelCaseSerializerSettings.csBTCPayServer/Data/BlobSerializer.csBTCPayServer/Data/IHasBlobExtensions.csBTCPayServer/Data/StoreDataExtensions.csBTCPayServer/Services/Invoices/InvoiceEntity.csBTCPayServer/Services/Stores/StoreRepository.csBTCPayServer/Data/Payouts/LightningLike/LightningLikePayoutHandler.csBTCPayServer/Hosting/BTCPayServerServices.csBTCPayServer/Plugins/Subscriptions/Controllers/GreenfieldOfferingController.csBTCPayServer/Plugins/Subscriptions/Controllers/UIOfferingController.csBTCPayServer/Plugins/Subscriptions/SubscriptionContext.csBTCPayServer/HostedServices/InvoiceWatcher.csBTCPayServer/Payments/Bitcoin/NBXplorerListener.csBTCPayServer/Payments/Lightning/LightningListener.csInspect captured patch +122 / −34
### BTCPayServer.Abstractions/CamelCaseSerializerSettings.cs
@@ -8,7 +8,8 @@ static CamelCaseSerializerSettings()
{
Settings = new JsonSerializerSettings()
{
- ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
+ ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(),
+ MetadataPropertyHandling = MetadataPropertyHandling.Ignore
};
Serializer = JsonSerializer.Create(Settings);
}
### BTCPayServer/Controllers/GreenField/GreenfieldUsersController.cs
@@ -174,8 +174,7 @@ public async Task<IActionResult> UpdateCurrentUser(UpdateApplicationUserRequest
var email = user.Email;
var setNewEmail = !string.IsNullOrEmpty(request.Email) && request.Email != email && ModelState.IsValid;
var currentPasswordValid = (setNewPassword || setNewEmail)
- && !string.IsNullOrEmpty(request.CurrentPassword)
- && await _userManager.CheckPasswordAsync(user, request.CurrentPassword);
+ && await _userManager.CheckPasswordWithLockoutAsync(user, request.CurrentPassword);
if ((setNewPassword || setNewEmail) && !currentPasswordValid)
{
ModelState.AddModelError(nameof(request.CurrentPassword), "The current password is not correct.");
### BTCPayServer/Controllers/UIManageController.cs
@@ -145,8 +145,7 @@ public async Task<IActionResult> Index(IndexViewModel model, [FromForm] bool Rem
bool needUpdate = false;
var email = user.Email;
var setNewEmail = model.Email != email && ModelState.IsValid;
- if (setNewEmail && (string.IsNullOrEmpty(model.CurrentPassword) ||
- !await _userManager.CheckPasswordAsync(user, model.CurrentPassword)))
+ if (setNewEmail && !await _userManager.CheckPasswordWithLockoutAsync(user, model.CurrentPassword))
{
ModelState.AddModelError(nameof(model.CurrentPassword), StringLocalizer["The current password is not correct."].Value);
return View(await GetIndexViewModel(user, model));
@@ -278,6 +277,12 @@ public async Task<IActionResult> ChangePassword(ChangePasswordViewModel model)
if (user == null)
return NotFound();
+ if (!await _userManager.CheckPasswordWithLockoutAsync(user, model.OldPassword))
+ {
+ ModelState.AddModelError(nameof(model.OldPassword), StringLocalizer["The current password is not correct."].Value);
+ return View(model);
+ }
+
var changePasswordResult = await _userManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword);
if (!changePasswordResult.Succeeded)
{
### BTCPayServer/Data/BlobSerializer.cs
@@ -36,6 +36,7 @@ private static JsonSerializerSettings CreateSettings()
Formatting = Formatting.None,
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore,
+ MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
};
return settings;
}
### BTCPayServer/Data/IHasBlobExtensions.cs
@@ -15,7 +15,8 @@ static IHasBlobExtensions()
DefaultSerializerSettings = new JsonSerializerSettings()
{
ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(),
- Formatting = Formatting.None
+ Formatting = Formatting.None,
+ MetadataPropertyHandling = MetadataPropertyHandling.Ignore
};
NBitcoin.JsonConverters.Serializer.RegisterFrontConverters(DefaultSerializerSettings);
DefaultSerializer = JsonSerializer.CreateDefault(DefaultSerializerSettings);
### BTCPayServer/Data/Payouts/LightningLike/LightningLikePayoutHandler.cs
@@ -37,6 +37,7 @@ public class LightningLikePayoutHandler : IPayoutHandler, IHasNetwork
public const string LightningLikePayoutHandlerClearnetNamedClient =
nameof(LightningLikePayoutHandlerClearnetNamedClient);
+ public const int MaxLNURLResponseSize = 256 * 1024;
private readonly IHttpClientFactory _httpClientFactory;
public LightningLikePayoutHandler(
### BTCPayServer/Data/StoreDataExtensions.cs
@@ -6,6 +6,7 @@
using BTCPayServer.Payments.Lightning;
using BTCPayServer.Services.Invoices;
using NBXplorer;
+using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace BTCPayServer.Data
@@ -43,7 +44,9 @@ public static void SetDefaultPaymentId(this StoreData storeData, PaymentMethodId
public static StoreBlob GetStoreBlob(this StoreData storeData)
{
ArgumentNullException.ThrowIfNull(storeData);
- var result = storeData.StoreBlob == null ? new StoreBlob() : new Serializer(null).ToObject<StoreBlob>(storeData.StoreBlob);
+ var serializer = new Serializer(null);
+ serializer.Settings.MetadataPropertyHandling = MetadataPropertyHandling.Ignore;
+ var result = storeData.StoreBlob == null ? new StoreBlob() : serializer.ToObject<StoreBlob>(storeData.StoreBlob);
if (result.PaymentMethodCriteria is null)
result.PaymentMethodCriteria = new List<PaymentMethodCriteria>();
result.PaymentMethodCriteria.RemoveAll(criteria => criteria?.PaymentMethod is null);
### BTCPayServer/HostedServices/InvoiceWatcher.cs
@@ -188,8 +188,8 @@ private void Watch(string invoiceId)
}
}
- private async Task Wait(string invoiceId, bool startup) => await Wait(await _invoiceRepository.GetInvoice(invoiceId), startup);
- private async Task Wait(InvoiceEntity invoice, bool startup)
+ private Task Wait(InvoiceEntity invoice, bool startup) => Wait(invoice.Id, invoice.ExpirationTime, invoice.MonitoringExpiration, startup);
+ private async Task Wait(string invoiceId, DateTimeOffset expirationTime, DateTimeOffset monitoringExpiration, bool startup)
{
var startupOffset = TimeSpan.Zero;
@@ -201,20 +201,20 @@ private async Task Wait(InvoiceEntity invoice, bool startup)
try
{
// add 1 second to ensure watch won't trigger moments before invoice expires
- var delay = (invoice.ExpirationTime.AddSeconds(1) + startupOffset) - DateTimeOffset.UtcNow;
+ var delay = (expirationTime.AddSeconds(1) + startupOffset) - DateTimeOffset.UtcNow;
if (delay > TimeSpan.Zero)
{
await Task.Delay(delay, _Cts.Token);
}
- Watch(invoice.Id);
+ Watch(invoiceId);
// add 1 second to ensure watch won't trigger moments before monitoring expires
- delay = invoice.MonitoringExpiration.AddSeconds(1) - DateTimeOffset.UtcNow;
+ delay = monitoringExpiration.AddSeconds(1) - DateTimeOffset.UtcNow;
if (delay > TimeSpan.Zero)
{
await Task.Delay(delay, _Cts.Token);
}
- Watch(invoice.Id);
+ Watch(invoiceId);
}
catch when (_Cts.IsCancellationRequested)
{ }
@@ -246,7 +246,7 @@ await _notificationSender.SendNotification(new StoreScope(b.Invoice.StoreId),
if (b.Name == InvoiceEvent.Created)
{
Watch(b.Invoice.Id);
- _ = Wait(b.Invoice.Id, false);
+ _ = Wait(b.Invoice, false);
}
if (b.Name == InvoiceEvent.ReceivedPayment)
@@ -259,8 +259,8 @@ await _notificationSender.SendNotification(new StoreScope(b.Invoice.StoreId),
private async Task WaitPendingInvoices()
{
- await Task.WhenAll((await GetPendingInvoices(_Cts.Token))
- .Select(i => Wait(i, true)).ToArray());
+ foreach (var invoice in await GetPendingInvoices(_Cts.Token))
+ _ = Wait(invoice, true);
}
private async Task<InvoiceEntity[]> GetPendingInvoices(CancellationToken cancellationToken)
### BTCPayServer/Hosting/BTCPayServerServices.cs
@@ -357,9 +357,11 @@ public static IServiceCollection AddBTCPayServer(this IServiceCollection service
services.AddSingleton<Dictionary<PaymentMethodId, ICheckoutModelExtension>>(o =>
o.GetRequiredService<IEnumerable<ICheckoutModelExtension>>().ToDictionary(o => o.PaymentMethodId, o => o));
- services.AddHttpClient(LightningLikePayoutHandler.LightningLikePayoutHandlerOnionNamedClient)
+ services.AddHttpClient(LightningLikePayoutHandler.LightningLikePayoutHandlerOnionNamedClient,
+ httpClient => httpClient.MaxResponseContentBufferSize = LightningLikePayoutHandler.MaxLNURLResponseSize)
.ConfigurePrimaryHttpMessageHandler<Socks5HttpClientHandler>();
- services.AddHttpClient(LightningLikePayoutHandler.LightningLikePayoutHandlerClearnetNamedClient)
+ services.AddHttpClient(LightningLikePayoutHandler.LightningLikePayoutHandlerClearnetNamedClient,
+ httpClient => httpClient.MaxResponseContentBufferSize = LightningLikePayoutHandler.MaxLNURLResponseSize)
.UseSSRFProtection();
services.AddSingleton<HostedServices.PullPaymentHostedService>();
services.AddSingleton<IHostedService, HostedServices.PullPaymentHostedService>(o => o.GetRequiredService<PullPaymentHostedService>());
### BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs
@@ -12,6 +12,7 @@
using BTCPayServer.Payments.PayJoin;
using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Wallets;
+using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NBitcoin;
@@ -25,7 +26,7 @@ namespace BTCPayServer.Payments.Bitcoin
/// <summary>
/// This class listener NBXplorer instances to detect incoming on-chain, bitcoin like payment
/// </summary>
- public class NBXplorerListener : IHostedService
+ public class NBXplorerListener : IHostedService, IDisposable
{
readonly EventAggregator _Aggregator;
private readonly UTXOLocker _utxoLocker;
@@ -36,6 +37,7 @@ public class NBXplorerListener : IHostedService
private TaskCompletionSource<bool> _RunningTask;
private CancellationTokenSource _Cts;
readonly BTCPayWalletProvider _Wallets;
+ private readonly MemoryCache _broadcastResults = new(new MemoryCacheOptions { SizeLimit = 10_000 });
public NBXplorerListener(ExplorerClientProvider explorerClients,
BTCPayWalletProvider wallets,
InvoiceRepository invoiceRepository,
@@ -148,10 +150,13 @@ private async Task Listen(BTCPayWallet wallet)
switch (newEvent)
{
case NBXplorer.Models.NewBlockEvent evt:
+ _broadcastResults.Clear();
await UpdatePaymentStates(wallet);
_Aggregator.Publish(new Events.NewBlockEvent() { PaymentMethodId = pmi, AdditionalInfo = evt });
break;
case NBXplorer.Models.NewTransactionEvent evt:
+ if (evt.Replacing is { Count: > 0 })
+ _broadcastResults.Clear();
if (evt.DerivationStrategy != null)
{
wallet.InvalidateCache(evt.DerivationStrategy);
@@ -267,7 +272,16 @@ async Task<InvoiceEntity> UpdatePaymentStates(BTCPayWallet wallet, InvoiceEntity
var explorerClient = _ExplorerClients.GetExplorerClient(wallet.Network);
try
{
- var result = await explorerClient.BroadcastAsync(tx.Transaction, testMempoolAccept: tx.Confirmations == -1, _Cts.Token);
+ var key = (wallet.Network.CryptoCode, tx.TransactionHash, tx.Confirmations);
+ if (!_broadcastResults.TryGetValue(key, out BroadcastResult result))
+ {
+ result = await explorerClient.BroadcastAsync(tx.Transaction, testMempoolAccept: tx.Confirmations == -1, _Cts.Token);
+ _broadcastResults.Set(key, result, new MemoryCacheEntryOptions
+ {
+ AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(1),
+ Size = 1
+ });
+ }
accounted = result.Success ||
result.RPCCode == RPCErrorCode.RPC_TRANSACTION_ALREADY_IN_CHAIN ||
!(
@@ -456,6 +470,8 @@ private async Task<InvoiceEntity> ReceivedPayment(BTCPayWallet wallet, InvoiceEn
_Aggregator.Publish(new InvoiceEvent(invoice, InvoiceEvent.ReceivedPayment) { Payment = payment });
return invoice;
}
+ public void Dispose() => _broadcastResults.Dispose();
+
public async Task StopAsync(CancellationToken cancellationToken)
{
if (_Cts != null)
### BTCPayServer/Payments/Lightning/LightningListener.cs
@@ -192,7 +192,7 @@ private List<ListenedInvoice> GetListenedInvoices(InvoiceEntity invoice)
listenedInvoices.Add(new ListenedInvoice(
invoice.MonitoringExpiration.AddSeconds(-1),
ligthningDetails,
- o.PaymentPrompt,
+ o.PaymentPrompt.PaymentMethodId,
((IHasNetwork)o.Handler).Network,
invoice.Id));
}
@@ -363,7 +363,7 @@ private async Task CreateNewLNInvoiceForBTCPayInvoice(InvoiceEntity invoice)
instanceListener.AddListenedInvoice(new ListenedInvoice(
invoice.MonitoringExpiration.AddSeconds(-1),
details,
- paymentPrompt,
+ paymentPrompt.PaymentMethodId,
network,
invoice.Id));
_Aggregator.Publish(new Events.InvoiceNewPaymentDetailsEvent(invoice.Id,
@@ -491,7 +491,7 @@ internal async Task PollPayment(ListenedInvoice listenedInvoice, CancellationTok
_ListenedInvoices.TryRemove(listenedInvoice.PaymentMethodDetails.InvoiceId, out _);
return;
}
- if (await AddPayment(lightningInvoice, listenedInvoice.InvoiceId, listenedInvoice.PaymentMethod.PaymentMethodId))
+ if (await AddPayment(lightningInvoice, listenedInvoice.InvoiceId, listenedInvoice.PaymentMethodId))
Logs.PayServer.LogInformation($"{_network.CryptoCode} (Lightning): Payment detected via polling on {listenedInvoice.InvoiceId}");
}
@@ -537,7 +537,7 @@ async Task Listen(CancellationToken cancellation)
var notification = await session.WaitInvoice(cancellation);
if (!_ListenedInvoices.TryGetValue(notification.Id, out var listenedInvoice))
continue;
- if (await AddPayment(notification, listenedInvoice.InvoiceId, listenedInvoice.PaymentMethod.PaymentMethodId))
+ if (await AddPayment(notification, listenedInvoice.InvoiceId, listenedInvoice.PaymentMethodId))
{
Logs.PayServer.LogInformation("{CryptoCode} (Lightning): Payment detected via notification ({InvoiceId})", _network.CryptoCode,
listenedInvoice.InvoiceId);
@@ -693,7 +693,7 @@ internal void RemoveExpiredInvoices()
public record ListenedInvoice(
DateTimeOffset Expiration,
LigthningPaymentPromptDetails PaymentMethodDetails,
- PaymentPrompt PaymentMethod,
+ PaymentMethodId PaymentMethodId,
BTCPayNetwork Network,
string InvoiceId)
{
### BTCPayServer/Plugins/Subscriptions/Controllers/GreenfieldOfferingController.cs
@@ -10,6 +10,7 @@
using BTCPayServer.Data.Subscriptions;
using BTCPayServer.ModelBinders;
using BTCPayServer.Security;
+using BTCPayServer.Security.Greenfield;
using BTCPayServer.Services.Apps;
using BTCPayServer.Services.Rates;
using BTCPayServer.Views.UIStoreMembership;
@@ -357,6 +358,10 @@ public async Task<IActionResult> UpdateCredit(string storeId, string offeringId,
var update = request ?? new UpdateCreditRequest();
if (update.Description?.Length > MaxCreditDescriptionLength)
ModelState.AddModelError(nameof(update.Description), $"Description must be at most {MaxCreditDescriptionLength} characters");
+ if (update.Credit is < 0m or > GreenfieldConstants.MaxAmount)
+ ModelState.AddModelError(nameof(update.Credit), $"Credit must be between 0 and {GreenfieldConstants.MaxAmount}");
+ if (update.Charge is < 0m or > GreenfieldConstants.MaxAmount)
+ ModelState.AddModelError(nameof(update.Charge), $"Charge must be between 0 and {GreenfieldConstants.MaxAmount}");
if (!ModelState.IsValid)
return this.CreateValidationError(ModelState);
var subscriber = await ctx.Subscribers.GetBySelector(offeringId, customerSelector, storeId);
@@ -373,7 +378,8 @@ public async Task<IActionResult> UpdateCredit(string storeId, string offeringId,
AllowOverdraft = update.AllowOverdraft
});
if (newTotal is null)
- return this.CreateAPIError(400, "overdraft", "The subscriber's balance would be overdrawn. Use allowOverdraft to allow this.");
+ return this.CreateAPIError(400, update.AllowOverdraft ? "balance-limit" : "overdraft",
+ "The subscriber's balance would exceed the permitted overdraft or balance limits.");
ctx.ChangeTracker.Clear();
return await GetCredit(storeId, offeringId, customerSelector, currency);
}
### BTCPayServer/Plugins/Subscriptions/Controllers/UIOfferingController.cs
@@ -14,6 +14,7 @@
using BTCPayServer.Plugins.Emails.Services;
using BTCPayServer.Plugins.Emails.Views;
using BTCPayServer.Security;
+using BTCPayServer.Security.Greenfield;
using BTCPayServer.Services;
using BTCPayServer.Services.Apps;
using BTCPayServer.Services.Invoices;
@@ -148,12 +149,20 @@ public async Task<IActionResult> SubscriberSuspend(string storeId, string offeri
await ctx.SaveChangesAsync();
TempData.SetStatusSuccess(StringLocalizer["Subscriber {0} deleted", subName]);
}
+ else if (command is "credit" or "charge" && amount is > GreenfieldConstants.MaxAmount)
+ {
+ TempData.SetStatusMessageModel(new()
+ {
+ Severity = StatusMessageModel.StatusSeverity.Error,
+ Html = StringLocalizer["The amount must be at most {0}", GreenfieldConstants.MaxAmount]
+ });
+ }
else if (command is "credit" or "charge" && amount is > 0)
{
var message = command is "credit"
? StringLocalizer["Subscriber {0} has been credited", subName]
: StringLocalizer["Subscriber {0} has been charged", subName];
- await SubsService.UpdateCredit(
+ var balance = await SubsService.UpdateCredit(
new SubscriptionHostedService.UpdateCreditParameters()
{
SubscriberId = sub.Id,
@@ -162,7 +171,18 @@ await SubsService.UpdateCredit(
Charge = command is "charge" ? amount.Value : 0.0m,
AllowOverdraft = true
});
- TempData.SetStatusSuccess(message);
+ if (balance is null)
+ {
+ TempData.SetStatusMessageModel(new()
+ {
+ Severity = StatusMessageModel.StatusSeverity.Error,
+ Html = StringLocalizer["Unable to update credit balance."]
+ });
+ }
+ else
+ {
+ TempData.SetStatusSuccess(message);
+ }
}
else if (command is "refund" && amount is > 0)
{
### BTCPayServer/Plugins/Subscriptions/SubscriptionContext.cs
@@ -8,6 +8,7 @@
using BTCPayServer.Data;
using BTCPayServer.Data.Subscriptions;
using BTCPayServer.Events;
+using BTCPayServer.Security.Greenfield;
using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Rates;
using Dapper;
@@ -50,13 +51,17 @@ public async Task<bool> TryChargeSubscriber(SubscriberData sub, string descripti
up AS (
INSERT INTO subs_subscriber_credits AS c (subscriber_id, currency, amount)
SELECT @id, @currency, @diff
- WHERE @force OR EXISTS (
+ WHERE @diff BETWEEN @minBalance AND @maxBalance
+ AND @credit <= @maxBalance
+ AND (@force OR EXISTS (
SELECT FROM subs_subscriber_credits
WHERE subscriber_id = @id AND currency = @currency
- )
+ ))
ON CONFLICT (subscriber_id, currency)
DO UPDATE SET amount = c.amount + EXCLUDED.amount
- WHERE @force OR c.amount + EXCLUDED.amount >= 0
+ WHERE (@force OR c.amount + EXCLUDED.amount >= 0)
+ AND c.amount + EXCLUDED.amount BETWEEN @minBalance AND @maxBalance
+ AND c.amount + @credit <= @maxBalance
RETURNING c.subscriber_id, c.currency, @diff AS diff, c.amount AS balance
),
hist AS (
@@ -71,7 +76,11 @@ INSERT INTO subs_subscriber_credits_history(subscriber_id, currency, description
FROM up
)
SELECT balance from up;
- """, new { id = tx.SubscriberId, currency = tx.Currency, diff, force, desc = tx.Description });
+ """, new
+ {
+ id = tx.SubscriberId, currency = tx.Currency, diff, force, desc = tx.Description,
+ credit = tx.Credit, minBalance = -GreenfieldConstants.MaxAmount, maxBalance = GreenfieldConstants.MaxAmount
+ });
return amount;
}
### BTCPayServer/Plugins/Translations/Translations.Default.cs
@@ -1875,6 +1875,7 @@ static Translations()
"The access key of the service is not set": "",
"The access token will be revoked. Do you wish to continue?": "",
"The admin {0} will be permanently deleted. This action will also delete all accounts, users and data associated with the server account. Are you sure?": "",
+ "The amount must be at most {0}": "",
"The amount should be more than zero": "",
"The API key was not found": "",
"The app <strong>{0}</strong> and its settings will be permanently deleted.": "",
@@ -2177,6 +2178,7 @@ static Translations()
"Unable to create the replacement transaction ({0})": "",
"Unable to proceed: As the user <strong>{0}</strong> is the last enabled admin, it cannot be disabled.": "",
"Unable to proceed: As the user <strong>{0}</strong> is the last enabled admin, it cannot be removed.": "",
+ "Unable to update credit balance.": "",
"Unapprove": "",
"Unapprove user": "",
"Unarchive": "",
### BTCPayServer/Services/Invoices/InvoiceEntity.cs
@@ -40,6 +40,7 @@ static InvoiceMetadata()
var seria = new JsonSerializer();
seria.DefaultValueHandling = DefaultValueHandling.Ignore;
seria.FloatParseHandling = FloatParseHandling.Decimal;
+ seria.MetadataPropertyHandling = MetadataPropertyHandling.Ignore;
seria.ContractResolver = new CamelCasePropertyNamesContractResolver();
MetadataSerializer = seria;
}
### BTCPayServer/Services/Stores/StoreRepository.cs
@@ -839,6 +839,7 @@ public async Task<StoreData> GetDefaultStoreTemplate()
return data;
var serializer = new NBXplorer.Serializer(null);
serializer.Settings.DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate;
+ serializer.Settings.MetadataPropertyHandling = MetadataPropertyHandling.Ignore;
var r = serializer.ToObject<RestrictedStoreData>(policies.DefaultStoreTemplate);
if (!string.IsNullOrWhiteSpace(r.StoreName))
data.StoreName = r.StoreName;
### BTCPayServer/UserManagerExtensions.cs
@@ -27,6 +27,18 @@ public static async Task<bool> IsAuthenticatorConfigured(this UserManager<Applic
return (await userManager.GetValidTwoFactorProvidersAsync(user)).Contains(userManager.Options.Tokens.AuthenticatorTokenProvider);
}
+ public static async Task<bool> CheckPasswordWithLockoutAsync(this UserManager<ApplicationUser> userManager, ApplicationUser user, string? password)
+ {
+ if (string.IsNullOrEmpty(password) || await userManager.IsLockedOutAsync(user))
+ return false;
+ if (await userManager.CheckPasswordAsync(user, password))
+ {
+ return (await userManager.ResetAccessFailedCountAsync(user)).Succeeded;
+ }
+ await userManager.AccessFailedAsync(user);
+ return false;
+ }
+
public static async Task<string?> GenerateInvitationTokenAsync(this UserManager<ApplicationUser> userManager, string userId)
{
var token = Guid.NewGuid().ToString("n")[..12];
### BTCPayServer/wwwroot/swagger/v1/swagger.template.subscriptions.json
@@ -493,14 +493,22 @@
}
},
"400": {
- "description": "Error code: `overdraft`. The subscriber's balance would be overdrawn. Use `allowOverdraft` to allow this.",
+ "description": "Error codes: `overdraft`, `balance-limit`. The balance update would exceed the permitted overdraft or balance limits.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
+ },
+ "422": {
+ "description": "Invalid credit, charge, or description.",
+ "content": {
+ "application/json": {
+ "schema": { "$ref": "#/components/schemas/ValidationProblemDetails" }
+ }
+ }
}
}
}
### BTCPayServer/wwwroot/swagger/v1/swagger.template.users.json
@@ -63,7 +63,7 @@
},
"currentPassword": {
"type": "string",
- "description": "The current password of the user. Required when changing the email or the password.",
+ "description": "The current password of the user. Required when changing the email or the password. Incorrect attempts count toward account lockout.",
"nullable": true
},
"newPassword": {Why this scored 61/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.