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,
|
Destination = destination.destination,
|
||||||
PullPaymentId = pullPaymentId,
|
PullPaymentId = pullPaymentId,
|
||||||
Value = request.Amount,
|
Value = request.Amount,
|
||||||
PaymentMethodId = paymentMethodId
|
PaymentMethodId = paymentMethodId,
|
||||||
|
StoreId = pp.StoreId
|
||||||
});
|
});
|
||||||
|
|
||||||
return HandleClaimResult(result);
|
return HandleClaimResult(result);
|
||||||
|
|||||||
@@ -612,7 +612,7 @@ namespace BTCPayServer.Controllers
|
|||||||
await _InvoiceRepository.MassArchive(selectedItems, false);
|
await _InvoiceRepository.MassArchive(selectedItems, false);
|
||||||
TempData[WellKnownTempData.SuccessMessage] = $"{selectedItems.Length} invoice{(selectedItems.Length == 1 ? "" : "s")} unarchived.";
|
TempData[WellKnownTempData.SuccessMessage] = $"{selectedItems.Length} invoice{(selectedItems.Length == 1 ? "" : "s")} unarchived.";
|
||||||
break;
|
break;
|
||||||
case "cpfp":
|
case "cpfp" when storeId is not null:
|
||||||
var network = _NetworkProvider.DefaultNetwork;
|
var network = _NetworkProvider.DefaultNetwork;
|
||||||
var explorer = _ExplorerClients.GetExplorerClient(network);
|
var explorer = _ExplorerClients.GetExplorerClient(network);
|
||||||
if (explorer is null)
|
if (explorer is null)
|
||||||
|
|||||||
@@ -261,7 +261,8 @@ namespace BTCPayServer.Controllers
|
|||||||
Destination = destination,
|
Destination = destination,
|
||||||
PullPaymentId = pullPaymentId,
|
PullPaymentId = pullPaymentId,
|
||||||
Value = vm.ClaimedAmount,
|
Value = vm.ClaimedAmount,
|
||||||
PaymentMethodId = paymentMethodId
|
PaymentMethodId = paymentMethodId,
|
||||||
|
StoreId = pp.StoreId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.Result != ClaimRequest.ClaimResult.Ok)
|
if (result.Result != ClaimRequest.ClaimResult.Ok)
|
||||||
|
|||||||
@@ -1,49 +1,41 @@
|
|||||||
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using BTCPayServer.Payments;
|
using BTCPayServer.Payments;
|
||||||
|
|
||||||
namespace BTCPayServer
|
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})$");
|
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);
|
ArgumentNullException.ThrowIfNull(str);
|
||||||
walletId = null;
|
walletId = null;
|
||||||
WalletId w = new WalletId();
|
|
||||||
var match = _WalletStoreRegex.Match(str);
|
var match = _WalletStoreRegex.Match(str);
|
||||||
if (!match.Success)
|
if (!match.Success)
|
||||||
return false;
|
return false;
|
||||||
w.StoreId = match.Groups[1].Value;
|
var storeId = match.Groups[1].Value;
|
||||||
w.CryptoCode = match.Groups[2].Value.ToUpperInvariant();
|
var cryptoCode = match.Groups[2].Value.ToUpperInvariant();
|
||||||
walletId = w;
|
walletId = new WalletId(storeId, cryptoCode);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
public WalletId()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public WalletId(string storeId, string cryptoCode)
|
public WalletId(string storeId, string cryptoCode)
|
||||||
{
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(storeId);
|
||||||
|
ArgumentNullException.ThrowIfNull(cryptoCode);
|
||||||
StoreId = storeId;
|
StoreId = storeId;
|
||||||
CryptoCode = cryptoCode;
|
CryptoCode = cryptoCode;
|
||||||
}
|
}
|
||||||
public string StoreId { get; set; }
|
public string StoreId { get; }
|
||||||
public string CryptoCode { get; set; }
|
public string CryptoCode { get; }
|
||||||
|
|
||||||
public PaymentMethodId GetPaymentMethodId()
|
public PaymentMethodId GetPaymentMethodId()
|
||||||
{
|
{
|
||||||
return new PaymentMethodId(CryptoCode, PaymentTypes.BTCLike);
|
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)
|
public static WalletId Parse(string id)
|
||||||
{
|
{
|
||||||
if (TryParse(id, out var v))
|
if (TryParse(id, out var v))
|
||||||
@@ -51,24 +43,6 @@ namespace BTCPayServer
|
|||||||
throw new FormatException("Invalid WalletId");
|
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()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
if (StoreId == null || CryptoCode == null)
|
if (StoreId == null || CryptoCode == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user