Merge pull request #1 from pinpong/master

update dto
This commit is contained in:
Gianluigi Davassi
2016-11-24 15:23:39 +01:00
committed by GitHub
30 changed files with 351 additions and 306 deletions
-1
View File
@@ -1,4 +1,3 @@
iota.node.protocol=http
#iota.node.host=138.68.126.141
iota.node.host=127.0.0.1
+84 -73
View File
@@ -1,86 +1,97 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.iota</groupId>
<artifactId>jota</artifactId>
<version>1.0.0-RELEASE</version>
<name>JOTA</name>
<description>JOTA library is a simple Java wrapper around IOTA Node's JSON-REST HTTP interface.</description>
<modelVersion>4.0.0</modelVersion>
<groupId>com.iota</groupId>
<artifactId>jota</artifactId>
<version>1.0.0-RELEASE</version>
<name>JOTA</name>
<description>JOTA library is a simple Java wrapper around IOTA Node's JSON-REST HTTP interface.</description>
<properties>
<java-version>1.7</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<properties>
<java-version>1.7</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit -->
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit -->
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.retrofit2/converter-gson -->
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-gson</artifactId>
<version>2.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.retrofit2/converter-gson -->
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-gson</artifactId>
<version>2.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<testSource>${java-version}</testSource>
<testTarget>${java-version}</testTarget>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<testSource>${java-version}</testSource>
<testTarget>${java-version}</testTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
+14 -14
View File
@@ -7,29 +7,29 @@ package jota;
*/
public enum IotaAPICommands {
GET_NODE_INFO("getNodeInfo", 0),
GET_NEIGHBORS("getNeighbors", 0),
ADD_NEIGHBORS("addNeighbors", 1),
REMOVE_NEIGHBORS("removeNeighbors",1),
GET_TIPS("getTips",0),
FIND_TRANSACTIONS("findTransactions", 1),
GET_TRYTES("getTrytes", 0),
GET_INCLUSIONS_STATES("getInclusionStates", 0),
GET_BALANCES("getBalances", 0),
GET_TRANSACTIONS_TO_APPROVE("getTransactionsToApprove", 0),
GET_NODE_INFO("getNodeInfo", 0),
GET_NEIGHBORS("getNeighbors", 0),
ADD_NEIGHBORS("addNeighbors", 1),
REMOVE_NEIGHBORS("removeNeighbors", 1),
GET_TIPS("getTips", 0),
FIND_TRANSACTIONS("findTransactions", 1),
GET_TRYTES("getTrytes", 0),
GET_INCLUSIONS_STATES("getInclusionStates", 0),
GET_BALANCES("getBalances", 0),
GET_TRANSACTIONS_TO_APPROVE("getTransactionsToApprove", 0),
ATTACH_TO_TANGLE("attachToTangle", 0),
INTERRUPT_ATTACHING_TO_TANGLE("interruptAttachingToTangle", 0),
BROADCAST_TRANSACTIONS("broadcastTransactions",0),
BROADCAST_TRANSACTIONS("broadcastTransactions", 0),
STORE_TRANSACTIONS("storeTransactions", 0);
private String command;
private int params;
IotaAPICommands(String command, int params) {
this.command = command;
this.params = params;
}
private String command;
private int params;
public String command() {
return command;
}
+60 -60
View File
@@ -1,37 +1,34 @@
package jota;
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
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 jota.utils.IotaAPIUtils;
import okhttp3.OkHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Collection;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
/**
* IotaAPIProxy Builder. Usage:
*
*
* IotaApiProxy api = IotaApiProxy.Builder
* .protocol("http")
* .nodeAddress("localhost")
* .port(12345)
* .build();
*
* .protocol("http")
* .nodeAddress("localhost")
* .port(12345)
* .build();
*
* GetNodeInfoResponse response = api.getNodeInfo();
*
*
* @author davassi
*/
public class IotaAPIProxy {
@@ -39,6 +36,7 @@ public class IotaAPIProxy {
private static final Logger log = LoggerFactory.getLogger(IotaAPIProxy.class);
private IotaAPIService service;
private String protocol, host, port;
private IotaAPIProxy(final Builder builder) {
protocol = builder.protocol;
@@ -47,7 +45,28 @@ public class IotaAPIProxy {
postConstruct();
}
private String protocol, host, port;
protected static <T> Response<T> wrapCheckedException(final Call<T> call) {
try {
final Response<T> res = call.execute();
if (res.code() == 400) {
throw new IllegalAccessError(res.errorBody().toString());
}
return res;
} catch (IOException e) {
log.error("Execution of the API call raised exception. IOTA Node not reachable?", e);
throw new IllegalStateException(e.getMessage());
}
}
private static final String env(String env, String def) {
final String value = System.getenv(env);
if (value == null) {
log.warn("Environment variable '{}' is not defined, and actual value has not been specified. "
+ "Rolling back to default value: '{}'", env, def);
return def;
}
return value;
}
private void postConstruct() {
@@ -79,12 +98,12 @@ public class IotaAPIProxy {
return wrapCheckedException(res).body();
}
public AddNeighborsResponse addNeighbors(String ... uris) {
public AddNeighborsResponse addNeighbors(String... uris) {
final Call<AddNeighborsResponse> res = service.addNeighbors(IotaNeighborsRequest.createAddNeighborsRequest(uris));
return wrapCheckedException(res).body();
}
public RemoveNeighborsResponse removeNeighbors(String ... uris) {
public RemoveNeighborsResponse removeNeighbors(String... uris) {
final Call<RemoveNeighborsResponse> res = service.removeNeighbors(IotaNeighborsRequest.createRemoveNeighborsRequest(uris));
return wrapCheckedException(res).body();
}
@@ -94,12 +113,12 @@ public class IotaAPIProxy {
return wrapCheckedException(res).body();
}
public FindTransactionResponse findTransactions(String [] addresses, String [] digests, String [] approvees, String [] bundles ) {
public FindTransactionResponse findTransactions(String[] addresses, String[] tags, String[] approvees, String[] bundles) {
final IotaFindTransactionsRequest findTransRequest = IotaFindTransactionsRequest
.createFindTransactionRequest()
.byAddresses(addresses)
.byDigests(digests)
.byTags(tags)
.byApprovees(approvees)
.byBundles(bundles);
@@ -107,19 +126,19 @@ public class IotaAPIProxy {
return wrapCheckedException(res).body();
}
public FindTransactionResponse findTransactionsByAddresses(final String ... addresses) {
public FindTransactionResponse findTransactionsByAddresses(final String... addresses) {
return findTransactions(addresses, null, null, null);
}
public FindTransactionResponse findTransactionsByBundles(final String ... bundles) {
public FindTransactionResponse findTransactionsByBundles(final String... bundles) {
return findTransactions(null, null, null, bundles);
}
public FindTransactionResponse findTransactionsByApprovees(final String ... approvees) {
public FindTransactionResponse findTransactionsByApprovees(final String... approvees) {
return findTransactions(null, null, approvees, null);
}
public FindTransactionResponse findTransactionsByDigests(final String ... digests) {
public FindTransactionResponse findTransactionsByDigests(final String... digests) {
return findTransactions(null, digests, null, null);
}
@@ -135,7 +154,7 @@ public class IotaAPIProxy {
return wrapCheckedException(res).body();
}
public GetTrytesResponse getTrytes(String ... hashes) {
public GetTrytesResponse getTrytes(String... hashes) {
final Call<GetTrytesResponse> res = service.getTrytes(IotaGetTrytesRequest.createGetTrytesRequest(hashes));
return wrapCheckedException(res).body();
}
@@ -145,7 +164,7 @@ public class IotaAPIProxy {
return wrapCheckedException(res).body();
}
public GetBalancesResponse getBalances(Integer threshold, String [] addresses) {
public GetBalancesResponse getBalances(Integer threshold, String[] addresses) {
final Call<GetBalancesResponse> res = service.getBalances(IotaGetBalancesRequest.createIotaGetBalancesRequest(threshold, addresses));
return wrapCheckedException(res).body();
}
@@ -155,36 +174,23 @@ public class IotaAPIProxy {
return wrapCheckedException(res).body();
}
public GetAttachToTangleResponse attachToTangle(String trunkTransaction, String branchTransaction, Integer minWeightMagnitude, String ... trytes) {
public GetAttachToTangleResponse attachToTangle(String trunkTransaction, String branchTransaction, Integer minWeightMagnitude, String... trytes) {
final Call<GetAttachToTangleResponse> res = service.attachToTangle(IotaAttachToTangleRequest.createAttachToTangleRequest(trunkTransaction, branchTransaction, minWeightMagnitude, trytes));
return wrapCheckedException(res).body();
}
public StoreTransactionsResponse storeTransactions(String ... trytes) {
public StoreTransactionsResponse storeTransactions(String... trytes) {
final Call<StoreTransactionsResponse> res = service.storeTransactions(IotaStoreTransactionsRequest.createStoreTransactionsRequest(trytes));
return wrapCheckedException(res).body();
}
public BroadcastTransactionsResponse broadcastTransactions(String ... trytes) {
// end of proxied calls.
public BroadcastTransactionsResponse broadcastTransactions(String... trytes) {
final Call<BroadcastTransactionsResponse> res = service.broadcastTransactions(IotaBroadcastTransactionRequest.createBroadcastTransactionsRequest(trytes));
return wrapCheckedException(res).body();
}
protected static <T> Response<T> wrapCheckedException(final Call<T> call) {
try {
final Response<T> res = call.execute();
if (res.code() == 400) {
throw new IllegalAccessError(res.errorBody().toString());
}
return res;
} catch (IOException e) {
log.error("Execution of the API call raised exception. IOTA Node not reachable?", e);
throw new IllegalStateException(e.getMessage());
}
}
// end of proxied calls.
public GetBundleResponse getBundle(String transaction) {
return IotaAPIUtils.getBundle(transaction);
}
@@ -193,20 +199,10 @@ public class IotaAPIProxy {
return IotaAPIUtils.getNewAddress(seed, securityLevel);
}
private static final String env(String env, String def) {
final String value = System.getenv(env);
if (value == null) {
log.warn("Environment variable '{}' is not defined, and actual value has not been specified. "
+ "Rolling back to default value: '{}'", env, def);
return def;
}
return value;
}
public static class Builder {
String protocol, host, port;
public IotaAPIProxy build() {
if (protocol == null || host == null || port == null) {
@@ -225,9 +221,13 @@ public class IotaAPIProxy {
private boolean checkPropertiesFiles() {
try (BufferedReader reader = Files.newBufferedReader(Paths.get("node_config.properties"))) {
try {
FileReader fileReader = new FileReader("node_config.properties");
BufferedReader bufferedReader = new BufferedReader(fileReader);
final Properties nodeConfig = new Properties();
nodeConfig.load(reader);
nodeConfig.load(bufferedReader);
if (nodeConfig.getProperty("iota.node.protocol") != null) {
protocol = nodeConfig.getProperty("iota.node.protocol");
@@ -252,7 +252,7 @@ public class IotaAPIProxy {
host = env("IOTA_NODE_HOST", "localhost");
port = env("IOTA_NODE_PORT", "14265");
}
public Builder host(String host) {
this.host = host;
return this;
+22 -23
View File
@@ -9,33 +9,33 @@ import retrofit2.http.POST;
/**
* IOTA API Proxy Service definition using Retrofit2
*
*
* @author davassi
*/
public interface IotaAPIService {
public static final String CONTENT_TYPE_HEADER = "Content-Type: application/json";
public static final String USER_AGENT_HEADER = "User-Agent: JOTA-API wrapper";
String CONTENT_TYPE_HEADER = "Content-Type: application/json";
String USER_AGENT_HEADER = "User-Agent: JOTA-API wrapper";
/**
* Returns information about your node.
*
*
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "getNodeInfo"}'
*
*
* @return a {@code NodeInfoResponse} object, if succesfull.
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<GetNodeInfoResponse> getNodeInfo(@Body IotaCommandRequest request);
/**
* Get the list of latest tips (unconfirmed transactions).
*
*
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "getNeighbors"}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<GetNeighborsResponse> getNeighbors(@Body IotaCommandRequest request);
@@ -45,7 +45,7 @@ public interface IotaAPIService {
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "addNeighbors", "uris": ["udp://8.8.8.8:14265", "udp://8.8.8.5:14265"]}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<AddNeighborsResponse> addNeighbors(@Body IotaNeighborsRequest request);
@@ -55,7 +55,7 @@ public interface IotaAPIService {
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "removeNeighbors", "uris": ["udp://8.8.8.8:14265", "udp://8.8.8.5:14265"]}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<RemoveNeighborsResponse> removeNeighbors(@Body IotaNeighborsRequest request);
@@ -65,17 +65,17 @@ public interface IotaAPIService {
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "getTips"}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<GetTipsResponse> getTips(@Body IotaCommandRequest request);
/**
* Find the transactions which match the specified input and return
*
* curl http://localhost:14265 \ -X POST \ -H 'Content-Type: application/json' \
*
* curl http://localhost:14265 \ -X POST \ -H 'Content-Type: application/json' \
* -d '{"command": "findTransactions", "addresses": ["RVORZ9SIIP9RCYMREUIXXVPQIPHVCNPQ9HZWYKFWYWZRE9JQKG9REPKIASHUUECPSQO9JT9XNMVKWYGVAZETAIRPTM"]}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<FindTransactionResponse> findTransactions(@Body IotaFindTransactionsRequest request);
@@ -86,7 +86,7 @@ public interface IotaAPIService {
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "getInclusionStates", "transactions"Q9HZWYKFWYWZRE9JQKG9REPKIASHUUECPSQO9JT9XNMVKWYGVAZETAIRPTM"], "tips" : []}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<GetInclusionStateResponse> getInclusionStates(@Body IotaGetInclusionStateRequest request);
@@ -95,9 +95,8 @@ public interface IotaAPIService {
*
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "getTrytes", "hashes": ["OAATQS9VQLSXCLDJVJJVYUGONXAXOFMJOZNSYWRZSWECMXAQQURHQBJNLD9IOFEPGZEPEMPXCIVRX9999"]}'
*
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<GetTrytesResponse> getTrytes(@Body IotaGetTrytesRequest request);
@@ -107,7 +106,7 @@ public interface IotaAPIService {
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "getTransactionsToApprove", "depth": 27}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<GetTransactionsToApproveResponse> getTransactionsToApprove(@Body IotaGetTransactionsToApproveRequest request);
@@ -117,7 +116,7 @@ public interface IotaAPIService {
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "getBalances", "addresses": ["HBBYKAKTILIPVUKFOTSLHGENPTXYBNKXZFQFR9VQFWNBMTQNRVOUKPVPRNBSZVVILMAFBKOTBLGLWLOHQ"], "threshold": 100}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<GetBalancesResponse> getBalances(@Body IotaGetBalancesRequest request);
@@ -127,7 +126,7 @@ public interface IotaAPIService {
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "attachToTangle", "trunkTransaction": "JVMTDGDPDFYHMZPMWEKKANBQSLSDTIIHAYQUMZOKHXXXGJHJDQPOMDOMNRDKYCZRUFZROZDADTHZC9999", "branchTransaction": "P9KFSJVGSPLXAEBJSHWFZLGP9GGJTIO9YITDEHATDTGAFLPLBZ9FOFWWTKMAZXZHFGQHUOXLXUALY9999", "minWeightMagnitude": 18, "trytes": ["TRYTVALUEHERE"]}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<GetAttachToTangleResponse> attachToTangle(@Body IotaAttachToTangleRequest request);
@@ -137,7 +136,7 @@ public interface IotaAPIService {
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "interruptAttachingToTangle" }
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<InterruptAttachingToTangleResponse> interruptAttachingToTangle(@Body IotaCommandRequest request);
@@ -147,7 +146,7 @@ public interface IotaAPIService {
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "broadcastTransactions", "trytes": ["BYSWEAUTWXHXZ9YBZISEK9LUHWGMHXCGEVNZHRLUWQFCUSDXZHOFHWHL9MQPVJXXZLIXPXPXF9KYERE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GK9UOHCFKBIBNETK999999999999999999999999999999999999999999999999999999999999999999999999999999999NOXDXXKUDWLOFJLIPQIBRBMGDYCPGDNLQOLQS99EQYKBIU9VHCJVIPFUYCQDNY9APGEVYLCENJIOBLWNB999999999XKBRHUD99C99999999NKZKEKWLDKMJCI9N9XQOLWEPAYWSH9999999999999999999999999KDDTGZLIPBNZKMLTOLOXQVNGLASESDQVPTXALEKRMIOHQLUHD9ELQDBQETS9QFGTYOYWLNTSKKMVJAUXSIROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999IROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999"]}
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<BroadcastTransactionsResponse> broadcastTransactions(@Body IotaBroadcastTransactionRequest request);
@@ -157,7 +156,7 @@ public interface IotaAPIService {
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
* -d '{"command": "storeTransactions", "trytes": ["BYSWEAUTWXHXZ9YBZISEK9LUHWGMHXCGEVNZHRLUWQFCUSDXZHOFHWHL9MQPVJXXZLIXPXPXF9KYEREFSKCPKYIIKPZVLHUTDFQKKVVBBN9ATTLPCNPJDWDEVIYYLGPZGCWXOBDXMLJC9VO9QXTTBLAXTTBFUAROYEGQIVB9MJWJKXJMCUPTWAUGFZBTZCSJVRBGMYXTVBDDS9MYUJCPZ9YDWWQNIPUAIJXXSNLKUBSCOIJPCLEFPOXFJREXQCUVUMKSDOVQGGHRNILCO9GNCLWFM9APMNMWYASHXQAYBEXF9QRIHIBHYEJOYHRQJAOKAQ9AJJFQ9WEIWIJOTZATIBOXQLBMIJU9PCGBLVDDVFP9CFFSXTDUXMEGOOFXWRTLFGV9XXMYWEMGQEEEDBTIJ9OJOXFAPFQXC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J9BKYYXSV9JSPEXYMCFAIKTGNRSQGUNIYZCRT9FOWENSZQPD9ALUPYYAVICHVYELYFPUYDTWUSWNIYFXPX9MICCCOOZIWRNJIDALWGWRATGLJXNAYTNIZWQ9YTVDBOFZRKO9CFWRPAQQRXTPACOWCPRLYRYSJARRKSQPR9TCFXDVIXLP9XVL99ERRDSOHBFJDJQQGGGCZNDQ9NYCTQJWVZIAELCRBJJFDMCNZU9FIZRPGNURTXOCDSQGXTQHKHUECGWFUUYS9J9NYQ9U9P9UUP9YMZHWWWCIASCFLCMSKTELZWUGCDE9YOKVOVKTAYPHDF9ZCCQAYPJIJNGSHUIHHCOSSOOBUDOKE9CJZGYSSGNCQJVBEFTZFJ9SQUHOASKRRGBSHWKBCBWBTJHOGQ9WOMQFHWJVEG9NYX9KWBTCAIXNXHEBDIOFO9ALYMFGRICLCKKLG9FOBOX9PDWNQRGHBKHGKKRLWTBEQMCWQRLHAVYYZDIIPKVQTHYTWQMTOACXZOQCDTJTBAAUWXSGJF9PNQIJ9AJRUMUVCPWYVYVARKR9RKGOUHHNKNVGGPDDLGKPQNOYHNKAVVKCXWXOQPZNSLATUJT9AUWRMPPSWHSTTYDFAQDXOCYTZHOYYGAIM9CELMZ9AZPWB9MJXGHOKDNNSZVUDAGXTJJSSZCPZVPZBYNNTUQABSXQWZCHDQSLGK9UOHCFKBIBNETK999999999999999999999999999999999999999999999999999999999999999999999999999999999NOXDXXKUDWLOFJLIPQIBRBMGDYCPGDNLQOLQS99EQYKBIU9VHCJVIPFUYCQDNY9APGEVYLCENJIOBLWNB999999999XKBRHUD99C99999999NKZKEKWLDKMJCI9N9XQOLWEPAYWSH9999999999999999999999999KDDTGZLIPBNZKMLTOLOXQVNGLASESDQVPTXALEKRMIOHQLUHD9ELQDBQETS9QFGTYOYWLNTSKKMVJAUXSIROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999IROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999"]}'
*/
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
@POST("./")
Call<StoreTransactionsResponse> storeTransactions(@Body IotaStoreTransactionsRequest request);
}
@@ -7,9 +7,9 @@ public class IotaAttachToTangleRequest extends IotaCommandRequest {
private String trunkTransaction;
private String branchTransaction;
private Integer minWeightMagnitude;
private String [] trytes;
private String[] trytes;
private IotaAttachToTangleRequest(final String trunkTransaction, final String branchTransaction, final Integer minWeightMagnitude, final String ... trytes) {
private IotaAttachToTangleRequest(final String trunkTransaction, final String branchTransaction, final Integer minWeightMagnitude, final String... trytes) {
super(IotaAPICommands.ATTACH_TO_TANGLE);
this.trunkTransaction = trunkTransaction;
this.branchTransaction = branchTransaction;
@@ -17,7 +17,7 @@ public class IotaAttachToTangleRequest extends IotaCommandRequest {
this.trytes = trytes;
}
public static IotaAttachToTangleRequest createAttachToTangleRequest(final String trunkTransaction, final String branchTransaction, final Integer minWeightMagnitude, final String ... trytes) {
public static IotaAttachToTangleRequest createAttachToTangleRequest(final String trunkTransaction, final String branchTransaction, final Integer minWeightMagnitude, final String... trytes) {
return new IotaAttachToTangleRequest(trunkTransaction, branchTransaction, minWeightMagnitude, trytes);
}
}
@@ -4,14 +4,14 @@ import jota.IotaAPICommands;
public class IotaBroadcastTransactionRequest extends IotaCommandRequest {
private String [] trytes;
private String[] trytes;
private IotaBroadcastTransactionRequest(final String ... trytes) {
private IotaBroadcastTransactionRequest(final String... trytes) {
super(IotaAPICommands.BROADCAST_TRANSACTIONS);
this.trytes = trytes;
}
public static IotaBroadcastTransactionRequest createBroadcastTransactionsRequest(final String ... trytes) {
public static IotaBroadcastTransactionRequest createBroadcastTransactionsRequest(final String... trytes) {
return new IotaBroadcastTransactionRequest(trytes);
}
}
@@ -17,7 +17,7 @@ public class IotaCommandRequest {
public static IotaCommandRequest createGetTipsRequest() {
return new IotaCommandRequest(IotaAPICommands.GET_TIPS);
}
public static IotaCommandRequest createGetNeighborsRequest() {
return new IotaCommandRequest(IotaAPICommands.GET_NEIGHBORS);
}
@@ -4,35 +4,35 @@ import jota.IotaAPICommands;
public class IotaFindTransactionsRequest extends IotaCommandRequest {
private IotaFindTransactionsRequest() {
super(IotaAPICommands.FIND_TRANSACTIONS);
}
private String[] bundles; // List of bundle hashes. The hashes need to be extended to 81chars by padding the hash with 9's.
private String[] addresses;
private String[] tags;
private String[] approvees;
private String[] bundles; // List of bundle hashes. The hashes need to be extended to 81chars by padding the hash with 9's.
private String[] addresses;
private String[] digests;
private String[] approvees;
private IotaFindTransactionsRequest() {
super(IotaAPICommands.FIND_TRANSACTIONS);
}
public static IotaFindTransactionsRequest createFindTransactionRequest() {
return new IotaFindTransactionsRequest();
}
public IotaFindTransactionsRequest byBundles(String ... bundles) {
public IotaFindTransactionsRequest byBundles(String... bundles) {
this.bundles = bundles;
return this;
}
public IotaFindTransactionsRequest byAddresses(String ... addresses) {
public IotaFindTransactionsRequest byAddresses(String... addresses) {
this.addresses = addresses;
return this;
}
public IotaFindTransactionsRequest byDigests(String ... digests) {
this.digests = digests;
public IotaFindTransactionsRequest byTags(String... tags) {
this.tags = tags;
return this;
}
public IotaFindTransactionsRequest byApprovees(String ... approvees) {
public IotaFindTransactionsRequest byApprovees(String... approvees) {
this.approvees = approvees;
return this;
}
@@ -4,16 +4,16 @@ import jota.IotaAPICommands;
public class IotaGetBalancesRequest extends IotaCommandRequest {
private String [] addresses;
private String[] addresses;
private Integer threshold;
private IotaGetBalancesRequest(final Integer threshold, final String ... addresses) {
private IotaGetBalancesRequest(final Integer threshold, final String... addresses) {
super(IotaAPICommands.GET_BALANCES);
this.addresses = addresses;
this.threshold = threshold;
}
public static IotaGetBalancesRequest createIotaGetBalancesRequest(final Integer threshold, final String ... addresses) {
public static IotaGetBalancesRequest createIotaGetBalancesRequest(final Integer threshold, final String... addresses) {
return new IotaGetBalancesRequest(threshold, addresses);
}
@@ -3,27 +3,26 @@ package jota.dto.request;
import jota.IotaAPICommands;
import java.util.Collection;
import java.util.stream.Collectors;
public class IotaGetInclusionStateRequest extends IotaCommandRequest {
private String[] transactions;
private String[] tips;
private IotaGetInclusionStateRequest(final String[] transactions, final String[] tips) {
super(IotaAPICommands.GET_INCLUSIONS_STATES);
this.transactions = transactions;
this.tips = tips;
}
private String[] transactions;
private String[] tips;
public static IotaGetInclusionStateRequest createGetInclusionStateRequest(String[] transactions, String[] tips) {
return new IotaGetInclusionStateRequest(transactions, tips);
}
public static IotaGetInclusionStateRequest createGetInclusionStateRequest(Collection<String> transactions, Collection<String> tips) {
return createGetInclusionStateRequest(
transactions.toArray(new String[] {}),
tips.toArray(new String[] {}));
transactions.toArray(new String[]{}),
tips.toArray(new String[]{}));
}
}
@@ -4,14 +4,14 @@ import jota.IotaAPICommands;
public class IotaGetTrytesRequest extends IotaCommandRequest {
private String [] hashes;
private String[] hashes;
private IotaGetTrytesRequest(final String ... hashes) {
private IotaGetTrytesRequest(final String... hashes) {
super(IotaAPICommands.GET_TRYTES);
this.hashes = hashes;
}
public static IotaGetTrytesRequest createGetTrytesRequest(String ... hashes) {
public static IotaGetTrytesRequest createGetTrytesRequest(String... hashes) {
return new IotaGetTrytesRequest(hashes);
}
}
@@ -4,18 +4,18 @@ import jota.IotaAPICommands;
public class IotaNeighborsRequest extends IotaCommandRequest {
private String [] uris;
private String[] uris;
private IotaNeighborsRequest(IotaAPICommands type, final String ... uris) {
private IotaNeighborsRequest(IotaAPICommands type, final String... uris) {
super(type);
this.uris = uris;
}
public static IotaNeighborsRequest createAddNeighborsRequest(String ... uris) {
public static IotaNeighborsRequest createAddNeighborsRequest(String... uris) {
return new IotaNeighborsRequest(IotaAPICommands.ADD_NEIGHBORS, uris);
}
public static IotaNeighborsRequest createRemoveNeighborsRequest(String ... uris) {
public static IotaNeighborsRequest createRemoveNeighborsRequest(String... uris) {
return new IotaNeighborsRequest(IotaAPICommands.REMOVE_NEIGHBORS, uris);
}
}
@@ -4,14 +4,14 @@ import jota.IotaAPICommands;
public class IotaStoreTransactionsRequest extends IotaCommandRequest {
private String [] trytes;
private String[] trytes;
private IotaStoreTransactionsRequest(final String ... trytes) {
private IotaStoreTransactionsRequest(final String... trytes) {
super(IotaAPICommands.STORE_TRANSACTIONS);
this.trytes = trytes;
}
public static IotaStoreTransactionsRequest createStoreTransactionsRequest(final String ... trytes) {
public static IotaStoreTransactionsRequest createStoreTransactionsRequest(final String... trytes) {
return new IotaStoreTransactionsRequest(trytes);
}
}
@@ -34,39 +34,51 @@ public class AnalyzeTransactionResponse extends AbstractResponse {
public String getValue() {
return value;
}
public String getDigest() {
return digest;
}
public String getTrunkTransaction() {
return trunkTransaction;
}
public String getTimestamp() {
return timestamp;
}
public String getSignatureNonce() {
return signatureNonce;
}
public String getType() {
return type;
}
public String getAddress() {
return address;
}
public String getApprovalNonce() {
return approvalNonce;
}
public String getBranchTransaction() {
return branchTransaction;
}
public String getBundle() {
return bundle;
}
public String getHash() {
return hash;
}
public String getIndex() {
return index;
}
public String getSignatureMessageChunk() {
return signatureMessageChunk;
}
@@ -1,10 +1,10 @@
package jota.dto.response;
public class FindTransactionResponse extends AbstractResponse {
String [] addresses;
public String[] getAddresses() {
return addresses;
}
String[] hashes;
public String[] getHashes() {
return hashes;
}
}
@@ -2,7 +2,7 @@ package jota.dto.response;
public class GetAttachToTangleResponse extends AbstractResponse {
private String [] trytes;
private String[] trytes;
public String[] getTrytes() {
return trytes;
@@ -2,7 +2,7 @@ package jota.dto.response;
public class GetBalancesResponse extends AbstractResponse {
private String [] balances;
private String[] balances;
private String milestone;
private Integer milestoneIndex;
@@ -5,7 +5,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
public class GetBundleResponse extends AbstractResponse {
private Transactions[] transactions;
public Transactions[] transactions;
private String warning;
@@ -17,7 +17,7 @@ public class GetBundleResponse extends AbstractResponse {
return transactions;
}
static class Transactions {
public static class Transactions {
private String signatureMessageChunk;
private String index;
private String approvalNonce;
@@ -1,7 +1,8 @@
package jota.dto.response;
public class GetInclusionStateResponse extends AbstractResponse {
boolean [] states;
boolean[] states;
public boolean[] getStates() {
return states;
@@ -2,25 +2,32 @@ package jota.dto.response;
public class GetNeighborsResponse extends AbstractResponse {
private Neighbors[] neighbors;
public Neighbors[] neighbors;
public Neighbors[] getNeighbors() {
return neighbors;
}
static class Neighbors {
public static class Neighbors {
private String numberOfAllTransactions;
private String address;
private String numberOfNewTransactions;
private Integer numberOfAllTransactions;
private Integer numberOfInvalidTransactions;
private Integer numberOfNewTransactions;
public String getAddress() {
return address;
}
public String getNumberOfAllTransactions() {
public Integer getNumberOfAllTransactions() {
return numberOfAllTransactions;
}
public String getNumberOfNewTransactions() {
public Integer getNumberOfInvalidTransactions() {
return numberOfInvalidTransactions;
}
public Integer getNumberOfNewTransactions() {
return numberOfNewTransactions;
}
}
@@ -2,65 +2,80 @@ package jota.dto.response;
public class GetNodeInfoResponse extends AbstractResponse {
private String incomingPacketsBacklog;
private String appName;
private String transactionsToRequest;
private String jreTotalMemory;
private String time;
private String neighbors;
private String milestoneIndex;
private String appVersion;
private String jreAvailableProcessors;
private String jreMaxMemory;
private String tips;
private String jreFreeMemory;
public String getIncomingPacketsBacklog() {
return incomingPacketsBacklog;
}
private Integer jreAvailableProcessors;
private Integer jreFreeMemory;
private Integer jreMaxMemory;
private Integer jreTotalMemory;
private String latestMilestone;
private Long latestMilestoneIndex;
private String latestSolidSubtangleMilestone;
private Long latestSolidSubtangleMilestoneIndex;
private Long neighbors;
private Long packetsQueueSize;
private Long time;
private Long tips;
private Long transactionsToRequest;
public String getAppName() {
return appName;
}
public String getTransactionsToRequest() {
return transactionsToRequest;
}
public String getJreTotalMemory() {
return jreTotalMemory;
}
public String getTime() {
return time;
}
public String getNeighbors() {
return neighbors;
}
public String getMilestoneIndex() {
return milestoneIndex;
}
public String getAppVersion() {
return appVersion;
}
public String getJreAvailableProcessors() {
public Integer getJreAvailableProcessors() {
return jreAvailableProcessors;
}
public String getJreMaxMemory() {
return jreMaxMemory;
}
public String getTips() {
return tips;
}
public String getJreFreeMemory() {
public Integer getJreFreeMemory() {
return jreFreeMemory;
}
}
public Integer getJreMaxMemory() {
return jreMaxMemory;
}
public Integer getJreTotalMemory() {
return jreTotalMemory;
}
public String getLatestMilestone() {
return latestMilestone;
}
public Long getLatestMilestoneIndex() {
return latestMilestoneIndex;
}
public String getLatestSolidSubtangleMilestone() {
return latestSolidSubtangleMilestone;
}
public Long getLatestSolidSubtangleMilestoneIndex() {
return latestSolidSubtangleMilestoneIndex;
}
public Long getNeighbors() {
return neighbors;
}
public Long getPacketsQueueSize() {
return packetsQueueSize;
}
public Long getTime() {
return time;
}
public Long getTips() {
return tips;
}
public Long getTransactionsToRequest() {
return transactionsToRequest;
}
}
@@ -8,6 +8,7 @@ public class GetTransactionsToApproveResponse extends AbstractResponse {
public String getBranchTransactionToApprove() {
return branchTransactionToApprove;
}
public String getTrunkTransaction() {
return trunkTransaction;
}
@@ -6,27 +6,35 @@ import org.apache.commons.lang3.builder.ToStringStyle;
public class GetTransfersResponse extends AbstractResponse {
private Transfers[] transfers;
public Transfers[] getTransfers() {
return transfers;
}
public static class Transfers {
private String timestamp;
private String address;
private String hash;
private String persistence;
private String value;
private Integer persistence;
private long value;
public String getAddress() {
return address;
}
public String getHash() {
return hash;
}
public String getPersistence() {
public Integer getPersistence() {
return persistence;
}
public String getTimestamp() {
return timestamp;
}
public String getValue() {
public long getValue() {
return value;
}
@@ -35,8 +43,4 @@ public class GetTransfersResponse extends AbstractResponse {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public Transfers[] getTransfers() {
return transfers;
}
}
@@ -2,9 +2,9 @@ package jota.dto.response;
public class GetTrytesResponse extends AbstractResponse {
private String [] trites;
private String[] trytes;
public String[] getTrites() {
return trites;
public String[] getTrytes() {
return trytes;
}
}
+3 -5
View File
@@ -9,12 +9,10 @@ public class Converter {
public static final int NUMBER_OF_TRITS_IN_A_BYTE = 5;
public static final int NUMBER_OF_TRITS_IN_A_TRYTE = 3;
public static final String TRYTE_ALPHABET = "9ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static final int[][] BYTE_TO_TRITS_MAPPINGS = new int[243][];
static final int[][] TRYTE_TO_TRITS_MAPPINGS = new int[27][];
public static final String TRYTE_ALPHABET = "9ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static {
final int[] trits = new int[NUMBER_OF_TRITS_IN_A_BYTE];
@@ -39,7 +37,7 @@ public class Converter {
for (int j = (size - i * NUMBER_OF_TRITS_IN_A_BYTE) < 5 ? (size - i * NUMBER_OF_TRITS_IN_A_BYTE) : NUMBER_OF_TRITS_IN_A_BYTE; j-- > 0; ) {
value = value * RADIX + trits[offset + i * NUMBER_OF_TRITS_IN_A_BYTE + j];
}
bytes[i] = (byte)value;
bytes[i] = (byte) value;
}
return bytes;
@@ -76,7 +74,7 @@ public class Converter {
long absoluteValue = value < 0 ? -value : value;
for (int i = 0; i < size; i++) {
int remainder = (int)(absoluteValue % RADIX);
int remainder = (int) (absoluteValue % RADIX);
absoluteValue /= RADIX;
if (remainder > MAX_TRIT_VALUE) {
+2 -3
View File
@@ -2,9 +2,8 @@ package jota.utils;
/**
* (c) 2016 Come-from-Beyond
*
* <p>
* Curl belongs to the sponge function family.
*
*/
public class Curl {
@@ -25,7 +24,7 @@ public class Curl {
} while ((length -= HASH_LENGTH) > 0);
}
public int [] squeeze(final int[] trits, int offset, int length) {
public int[] squeeze(final int[] trits, int offset, int length) {
do {
System.arraycopy(state, 0, trits, offset, length < HASH_LENGTH ? length : HASH_LENGTH);
+3 -3
View File
@@ -17,9 +17,9 @@ public class IotaAPIUtils {
public static GetNewAddressResponse getNewAddress(final String seed, final int index) {
final int [] key = Signing.key(Converter.trits(seed), index, 2);
final int [] digests = Signing.digests(key);
final int [] addressTrits = Signing.address(digests);
final int[] key = Signing.key(Converter.trits(seed), index, 2);
final int[] digests = Signing.digests(key);
final int[] addressTrits = Signing.address(digests);
final String address = Converter.trytes(addressTrits);
return GetNewAddressResponse.create(address);
+8 -7
View File
@@ -6,7 +6,7 @@ import java.util.List;
public class Signing {
static int[] key(int [] seed, int index, int length) {
static int[] key(int[] seed, int index, int length) {
final int[] subseed = seed;
@@ -26,7 +26,7 @@ public class Signing {
curl.absorb(subseed, 0, subseed.length);
List<Integer> key = new ArrayList<>();
int [] buffer = new int[subseed.length];
int[] buffer = new int[subseed.length];
int offset = 0;
while (length-- > 0) {
@@ -43,21 +43,22 @@ public class Signing {
}
private static int[] to(List<Integer> key) {
int a [] = new int[key.size()]; int i = 0;
int a[] = new int[key.size()];
int i = 0;
for (Integer v : key) {
a[i++] = v;
}
return a;
}
public static int [] digests(int [] key) {
public static int[] digests(int[] key) {
final Curl curl = new Curl();
int[] digests = new int[key.length];
int[] buffer = new int[key.length];
for (int i = 0; i < Math.floor(key.length / 6561); i++) {
int [] keyFragment = Arrays.copyOfRange(key, i * 6561, (i + 1) * 6561);
int[] keyFragment = Arrays.copyOfRange(key, i * 6561, (i + 1) * 6561);
for (int j = 0; j < 27; j++) {
@@ -83,9 +84,9 @@ public class Signing {
return digests;
}
public static int [] address(int [] digests) {
public static int[] address(int[] digests) {
final Curl curl = new Curl();
int [] address = new int[digests.length];
int[] address = new int[digests.length];
curl.absorb(digests, 0, digests.length);
curl.squeeze(address, 0, address.length);
return address;
+4 -5
View File
@@ -1,19 +1,18 @@
package jota;
import static org.junit.Assert.assertThat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import jota.dto.response.*;
import jota.utils.IotaAPIUtils;
import org.hamcrest.core.IsNull;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertThat;
/**
* Let's do some integration test coverage against a default local real node.
*
*
* @author davassi
*/
public class IotaAPIProxyTest {
@@ -130,4 +129,4 @@ public class IotaAPIProxyTest {
System.err.println(res);
}
}
}