3
0
mirror of https://github.com/Qortal/qortal.git synced 2025-02-12 02:05:50 +00:00

Added "SEARCH_TRANSACTIONS" action.

This commit is contained in:
CalDescent 2023-01-19 20:22:29 +00:00
parent ca80fd5f9c
commit 86d6037af3
3 changed files with 42 additions and 0 deletions

View File

@ -75,6 +75,7 @@ Here is a list of currently supported actions:
- LIST_ATS
- FETCH_BLOCK
- FETCH_BLOCK_RANGE
- SEARCH_TRANSACTIONS
More functionality will be added in the future.
@ -373,6 +374,24 @@ let res = await qortalRequest({
});
```
### Search transactions
```
let res = await qortalRequest({
action: "SEARCH_TRANSACTIONS",
// startBlock: 1139000,
// blockLimit: 1000,
txGroupId: 0,
txType: [
"PAYMENT",
"REWARD_SHARE"
],
confirmationStatus: "CONFIRMED",
limit: 10,
offset: 0,
reverse: false
});
```
## Sample App

View File

@ -20,6 +20,8 @@ import org.qortal.data.block.BlockData;
import org.qortal.data.chat.ChatMessage;
import org.qortal.data.group.GroupData;
import org.qortal.data.naming.NameData;
import org.qortal.data.transaction.TransactionData;
import org.qortal.transaction.Transaction;
import org.qortal.utils.Base58;
import javax.servlet.ServletContext;
@ -204,6 +206,14 @@ public class AppsResource {
return blocksResource.getBlockRange(height, count, reverse, includeOnlineSignatures);
}
@GET
@Path("/transactions/search")
@Hidden // For internal Q-App API use only
public List<TransactionData> searchTransactions(@QueryParam("startBlock") Integer startBlock, @QueryParam("blockLimit") Integer blockLimit, @QueryParam("txGroupId") Integer txGroupId, @QueryParam("txType") List<Transaction.TransactionType> txTypes, @QueryParam("address") String address, @Parameter() @QueryParam("confirmationStatus") TransactionsResource.ConfirmationStatus confirmationStatus, @Parameter(ref = "limit") @QueryParam("limit") Integer limit, @Parameter(ref = "offset") @QueryParam("offset") Integer offset, @Parameter(ref = "reverse") @QueryParam("reverse") Boolean reverse) {
TransactionsResource transactionsResource = (TransactionsResource) buildResource(TransactionsResource.class, request, response, context);
return transactionsResource.searchTransactions(startBlock, blockLimit, txGroupId, txTypes, address, confirmationStatus, limit, offset, reverse);
}
public static Object buildResource(Class<?> resourceClass, HttpServletRequest request, HttpServletResponse response, ServletContext context) {
try {

View File

@ -177,6 +177,19 @@ window.addEventListener("message", (event) => {
response = httpGet(url);
break;
case "SEARCH_TRANSACTIONS":
url = "/apps/transactions/search?";
if (data.startBlock != null) url = url.concat("&startBlock=" + data.startBlock);
if (data.blockLimit != null) url = url.concat("&blockLimit=" + data.blockLimit);
if (data.txGroupId != null) url = url.concat("&txGroupId=" + data.txGroupId);
if (data.txType != null) data.txType.forEach((x, i) => url = url.concat("&txType=" + x));
if (data.confirmationStatus != null) url = url.concat("&confirmationStatus=" + data.confirmationStatus);
if (data.limit != null) url = url.concat("&limit=" + data.limit);
if (data.offset != null) url = url.concat("&offset=" + data.offset);
if (data.reverse != null) url = url.concat("&reverse=" + new Boolean(data.reverse).toString());
response = httpGet(url);
break;
default:
// Pass to parent (UI), in case they can fulfil this request
event.data.requestedHandler = "UI";