mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Add label filter for onchain tx API endpoint (#3588)
* Add label filter for onchain tx API endpoint close #3587 * Add Swagger docs * Add test for filtering by transaction label
This commit is contained in:
@@ -173,6 +173,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
string storeId,
|
||||
string cryptoCode,
|
||||
[FromQuery] TransactionStatus[]? statusFilter = null,
|
||||
[FromQuery] string? labelFilter = null,
|
||||
[FromQuery] int skip = 0,
|
||||
[FromQuery] int limit = int.MaxValue
|
||||
)
|
||||
@@ -202,6 +203,23 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
filteredFlatList.AddRange(txs.ReplacedTransactions.Transactions);
|
||||
}
|
||||
|
||||
if (labelFilter != null)
|
||||
{
|
||||
filteredFlatList = filteredFlatList.Where(information =>
|
||||
{
|
||||
walletTransactionsInfoAsync.TryGetValue(information.TransactionId.ToString(), out var transactionInfo);
|
||||
|
||||
if (transactionInfo != null)
|
||||
{
|
||||
return transactionInfo.Labels.ContainsKey(labelFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
var result = filteredFlatList.Skip(skip).Take(limit).Select(information =>
|
||||
{
|
||||
walletTransactionsInfoAsync.TryGetValue(information.TransactionId.ToString(), out var transactionInfo);
|
||||
|
||||
Reference in New Issue
Block a user