implemented getNewAddress command request

This commit is contained in:
davassi
2016-10-08 10:16:21 +02:00
parent 2a5b518298
commit 300be40b72
5 changed files with 54 additions and 6 deletions
+12 -5
View File
@@ -87,11 +87,6 @@ public class IotaAPIProxy {
return wrapCheckedException(res).body();
}
public AnalyzeTransactionResponse analyseTransaction(String ... trytes) {
final Call<AnalyzeTransactionResponse> res = service.analyzeTransactions(IotaAnalyzeTransactionRequest.createIotaAnalyzeTransactionRequest(trytes));
return wrapCheckedException(res).body();
}
public FindTransactionResponse findTransactions(String [] addresses, String [] digests, String [] approvees, String [] bundles ) {
final IotaFindTransactionsRequest findTransRequest = IotaFindTransactionsRequest
@@ -143,6 +138,18 @@ public class IotaAPIProxy {
return wrapCheckedException(res).body();
}
public AnalyzeTransactionResponse analyseTransaction(String ... trytes) {
final Call<AnalyzeTransactionResponse> res = service.analyzeTransactions(IotaAnalyzeTransactionRequest.createIotaAnalyzeTransactionRequest(trytes));
return wrapCheckedException(res).body();
}
public GetNewAddressResponse getNewAddress(String seed, Integer securityLevel) {
final Call<GetNewAddressResponse> res = service.getNewAddress(IotaGetNewAddressRequest.createIotaGetNewAddressRequest(seed, securityLevel));
return wrapCheckedException(res).body();
}
protected static <T> Response<T> wrapCheckedException(final Call<T> call) {
try {
final Response<T> res = call.execute();
+7 -1
View File
@@ -126,11 +126,17 @@ public interface IotaAPIService {
@POST("./")
Call<AnalyzeTransactionResponse> analyzeTransactions(@Body IotaAnalyzeTransactionRequest request);
/*
/**
* Generates a new address for your specified account (seed + securityLevel).
*
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "getNewAddress", "seed": "AAA999999999999999999999999999999999999999999999999999999999999999999999999999999", "securityLevel": 1}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@POST("./")
Call<GetNewAddressResponse> getNewAddress(@Body IotaGetNewAddressRequest request);
/*
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@POST("./")
Call<PrepareTransfersResponse> prepareTransfers(@Body IotaPrepareTransfersRequest request);
@@ -0,0 +1,19 @@
package jota.dto.request;
import jota.IotaAPICommands;
public class IotaGetNewAddressRequest extends IotaCommandRequest {
private String seed;
private Integer securityLevel;
private IotaGetNewAddressRequest(final String seed, final Integer securityLevel) {
super(IotaAPICommands.GET_NEW_ADDRESS);
this.seed = seed;
this.securityLevel = securityLevel;
}
public static IotaGetNewAddressRequest createIotaGetNewAddressRequest(String seed, Integer securityLevel) {
return new IotaGetNewAddressRequest(seed, securityLevel);
}
}
@@ -0,0 +1,10 @@
package jota.dto.response;
public class GetNewAddressResponse extends AbstractResponse {
private String address;
public String getAddress() {
return address;
}
}