Fix crash on /wallets/transactions with non zero skip parameter (Fix #5183)

This commit is contained in:
nicolas.dorier 2023-08-23 16:11:25 +09:00
parent 583813883c
commit 56fa3fe8f2
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
4 changed files with 10 additions and 3 deletions

View file

@ -55,7 +55,7 @@ namespace BTCPayServer.Client
}
public virtual async Task<IEnumerable<OnChainWalletTransactionData>> ShowOnChainWalletTransactions(
string storeId, string cryptoCode, TransactionStatus[] statusFilter = null, string labelFilter = null,
string storeId, string cryptoCode, TransactionStatus[] statusFilter = null, string labelFilter = null, int skip = 0,
CancellationToken token = default)
{
var query = new Dictionary<string, object>();
@ -67,6 +67,10 @@ namespace BTCPayServer.Client
{
query.Add(nameof(labelFilter), labelFilter);
}
if (skip != 0)
{
query.Add(nameof(skip), skip);
}
var response =
await _httpClient.SendAsync(
CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/wallet/transactions", query), token);

View file

@ -3212,6 +3212,9 @@ namespace BTCPayServer.Tests
});
var transaction = await client.GetOnChainWalletTransaction(walletId.StoreId, walletId.CryptoCode, txdata.TransactionHash.ToString());
// Check skip doesn't crash
await client.ShowOnChainWalletTransactions(walletId.StoreId, walletId.CryptoCode, skip: 1);
Assert.Equal(transaction.TransactionHash, txdata.TransactionHash);
Assert.Equal(String.Empty, transaction.Comment);
#pragma warning disable CS0612 // Type or member is obsolete

View file

@ -759,7 +759,7 @@ namespace BTCPayServer.Controllers.Greenfield
}
public override async Task<IEnumerable<OnChainWalletTransactionData>> ShowOnChainWalletTransactions(
string storeId, string cryptoCode, TransactionStatus[] statusFilter = null, string labelFilter = null,
string storeId, string cryptoCode, TransactionStatus[] statusFilter = null, string labelFilter = null, int skip = 0,
CancellationToken token = default)
{
return GetFromActionResult<IEnumerable<OnChainWalletTransactionData>>(

View file

@ -252,7 +252,7 @@ namespace BTCPayServer.Services.Wallets
{
wallet_id = NBXplorer.Client.DBUtils.nbxv1_get_wallet_id(Network.CryptoCode, derivationStrategyBase.ToString()),
code = Network.CryptoCode,
count = count,
count = count == int.MaxValue ? null : count,
skip = skip,
interval = interval is TimeSpan t ? t : TimeSpan.FromDays(365 * 1000)
},