mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2026-08-31 05:10:25 +00:00
implemented getTransactionToApprove command request
This commit is contained in:
@@ -8,9 +8,11 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import jota.dto.request.*;
|
||||
import jota.dto.response.*;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -51,9 +53,15 @@ public class IotaAPIProxy {
|
||||
|
||||
final String nodeUrl = protocol + "://" + host + ":" + port;
|
||||
|
||||
final OkHttpClient client = new OkHttpClient.Builder()
|
||||
.readTimeout(120, TimeUnit.SECONDS)
|
||||
.connectTimeout(120, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
final Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(nodeUrl)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(client)
|
||||
.build();
|
||||
|
||||
service = retrofit.create(IotaAPIService.class);
|
||||
@@ -148,6 +156,10 @@ public class IotaAPIProxy {
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
public GetTransactionsToApproveResponse getTransactionsToApprove(String milestone) {
|
||||
final Call<GetTransactionsToApproveResponse> res = service.getTransactionsToApprove(IotaGetTransactionsToApproveRequest.createIotaGetTransactionsToApproveRequest(milestone));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
|
||||
protected static <T> Response<T> wrapCheckedException(final Call<T> call) {
|
||||
|
||||
@@ -140,11 +140,19 @@ public interface IotaAPIService {
|
||||
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
|
||||
@POST("./")
|
||||
Call<PrepareTransfersResponse> prepareTransfers(@Body IotaPrepareTransfersRequest request);
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tip selection which returns trunkTransaction and branchTransaction. The input value is the latest coordinator milestone, as provided through the getNodeInfo API call.
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getTransactionsToApprove", "milestone": "SMYMAKKPSUKCKDRUEYCGZJTYCZ9HHDMDUWBAPXARGURPQRHTAJDASRWMIDTPTBNDKDEFBUTBGGAFX9999"}'
|
||||
*/
|
||||
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
|
||||
@POST("./")
|
||||
Call<GetTransactionsToApproveResponse> getTransactionsToApprove(@Body IotaGetTransactionsToApproveRequest request);
|
||||
|
||||
/*
|
||||
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
|
||||
@POST("./")
|
||||
Call<GetAttachToTangleResponse> attachToTangle(@Body IotaAttachToTangleRequest request);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package jota.dto.request;
|
||||
|
||||
import jota.IotaAPICommands;
|
||||
|
||||
public class IotaGetTransactionsToApproveRequest extends IotaCommandRequest {
|
||||
|
||||
private String milestone;
|
||||
|
||||
private IotaGetTransactionsToApproveRequest(final String milestone) {
|
||||
super(IotaAPICommands.GET_TRANSACTIONS_TO_APPROVE);
|
||||
this.milestone = milestone;
|
||||
}
|
||||
|
||||
public static IotaGetTransactionsToApproveRequest createIotaGetTransactionsToApproveRequest(String milestone) {
|
||||
return new IotaGetTransactionsToApproveRequest(milestone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package jota.dto.response;
|
||||
|
||||
public class GetTransactionsToApproveResponse extends AbstractResponse {
|
||||
|
||||
private String trunkTransaction;
|
||||
private String branchTransaction;
|
||||
|
||||
public String getBranchTransaction() {
|
||||
return branchTransaction;
|
||||
}
|
||||
public String getTrunkTransaction() {
|
||||
return trunkTransaction;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user