We (currently) can't filter unconfirmed transactions by address, because only the public key is stored in the database until it is confirmed (at which point there is an entry in the TransactionParticipants table which contains the address). Given that this isn't a simple problem to solve, for now it makes sense to reject this combination if requested via the /transactions/search API.

This commit is contained in:
CalDescent 2022-01-29 19:24:28 +00:00
parent c4f763960c
commit 7aed0354f1

View File

@ -349,6 +349,10 @@ public class TransactionsResource {
if (confirmationStatus != ConfirmationStatus.CONFIRMED && (startBlock != null || blockLimit != null))
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);
// You can't ask for unconfirmed and filter by address (due to only public key being stored when unconfirmed)
if (confirmationStatus != ConfirmationStatus.CONFIRMED && address != null && !address.isEmpty())
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);
try (final Repository repository = RepositoryManager.getRepository()) {
List<byte[]> signatures = repository.getTransactionRepository().getSignaturesMatchingCriteria(startBlock, blockLimit, txGroupId,
txTypes, null, null, address, confirmationStatus, limit, offset, reverse);