diff --git a/src/main/java/jota/IotaAPIProxy.java b/src/main/java/jota/IotaAPIProxy.java index f0edefe..ded3f0f 100644 --- a/src/main/java/jota/IotaAPIProxy.java +++ b/src/main/java/jota/IotaAPIProxy.java @@ -87,11 +87,6 @@ public class IotaAPIProxy { return wrapCheckedException(res).body(); } - public AnalyzeTransactionResponse analyseTransaction(String ... trytes) { - final Call 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 res = service.analyzeTransactions(IotaAnalyzeTransactionRequest.createIotaAnalyzeTransactionRequest(trytes)); + return wrapCheckedException(res).body(); + } + + public GetNewAddressResponse getNewAddress(String seed, Integer securityLevel) { + final Call res = service.getNewAddress(IotaGetNewAddressRequest.createIotaGetNewAddressRequest(seed, securityLevel)); + return wrapCheckedException(res).body(); + } + + + protected static Response wrapCheckedException(final Call call) { try { final Response res = call.execute(); diff --git a/src/main/java/jota/IotaAPIService.java b/src/main/java/jota/IotaAPIService.java index 60fdf24..ad3d8bd 100644 --- a/src/main/java/jota/IotaAPIService.java +++ b/src/main/java/jota/IotaAPIService.java @@ -126,11 +126,17 @@ public interface IotaAPIService { @POST("./") Call 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 getNewAddress(@Body IotaGetNewAddressRequest request); + /* @Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER }) @POST("./") Call prepareTransfers(@Body IotaPrepareTransfersRequest request); diff --git a/src/main/java/jota/dto/request/IotaGetNewAddressRequest.java b/src/main/java/jota/dto/request/IotaGetNewAddressRequest.java new file mode 100644 index 0000000..1216535 --- /dev/null +++ b/src/main/java/jota/dto/request/IotaGetNewAddressRequest.java @@ -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); + } +} diff --git a/src/main/java/jota/dto/response/GetNewAddressResponse.java b/src/main/java/jota/dto/response/GetNewAddressResponse.java new file mode 100644 index 0000000..a9216d2 --- /dev/null +++ b/src/main/java/jota/dto/response/GetNewAddressResponse.java @@ -0,0 +1,10 @@ +package jota.dto.response; + +public class GetNewAddressResponse extends AbstractResponse { + + private String address; + + public String getAddress() { + return address; + } +} diff --git a/src/test/java/jota/IotaAPIProxyTest.java b/src/test/java/jota/IotaAPIProxyTest.java index 204a3a4..2843f97 100644 --- a/src/test/java/jota/IotaAPIProxyTest.java +++ b/src/test/java/jota/IotaAPIProxyTest.java @@ -117,4 +117,10 @@ public class IotaAPIProxyTest { assertThat(res, IsNull.notNullValue()); } + @Test + public void shouldGetNewAddress() { + GetNewAddressResponse res = proxy.getNewAddress(TEST_SEED, 1); + assertThat(res, IsNull.notNullValue()); + } + }