mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Fix: Labels wouldn't be properly applied to some wallet's transactions (#5770)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using BTCPayServer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BTCPayServer.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20240220000000_FixWalletObjectsWithEmptyWalletId")]
|
||||
public partial class FixWalletObjectsWithEmptyWalletId : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
if (migrationBuilder.IsNpgsql())
|
||||
{
|
||||
migrationBuilder.Sql("DELETE FROM \"WalletObjects\" WHERE \"WalletId\"='';");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -386,7 +386,8 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
Destination = destination.destination,
|
||||
PullPaymentId = pullPaymentId,
|
||||
Value = request.Amount,
|
||||
PaymentMethodId = paymentMethodId
|
||||
PaymentMethodId = paymentMethodId,
|
||||
StoreId = pp.StoreId
|
||||
});
|
||||
|
||||
return HandleClaimResult(result);
|
||||
|
||||
@@ -612,7 +612,7 @@ namespace BTCPayServer.Controllers
|
||||
await _InvoiceRepository.MassArchive(selectedItems, false);
|
||||
TempData[WellKnownTempData.SuccessMessage] = $"{selectedItems.Length} invoice{(selectedItems.Length == 1 ? "" : "s")} unarchived.";
|
||||
break;
|
||||
case "cpfp":
|
||||
case "cpfp" when storeId is not null:
|
||||
var network = _NetworkProvider.DefaultNetwork;
|
||||
var explorer = _ExplorerClients.GetExplorerClient(network);
|
||||
if (explorer is null)
|
||||
|
||||
@@ -261,7 +261,8 @@ namespace BTCPayServer.Controllers
|
||||
Destination = destination,
|
||||
PullPaymentId = pullPaymentId,
|
||||
Value = vm.ClaimedAmount,
|
||||
PaymentMethodId = paymentMethodId
|
||||
PaymentMethodId = paymentMethodId,
|
||||
StoreId = pp.StoreId
|
||||
});
|
||||
|
||||
if (result.Result != ClaimRequest.ClaimResult.Ok)
|
||||
|
||||
@@ -1,48 +1,40 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.RegularExpressions;
|
||||
using BTCPayServer.Payments;
|
||||
|
||||
namespace BTCPayServer
|
||||
{
|
||||
public class WalletId
|
||||
public record WalletId
|
||||
{
|
||||
static readonly Regex _WalletStoreRegex = new Regex("^S-([a-zA-Z0-9]{30,60})-([a-zA-Z]{2,5})$");
|
||||
public static bool TryParse(string str, out WalletId walletId)
|
||||
public static bool TryParse(string str, [MaybeNullWhen(false)] out WalletId walletId)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(str);
|
||||
walletId = null;
|
||||
WalletId w = new WalletId();
|
||||
var match = _WalletStoreRegex.Match(str);
|
||||
if (!match.Success)
|
||||
return false;
|
||||
w.StoreId = match.Groups[1].Value;
|
||||
w.CryptoCode = match.Groups[2].Value.ToUpperInvariant();
|
||||
walletId = w;
|
||||
var storeId = match.Groups[1].Value;
|
||||
var cryptoCode = match.Groups[2].Value.ToUpperInvariant();
|
||||
walletId = new WalletId(storeId, cryptoCode);
|
||||
return true;
|
||||
}
|
||||
public WalletId()
|
||||
{
|
||||
|
||||
}
|
||||
public WalletId(string storeId, string cryptoCode)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(storeId);
|
||||
ArgumentNullException.ThrowIfNull(cryptoCode);
|
||||
StoreId = storeId;
|
||||
CryptoCode = cryptoCode;
|
||||
}
|
||||
public string StoreId { get; set; }
|
||||
public string CryptoCode { get; set; }
|
||||
public string StoreId { get; }
|
||||
public string CryptoCode { get; }
|
||||
|
||||
public PaymentMethodId GetPaymentMethodId()
|
||||
{
|
||||
return new PaymentMethodId(CryptoCode, PaymentTypes.BTCLike);
|
||||
}
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
WalletId item = obj as WalletId;
|
||||
if (item == null)
|
||||
return false;
|
||||
return ToString().Equals(item.ToString(), StringComparison.InvariantCulture);
|
||||
}
|
||||
|
||||
public static WalletId Parse(string id)
|
||||
{
|
||||
@@ -51,24 +43,6 @@ namespace BTCPayServer
|
||||
throw new FormatException("Invalid WalletId");
|
||||
}
|
||||
|
||||
public static bool operator ==(WalletId a, WalletId b)
|
||||
{
|
||||
if (System.Object.ReferenceEquals(a, b))
|
||||
return true;
|
||||
if (((object)a == null) || ((object)b == null))
|
||||
return false;
|
||||
return a.ToString() == b.ToString();
|
||||
}
|
||||
|
||||
public static bool operator !=(WalletId a, WalletId b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ToString().GetHashCode(StringComparison.Ordinal);
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
if (StoreId == null || CryptoCode == null)
|
||||
|
||||
Reference in New Issue
Block a user