mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2026-08-31 05:10:25 +00:00
rerranged entries, optimized imports
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -19,15 +19,15 @@ 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 {
|
||||
@@ -35,6 +35,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;
|
||||
@@ -43,7 +44,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() {
|
||||
|
||||
@@ -75,12 +97,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();
|
||||
}
|
||||
@@ -103,19 +125,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);
|
||||
}
|
||||
|
||||
@@ -131,7 +153,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();
|
||||
}
|
||||
@@ -141,7 +163,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();
|
||||
}
|
||||
@@ -151,36 +173,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);
|
||||
}
|
||||
@@ -189,20 +198,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) {
|
||||
@@ -252,7 +251,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;
|
||||
|
||||
@@ -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": ["BYSWEAUTWXHXZ9YBZISEK9LUHWGMHXCGEVNZHRLUWQFCUSDXZHOFHWHL9MQPVJXXZLIXPXPXF9KYEREFSKCPKYIIKPZVLHUTDFQKKVVBBN9ATTLPCNPJDWDEVIYYLGPZGCWXOBDXMLJC9VO9QXTTBLAXTTBFUAROYEGQIVB9MJWJKXJMCUPTWAUGFZBTZCSJVRBGMYXTVBDDS9MYUJCPZ9YDWWQNIPUAIJXXSNLKUBSCOIJPCLEFPOXFJREXQCUVUMKSDOVQGGHRNILCO9GNCLWFM9APMNMWYASHXQAYBEXF9QRIHIBHYEJOYHRQJAOKAQ9AJJFQ9WEIWIJOTZATIBOXQLBMIJU9PCGBLVDDVFP9CFFSXTDUXMEGOOFXWRTLFGV9XXMYWEMGQEEEDBTIJ9OJOXFAPFQXCDAXOUDMLVYRMRLUDBET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CFAIKTGNRSQGUNIYZCRT9FOWENSZQPD9ALUPYYAVICHVYELYFPUYDTWUSWNIYFXPX9MICCCOOZIWRNJIDALWGWRATGLJXNAYTNIZWQ9YTVDBOFZRKO9CFWRPAQQRXTPACOWCPRLYRYSJARRKSQPR9TCFXDVIXLP9XVL99ERRDSOHBFJDJQQGGGCZNDQ9NYCTQJWVZIAELCRBJJFDMCNZU9FIZRPGNURTXOCDSQGXTQHKHUECGWFUUYS9J9NYQ9U9P9UUP9YMZHWWWCIASCFLCMSKTELZWUGCDE9YOKVOVKTAYPHDF9ZCCQAYPJIJNGSHUIHHCOSSOOBUDOKE9CJZGYSSGNCQJVBEFTZFJ9SQUHOASKRRGBSHWKBCBWBTJHOGQ9WOMQFHWJVEG9NYX9KWBTCAIXNXHEBDIOFO9ALYMFGRICLCKKLG9FOBOX9PDWNQRGHBKHGKKRLWTBEQMCWQRLHAVYYZDIIPKVQTHYTWQMTOACXZOQCDTJTBAAUWXSGJF9PNQIJ9AJRUMUVCPWYVYVARKR9RKGOUHHNKNVGGPDDLGKPQNOYHNKAVVKCXWXOQPZNSLATUJT9AUWRMPPSWHSTTYDFAQDXOCYTZHOYYGAIM9CELMZ9AZPWB9MJXGHOKDNNSZVUDAGXTJJSSZCPZVPZBYNNTUQABSXQWZCHDQSLGK9UOHCFKBIBNETK999999999999999999999999999999999999999999999999999999999999999999999999999999999NOXDXXKUDWLOFJLIPQIBRBMGDYCPGDNLQOLQS99EQYKBIU9VHCJVIPFUYCQDNY9APGEVYLCENJIOBLWNB999999999XKBRHUD99C99999999NKZKEKWLDKMJCI9N9XQOLWEPAYWSH9999999999999999999999999KDDTGZLIPBNZKMLTOLOXQVNGLASESDQVPTXALEKRMIOHQLUHD9ELQDBQETS9QFGTYOYWLNTSKKMVJAUXSIROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999IROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999"]}
|
||||
*/
|
||||
@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": ["BYSWEAUTWXHXZ9YBZISEK9LUHWGMHXCGEVNZHRLUWQFCUSDXZHOFHWHL9MQPVJXXZLIXPXPXF9KYEREFSKCPKYIIKPZVLHUTDFQKKVVBBN9ATTLPCNPJDWDEVIYYLGPZGCWXOBDXMLJC9VO9QXTTBLAXTTBFUAROYEGQIVB9MJWJKXJMCUPTWAUGFZBTZCSJVRBGMYXTVBDDS9MYUJCPZ9YDWWQNIPUAIJXXSNLKUBSCOIJPCLEFPOXFJREXQCUVUMKSDOVQGGHRNILCO9GNCLWFM9APMNMWYASHXQAYBEXF9QRIHIBHYEJOYHRQJAOKAQ9AJJFQ9WEIWIJOTZATIBOXQLBMIJU9PCGBLVDDVFP9CFFSXTDUXMEGOOFXWRTLFGV9XXMYWEMGQEEEDBTIJ9OJOXFAPFQXCDAXOUDMLVYRMRLUDBETOLRJQAEDDLNVIRQJUBZBO9CCFDHIX9MSQCWYAXJVWHCUPTRSXJDESISQPRKZAFKFRULCGVRSBLVFOPEYLEE99JD9SEBALQINPDAZHFAB9RNBH9AZWIJOTLBZVIEJIAYGMC9AZGNFWGRSWAXTYSXVROVNKCOQQIWGPNQZKHUNODGYADPYLZZZUQRTJRTODOUKAOITNOMWNGHJBBA99QUMBHRENGBHTH9KHUAOXBVIVDVYYZMSEYSJWIOGGXZVRGN999EEGQMCOYVJQRIRROMPCQBLDYIGQO9AMORPYFSSUGACOJXGAQSPD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HDF9ZCCQAYPJIJNGSHUIHHCOSSOOBUDOKE9CJZGYSSGNCQJVBEFTZFJ9SQUHOASKRRGBSHWKBCBWBTJHOGQ9WOMQFHWJVEG9NYX9KWBTCAIXNXHEBDIOFO9ALYMFGRICLCKKLG9FOBOX9PDWNQRGHBKHGKKRLWTBEQMCWQRLHAVYYZDIIPKVQTHYTWQMTOACXZOQCDTJTBAAUWXSGJF9PNQIJ9AJRUMUVCPWYVYVARKR9RKGOUHHNKNVGGPDDLGKPQNOYHNKAVVKCXWXOQPZNSLATUJT9AUWRMPPSWHSTTYDFAQDXOCYTZHOYYGAIM9CELMZ9AZPWB9MJXGHOKDNNSZVUDAGXTJJSSZCPZVPZBYNNTUQABSXQWZCHDQSLGK9UOHCFKBIBNETK999999999999999999999999999999999999999999999999999999999999999999999999999999999NOXDXXKUDWLOFJLIPQIBRBMGDYCPGDNLQOLQS99EQYKBIU9VHCJVIPFUYCQDNY9APGEVYLCENJIOBLWNB999999999XKBRHUD99C99999999NKZKEKWLDKMJCI9N9XQOLWEPAYWSH9999999999999999999999999KDDTGZLIPBNZKMLTOLOXQVNGLASESDQVPTXALEKRMIOHQLUHD9ELQDBQETS9QFGTYOYWLNTSKKMVJAUXSIROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999IROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999"]}'
|
||||
*/
|
||||
@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[] 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 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 byTags(String ... tags) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,23 +6,23 @@ import java.util.Collection;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package jota.dto.response;
|
||||
|
||||
public class GetInclusionStateResponse extends AbstractResponse {
|
||||
boolean [] states;
|
||||
|
||||
boolean[] states;
|
||||
|
||||
public boolean[] getStates() {
|
||||
return states;
|
||||
|
||||
@@ -18,6 +18,7 @@ public class GetNeighborsResponse extends AbstractResponse {
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public String getNumberOfAllTransactions() {
|
||||
return numberOfAllTransactions;
|
||||
}
|
||||
@@ -25,6 +26,7 @@ public class GetNeighborsResponse extends AbstractResponse {
|
||||
public String getNumberOfInvalidTransactions() {
|
||||
return numberOfInvalidTransactions;
|
||||
}
|
||||
|
||||
public String getNumberOfNewTransactions() {
|
||||
return numberOfNewTransactions;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ public class GetTransactionsToApproveResponse extends AbstractResponse {
|
||||
public String getBranchTransactionToApprove() {
|
||||
return branchTransactionToApprove;
|
||||
}
|
||||
|
||||
public String getTrunkTransaction() {
|
||||
return trunkTransaction;
|
||||
}
|
||||
|
||||
@@ -6,26 +6,34 @@ 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;
|
||||
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public String getPersistence() {
|
||||
return persistence;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public String 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user