forked from Qortal/qortal
Added API call GET /transactions/reference/{reference} for looking up a transaction by its reference
This commit is contained in:
parent
99e11d1f52
commit
3470b8bf57
@ -71,7 +71,7 @@ public class TransactionsResource {
|
||||
@ApiErrors({
|
||||
ApiError.INVALID_SIGNATURE, ApiError.TRANSACTION_NO_EXISTS, ApiError.REPOSITORY_ISSUE
|
||||
})
|
||||
public TransactionData getTransaction(@PathParam("signature") String signature58) {
|
||||
public TransactionData getTransactionBySignature(@PathParam("signature") String signature58) {
|
||||
byte[] signature;
|
||||
try {
|
||||
signature = Base58.decode(signature58);
|
||||
@ -112,7 +112,7 @@ public class TransactionsResource {
|
||||
@ApiErrors({
|
||||
ApiError.INVALID_SIGNATURE, ApiError.TRANSACTION_NO_EXISTS, ApiError.REPOSITORY_ISSUE, ApiError.TRANSFORMATION_ERROR
|
||||
})
|
||||
public String getRawTransaction(@PathParam("signature") String signature58) {
|
||||
public String getRawTransactionBySignature(@PathParam("signature") String signature58) {
|
||||
byte[] signature;
|
||||
try {
|
||||
signature = Base58.decode(signature58);
|
||||
@ -137,6 +137,46 @@ public class TransactionsResource {
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/reference/{reference}")
|
||||
@Operation(
|
||||
summary = "Fetch transaction using transaction reference",
|
||||
description = "Returns transaction",
|
||||
responses = {
|
||||
@ApiResponse(
|
||||
description = "a transaction",
|
||||
content = @Content(
|
||||
schema = @Schema(
|
||||
implementation = TransactionData.class
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
@ApiErrors({
|
||||
ApiError.INVALID_REFERENCE, ApiError.TRANSACTION_NO_EXISTS, ApiError.REPOSITORY_ISSUE
|
||||
})
|
||||
public TransactionData getTransactionByReference(@PathParam("reference") String reference58) {
|
||||
byte[] reference;
|
||||
try {
|
||||
reference = Base58.decode(reference58);
|
||||
} catch (NumberFormatException e) {
|
||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_REFERENCE, e);
|
||||
}
|
||||
|
||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||
TransactionData transactionData = repository.getTransactionRepository().fromReference(reference);
|
||||
if (transactionData == null)
|
||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.TRANSACTION_NO_EXISTS);
|
||||
|
||||
return transactionData;
|
||||
} catch (ApiException e) {
|
||||
throw e;
|
||||
} catch (DataException e) {
|
||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/block/{signature}")
|
||||
@Operation(
|
||||
|
Loading…
Reference in New Issue
Block a user