mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2026-10-04 05:26:59 +00:00
added more documentation
This commit is contained in:
@@ -14,13 +14,13 @@ import java.util.*;
|
||||
|
||||
/**
|
||||
* IotaAPI Builder. Usage:
|
||||
* <p>
|
||||
*
|
||||
* IotaApiProxy api = IotaApiProxy.Builder
|
||||
* .protocol("http")
|
||||
* .nodeAddress("localhost")
|
||||
* .port(12345)
|
||||
* .build();
|
||||
* <p>
|
||||
*
|
||||
* GetNodeInfoResponse response = api.getNodeInfo();
|
||||
*
|
||||
* @author davassi
|
||||
@@ -730,7 +730,6 @@ public class IotaAPI extends IotaAPICore {
|
||||
* @throws InvalidBundleException is thrown if an invalid bundle was found or provided.
|
||||
* @throws ArgumentException is thrown when an invalid argument is provided.
|
||||
* @throws InvalidSignatureException is thrown when an invalid signature is encountered.
|
||||
* @throws InvalidTransferException is thrown when an invalid transfer is provided.
|
||||
*/
|
||||
public ReplayBundleResponse replayBundle(String transaction, int depth, int minWeightMagnitude) throws InvalidBundleException, ArgumentException, InvalidSignatureException, InvalidTrytesException {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
||||
@@ -2,50 +2,42 @@ package jota;
|
||||
|
||||
/**
|
||||
* IOTA's node command list
|
||||
* <p>
|
||||
* 'params' is not currently used.
|
||||
*
|
||||
*/
|
||||
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),
|
||||
ATTACH_TO_TANGLE("attachToTangle", 0),
|
||||
INTERRUPT_ATTACHING_TO_TANGLE("interruptAttachingToTangle", 0),
|
||||
BROADCAST_TRANSACTIONS("broadcastTransactions", 0),
|
||||
STORE_TRANSACTIONS("storeTransactions", 0);
|
||||
GET_NODE_INFO("getNodeInfo"),
|
||||
GET_NEIGHBORS("getNeighbors"),
|
||||
ADD_NEIGHBORS("addNeighbors"),
|
||||
REMOVE_NEIGHBORS("removeNeighbors"),
|
||||
GET_TIPS("getTips"),
|
||||
FIND_TRANSACTIONS("findTransactions"),
|
||||
GET_TRYTES("getTrytes"),
|
||||
GET_INCLUSIONS_STATES("getInclusionStates"),
|
||||
GET_BALANCES("getBalances"),
|
||||
GET_TRANSACTIONS_TO_APPROVE("getTransactionsToApprove"),
|
||||
ATTACH_TO_TANGLE("attachToTangle"),
|
||||
INTERRUPT_ATTACHING_TO_TANGLE("interruptAttachingToTangle"),
|
||||
BROADCAST_TRANSACTIONS("broadcastTransactions"),
|
||||
STORE_TRANSACTIONS("storeTransactions");
|
||||
|
||||
private String command;
|
||||
private int params;
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* @param params
|
||||
* Initializes a new instance of the IotaAPICommands class.
|
||||
*/
|
||||
IotaAPICommands(String command, int params) {
|
||||
IotaAPICommands(String command) {
|
||||
this.command = command;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* Gets the command.
|
||||
*
|
||||
* @return The command.
|
||||
*/
|
||||
public String command() {
|
||||
return command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int params() {
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,11 +53,6 @@ public class IotaAPICore {
|
||||
postConstruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param call
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
protected static <T> Response<T> wrapCheckedException(final Call<T> call) {
|
||||
try {
|
||||
final Response<T> res = call.execute();
|
||||
@@ -85,11 +80,6 @@ public class IotaAPICore {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param env
|
||||
* @param def
|
||||
* @return
|
||||
*/
|
||||
private static String env(String env, String def) {
|
||||
final String value = System.getenv(env);
|
||||
if (value == null) {
|
||||
@@ -101,7 +91,7 @@ public class IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* added header for IRI 1.4.1
|
||||
* added header for IRI
|
||||
*/
|
||||
private void postConstruct() {
|
||||
|
||||
@@ -138,31 +128,62 @@ public class IotaAPICore {
|
||||
log.debug("Jota-API Java proxy pointing to node url: '{}'", nodeUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the node information.
|
||||
*
|
||||
* @return The information about your node.
|
||||
*/
|
||||
public GetNodeInfoResponse getNodeInfo() {
|
||||
final Call<GetNodeInfoResponse> res = service.getNodeInfo(IotaCommandRequest.createNodeInfoRequest());
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of neighbors from your node.
|
||||
*
|
||||
* @return The set of neighbors you are connected with.
|
||||
*/
|
||||
public GetNeighborsResponse getNeighbors() {
|
||||
final Call<GetNeighborsResponse> res = service.getNeighbors(IotaCommandRequest.createGetNeighborsRequest());
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a list of neighbors to your node.
|
||||
*
|
||||
* @param uris The list of URI elements.
|
||||
*/
|
||||
public AddNeighborsResponse addNeighbors(String... uris) {
|
||||
final Call<AddNeighborsResponse> res = service.addNeighbors(IotaNeighborsRequest.createAddNeighborsRequest(uris));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a list of neighbors from your node.
|
||||
*
|
||||
* @param uris The list of URI elements.
|
||||
*/
|
||||
public RemoveNeighborsResponse removeNeighbors(String... uris) {
|
||||
final Call<RemoveNeighborsResponse> res = service.removeNeighbors(IotaNeighborsRequest.createRemoveNeighborsRequest(uris));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of latest tips (unconfirmed transactions).
|
||||
*
|
||||
* @return The the list of tips.
|
||||
*/
|
||||
public GetTipsResponse getTips() {
|
||||
final Call<GetTipsResponse> res = service.getTips(IotaCommandRequest.createGetTipsRequest());
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find the transactions which match the specified input
|
||||
*
|
||||
* @return The transaction hashes which are returned depend on your input.
|
||||
*/
|
||||
public FindTransactionResponse findTransactions(String[] addresses, String[] tags, String[] approvees, String[] bundles) {
|
||||
|
||||
final IotaFindTransactionsRequest findTransRequest = IotaFindTransactionsRequest
|
||||
@@ -176,52 +197,115 @@ public class IotaAPICore {
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the transactions by addresses
|
||||
*
|
||||
* @param addresses A List of addresses.
|
||||
* @return The transaction hashes which are returned depend on your input.
|
||||
*/
|
||||
public FindTransactionResponse findTransactionsByAddresses(final String... addresses) {
|
||||
return findTransactions(addresses, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the transactions by bundles
|
||||
*
|
||||
* @param bundles A List of bundles.
|
||||
* @return The transaction hashes which are returned depend on your input.
|
||||
*/
|
||||
public FindTransactionResponse findTransactionsByBundles(final String... bundles) {
|
||||
return findTransactions(null, null, null, bundles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the transactions by approvees
|
||||
*
|
||||
* @param approvees A List of approvess.
|
||||
* @return The transaction hashes which are returned depend on your input.
|
||||
*/
|
||||
public FindTransactionResponse findTransactionsByApprovees(final String... approvees) {
|
||||
return findTransactions(null, null, approvees, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find the transactions by digests
|
||||
*
|
||||
* @param digests A List of digests.
|
||||
* @return The transaction hashes which are returned depend on your input.
|
||||
*/
|
||||
public FindTransactionResponse findTransactionsByDigests(final String... digests) {
|
||||
return findTransactions(null, digests, null, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the inclusion states of a set of transactions. This is for determining if a transaction was accepted and confirmed by the network or not. You can search for multiple tips (and thus, milestones) to get past inclusion states of transactions.
|
||||
*
|
||||
* @param transactions The ist of transactions you want to get the inclusion state for.
|
||||
* @param tips ThelList of tips (including milestones) you want to search for the inclusion state.
|
||||
* @return The inclusion states of a set of transactions.
|
||||
*/
|
||||
public GetInclusionStateResponse getInclusionStates(String[] transactions, String[] tips) {
|
||||
final Call<GetInclusionStateResponse> res = service.getInclusionStates(IotaGetInclusionStateRequest
|
||||
.createGetInclusionStateRequest(transactions, tips));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw trytes data of a transaction.
|
||||
*
|
||||
* @param hashes The of transaction hashes of which you want to get trytes from.
|
||||
* @return The the raw transaction data (trytes) of a specific transaction.
|
||||
*/
|
||||
public GetTrytesResponse getTrytes(String... hashes) {
|
||||
final Call<GetTrytesResponse> res = service.getTrytes(IotaGetTrytesRequest.createGetTrytesRequest(hashes));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tip selection which returns trunkTransaction and branchTransaction. The input value is the latest coordinator milestone, as provided through the getNodeInfo API call.
|
||||
*
|
||||
* @param depth The number of bundles to go back to determine the transactions for approval.
|
||||
* @return The Tip selection which returns trunkTransaction and branchTransaction
|
||||
*/
|
||||
public GetTransactionsToApproveResponse getTransactionsToApprove(Integer depth) {
|
||||
final Call<GetTransactionsToApproveResponse> res = service.getTransactionsToApprove(IotaGetTransactionsToApproveRequest.createIotaGetTransactionsToApproveRequest(depth));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* It returns the confirmed balance which a list of addresses have at the latest confirmed milestone.
|
||||
*
|
||||
* @param threshold The confirmation threshold, should be set to 100.
|
||||
* @param addresses The array list of addresses you want to get the confirmed balance from.
|
||||
* @return The confirmed balance which a list of addresses have at the latest confirmed milestone.
|
||||
*/
|
||||
public GetBalancesResponse getBalances(Integer threshold, String[] addresses) {
|
||||
final Call<GetBalancesResponse> res = service.getBalances(IotaGetBalancesRequest.createIotaGetBalancesRequest(threshold, addresses));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* It returns the confirmed balance which a list of addresses have at the latest confirmed milestone.
|
||||
*
|
||||
* @param threshold The confirmation threshold, should be set to 100.
|
||||
* @param addresses The list of addresses you want to get the confirmed balance from.
|
||||
* @return The confirmed balance which a list of addresses have at the latest confirmed milestone.
|
||||
*/
|
||||
public GetBalancesResponse getBalances(Integer threshold, List<String> addresses) {
|
||||
return getBalances(threshold, addresses.toArray(new String[]{}));
|
||||
}
|
||||
|
||||
public InterruptAttachingToTangleResponse interruptAttachingToTangle() {
|
||||
final Call<InterruptAttachingToTangleResponse> res = service.interruptAttachingToTangle(IotaCommandRequest.createInterruptAttachToTangleRequest());
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the specified transactions (trytes) to the Tangle by doing Proof of Work.
|
||||
*
|
||||
* @param trunkTransaction The trunk transaction to approve.
|
||||
* @param branchTransaction The branch transaction to approve.
|
||||
* @param minWeightMagnitude The Proof of Work intensity.
|
||||
* @param trytes A List of trytes (raw transaction data) to attach to the tangle.
|
||||
*/
|
||||
public GetAttachToTangleResponse attachToTangle(String trunkTransaction, String branchTransaction, Integer minWeightMagnitude, String... trytes) throws InvalidTrytesException {
|
||||
if (!InputValidator.isArrayOfTrytes(trytes)) {
|
||||
throw new InvalidTrytesException();
|
||||
@@ -249,29 +333,61 @@ public class IotaAPICore {
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
public StoreTransactionsResponse storeTransactions(String... trytes) {
|
||||
final Call<StoreTransactionsResponse> res = service.storeTransactions(IotaStoreTransactionsRequest.createStoreTransactionsRequest(trytes));
|
||||
/**
|
||||
* Interrupts and completely aborts the attachToTangle process.
|
||||
*/
|
||||
public InterruptAttachingToTangleResponse interruptAttachingToTangle() {
|
||||
final Call<InterruptAttachingToTangleResponse> res = service.interruptAttachingToTangle(IotaCommandRequest.createInterruptAttachToTangleRequest());
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast a list of transactions to all neighbors. The input trytes for this call are provided by attachToTangle.
|
||||
*
|
||||
* @param trytes The list of raw data of transactions to be rebroadcast.
|
||||
*/
|
||||
public BroadcastTransactionsResponse broadcastTransactions(String... trytes) {
|
||||
final Call<BroadcastTransactionsResponse> res = service.broadcastTransactions(IotaBroadcastTransactionRequest.createBroadcastTransactionsRequest(trytes));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* Store transactions into the local storage. The trytes to be used for this call are returned by attachToTangle.
|
||||
*
|
||||
* @param trytes The list of raw data of transactions to be rebroadcast.
|
||||
*/
|
||||
public StoreTransactionsResponse storeTransactions(String... trytes) {
|
||||
final Call<StoreTransactionsResponse> res = service.storeTransactions(IotaStoreTransactionsRequest.createStoreTransactionsRequest(trytes));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the protocol.
|
||||
*
|
||||
* @return The protocol to use when connecting to the remote node.
|
||||
*/
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the host.
|
||||
*
|
||||
* @return The host you want to connect to.
|
||||
*/
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the port.
|
||||
*
|
||||
* @return The port of the host you want to connect to.
|
||||
*/
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static class Builder<T extends Builder<T>> {
|
||||
String protocol, host, port;
|
||||
IotaLocalPoW localPoW;
|
||||
@@ -332,37 +448,21 @@ public class IotaAPICore {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param host
|
||||
* @return
|
||||
*/
|
||||
public T host(String host) {
|
||||
this.host = host;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param port
|
||||
* @return
|
||||
*/
|
||||
public T port(String port) {
|
||||
this.port = port;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param protocol
|
||||
* @return
|
||||
*/
|
||||
public T protocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param localPoW
|
||||
* @return
|
||||
*/
|
||||
public T localPoW(IotaLocalPoW localPoW) {
|
||||
this.localPoW = localPoW;
|
||||
return (T) this;
|
||||
|
||||
@@ -19,20 +19,18 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Returns information about your node.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getNodeInfo"}'
|
||||
*
|
||||
* @return a {@code NodeInfoResponse} object, if succesfull.
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getNodeInfo"}'
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
@POST("./")
|
||||
Call<GetNodeInfoResponse> getNodeInfo(@Body IotaCommandRequest request);
|
||||
|
||||
/**
|
||||
* Get the list of latest tips (unconfirmed transactions).
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
* Get the list of neighbors from your node.
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getNeighbors"}'
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
@@ -41,8 +39,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Add a list of neighbors to your node.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -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})
|
||||
@@ -51,8 +49,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Removes a list of neighbors to your node.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -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})
|
||||
@@ -61,8 +59,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Get the list of latest tips (unconfirmed transactions).
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getTips"}'
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
@@ -71,7 +69,7 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Find the transactions which match the specified input and return
|
||||
* <p>
|
||||
*
|
||||
* curl http://localhost:14265 \ -X POST \ -H 'Content-Type: application/json' \
|
||||
* -d '{"command": "findTransactions", "addresses": ["RVORZ9SIIP9RCYMREUIXXVPQIPHVCNPQ9HZWYKFWYWZRE9JQKG9REPKIASHUUECPSQO9JT9XNMVKWYGVAZETAIRPTM"]}'
|
||||
*/
|
||||
@@ -82,8 +80,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Get the inclusion states of a set of transactions. This is for determining if a transaction was accepted and confirmed by the network or not. You can search for multiple tips (and thus, milestones) to get past inclusion states of transactions.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getInclusionStates", "transactions"Q9HZWYKFWYWZRE9JQKG9REPKIASHUUECPSQO9JT9XNMVKWYGVAZETAIRPTM"], "tips" : []}'
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
@@ -92,8 +90,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Returns the raw trytes data of a transaction.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getTrytes", "hashes": ["OAATQS9VQLSXCLDJVJJVYUGONXAXOFMJOZNSYWRZSWECMXAQQURHQBJNLD9IOFEPGZEPEMPXCIVRX9999"]}'
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
@@ -102,8 +100,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Tip selection which returns trunkTransaction and branchTransaction. The input value is the latest coordinator milestone, as provided through the getNodeInfo API call.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getTransactionsToApprove", "depth": 27}'
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
@@ -112,8 +110,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* It returns the confirmed balance which a list of addresses have at the latest confirmed milestone.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getBalances", "addresses": ["HBBYKAKTILIPVUKFOTSLHGENPTXYBNKXZFQFR9VQFWNBMTQNRVOUKPVPRNBSZVVILMAFBKOTBLGLWLOHQ"], "threshold": 100}'
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
@@ -122,8 +120,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Attaches the specified transactions (trytes) to the Tangle by doing Proof of Work.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'
|
||||
* -d '{"command": "attachToTangle", "trunkTransaction": "JVMTDGDPDFYHMZPMWEKKANBQSLSDTIIHAYQUMZOKHXXXGJHJDQPOMDOMNRDKYCZRUFZROZDADTHZC9999", "branchTransaction": "P9KFSJVGSPLXAEBJSHWFZLGP9GGJTIO9YITDEHATDTGAFLPLBZ9FOFWWTKMAZXZHFGQHUOXLXUALY9999", "minWeightMagnitude": 18, "trytes": ["TRYTVALUEHERE"]}'
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
@@ -132,8 +130,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Interrupts and completely aborts the attachToTangle process.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'
|
||||
* -d '{"command": "interruptAttachingToTangle" }
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
@@ -142,8 +140,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Broadcast a list of transactions to all neighbors. The input trytes for this call are provided by attachToTangle.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'
|
||||
* -d '{"command": "broadcastTransactions", "trytes": ["BYSWEAUTWXHXZ9YBZISEK9LUHWGMHXCGEVNZHRLUWQFCUSDXZHOFHWHL9MQPVJXXZLIXPXPXF9KYEREFSKCPKYIIKPZVLHUTDFQKKVVBBN9ATTLPCNPJDWDEVIYYLGPZGCWXOBDXMLJC9VO9QXTTBLAXTTBFUAROYEGQIVB9MJWJKXJMCUPTWAUGFZBTZCSJVRBGMYXTVBDDS9MYUJCPZ9YDWWQNIPUAIJXXSNLKUBSCOIJPCLEFPOXFJREXQCUVUMKSDOVQGGHRNILCO9GNCLWFM9APMNMWYASHXQAYBEXF9QRIHIBHYEJOYHRQJAOKAQ9AJJFQ9WEIWIJOTZATIBOXQLBMIJU9PCGBLVDDVFP9CFFSXTDUXMEGOOFXWRTLFGV9XXMYWEMGQEEEDBTIJ9OJOXFAPFQXCDAXOUDMLVYRMRLUDBETOLRJQAEDDLNVIRQJUBZBO9CCFDHIX9MSQCWYAXJVWHCUPTRSXJDESISQPRKZAFKFRULCGVRSBLVFOPEYLEE99JD9SEBALQINPDAZHFAB9RNBH9AZWIJOTLBZVIEJIAYGMC9AZGNFWGRSWAXTYSXVROVNKCOQQIWGPNQZKHUNODGYADPYLZZZUQRTJRTODOUKAOITNOMWNGHJBBA99QUMBHRENGBHTH9KHUAOXBVIVDVYYZMSEYSJWIOGGXZVRGN999EEGQMCOYVJQRIRROMPCQBLDYIGQO9AMORPYFSSUGACOJXGAQSPDY9YWRRPESNXXBDQ9OZOXVIOMLGTSWAMKMTDRSPGJKGBXQIVNRJRF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TZFJ9SQUHOASKRRGBSHWKBCBWBTJHOGQ9WOMQFHWJVEG9NYX9KWBTCAIXNXHEBDIOFO9ALYMFGRICLCKKLG9FOBOX9PDWNQRGHBKHGKKRLWTBEQMCWQRLHAVYYZDIIPKVQTHYTWQMTOACXZOQCDTJTBAAUWXSGJF9PNQIJ9AJRUMUVCPWYVYVARKR9RKGOUHHNKNVGGPDDLGKPQNOYHNKAVVKCXWXOQPZNSLATUJT9AUWRMPPSWHSTTYDFAQDXOCYTZHOYYGAIM9CELMZ9AZPWB9MJXGHOKDNNSZVUDAGXTJJSSZCPZVPZBYNNTUQABSXQWZCHDQSLGK9UOHCFKBIBNETK999999999999999999999999999999999999999999999999999999999999999999999999999999999NOXDXXKUDWLOFJLIPQIBRBMGDYCPGDNLQOLQS99EQYKBIU9VHCJVIPFUYCQDNY9APGEVYLCENJIOBLWNB999999999XKBRHUD99C99999999NKZKEKWLDKMJCI9N9XQOLWEPAYWSH9999999999999999999999999KDDTGZLIPBNZKMLTOLOXQVNGLASESDQVPTXALEKRMIOHQLUHD9ELQDBQETS9QFGTYOYWLNTSKKMVJAUXSIROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999IROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999"]}
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
@@ -152,8 +150,8 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Store transactions into the local storage. The trytes to be used for this call are returned by attachToTangle.
|
||||
* <p>
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'
|
||||
* -d '{"command": "storeTransactions", "trytes": ["BYSWEAUTWXHXZ9YBZISEK9LU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ZPWB9MJXGHOKDNNSZVUDAGXTJJSSZCPZVPZBYNNTUQABSXQWZCHDQSLGK9UOHCFKBIBNETK999999999999999999999999999999999999999999999999999999999999999999999999999999999NOXDXXKUDWLOFJLIPQIBRBMGDYCPGDNLQOLQS99EQYKBIU9VHCJVIPFUYCQDNY9APGEVYLCENJIOBLWNB999999999XKBRHUD99C99999999NKZKEKWLDKMJCI9N9XQOLWEPAYWSH9999999999999999999999999KDDTGZLIPBNZKMLTOLOXQVNGLASESDQVPTXALEKRMIOHQLUHD9ELQDBQETS9QFGTYOYWLNTSKKMVJAUXSIROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999IROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999"]}'
|
||||
*/
|
||||
@Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
|
||||
|
||||
@@ -4,7 +4,7 @@ import jota.IotaAPICommands;
|
||||
|
||||
/**
|
||||
* This class represents the core API request 'attachToTangle'.
|
||||
* <p>
|
||||
*
|
||||
* It is used to attach trytes to the tangle.
|
||||
**/
|
||||
public class IotaAttachToTangleRequest extends IotaCommandRequest {
|
||||
|
||||
@@ -4,7 +4,7 @@ import jota.IotaAPICommands;
|
||||
|
||||
/**
|
||||
* This class represents the core API request 'broadcastTransaction'.
|
||||
* <p>
|
||||
*
|
||||
* Broadcast a list of transactions to all neighbors. The input trytes for this call are provided by attachToTangle
|
||||
**/
|
||||
public class IotaBroadcastTransactionRequest extends IotaCommandRequest {
|
||||
|
||||
@@ -10,7 +10,7 @@ public class IotaCommandRequest {
|
||||
final String command;
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* Initializes a new instance of the IotaCommandRequest class.
|
||||
*/
|
||||
protected IotaCommandRequest(IotaAPICommands command) {
|
||||
this.command = command.command();
|
||||
|
||||
@@ -4,7 +4,7 @@ import jota.IotaAPICommands;
|
||||
|
||||
/**
|
||||
* This class represents the core API request 'getTransactionsToApprove'.
|
||||
* <p>
|
||||
*
|
||||
* It stores transactions into the local storage. The trytes to be used for this call are returned by attachToTangle.
|
||||
**/
|
||||
public class IotaStoreTransactionsRequest extends IotaCommandRequest {
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* (c) 2016 Come-from-Beyond
|
||||
* <p>
|
||||
*
|
||||
* JCurl belongs to the sponge function family.
|
||||
*/
|
||||
public class JCurl implements ICurl {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Signing {
|
||||
* public Signing() {
|
||||
* this(null);
|
||||
* }
|
||||
* <p>
|
||||
*
|
||||
* /**
|
||||
*
|
||||
* @param curl
|
||||
|
||||
@@ -10,7 +10,7 @@ public class StopWatch {
|
||||
private long currentTime = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* Initializes a new instance of the StopWatch class.
|
||||
*/
|
||||
public StopWatch() {
|
||||
this.startTime = System.currentTimeMillis();
|
||||
@@ -26,7 +26,7 @@ public class StopWatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public StopWatch stop() {
|
||||
this.running = false;
|
||||
@@ -52,7 +52,7 @@ public class StopWatch {
|
||||
/**
|
||||
* Elapsed time in milliseconds.
|
||||
*
|
||||
* @return
|
||||
* @return The elapsed time in milliseconds.
|
||||
*/
|
||||
public long getElapsedTimeMili() {
|
||||
long elapsed = 0;
|
||||
@@ -65,7 +65,7 @@ public class StopWatch {
|
||||
/**
|
||||
* Elapsed time in seconds.
|
||||
*
|
||||
* @return
|
||||
* @return The elapsed time in seconds.
|
||||
*/
|
||||
public long getElapsedTimeSecs() {
|
||||
long elapsed = 0;
|
||||
@@ -78,7 +78,7 @@ public class StopWatch {
|
||||
/**
|
||||
* Elapsed time in minutes.
|
||||
*
|
||||
* @return
|
||||
* @return The elapsed time in minutes.
|
||||
*/
|
||||
public long getElapsedTimeMin() {
|
||||
long elapsed = 0;
|
||||
@@ -91,7 +91,7 @@ public class StopWatch {
|
||||
/**
|
||||
* Elapsed time in hours.
|
||||
*
|
||||
* @return
|
||||
* @return The elapsed time in hours.
|
||||
*/
|
||||
public long getElapsedTimeHour() {
|
||||
long elapsed = 0;
|
||||
|
||||
@@ -10,20 +10,20 @@ public class TrytesConverter {
|
||||
/**
|
||||
* Conversion of ascii encoded bytes to trytes.
|
||||
* Input is a string (can be stringified JSON object), return value is Trytes
|
||||
* <p>
|
||||
*
|
||||
* How the conversion works:
|
||||
* 2 Trytes === 1 Byte
|
||||
* There are a total of 27 different tryte values: 9ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
* <p>
|
||||
*
|
||||
* 1. We get the decimal value of an individual ASCII character
|
||||
* 2. From the decimal value, we then derive the two tryte values by basically calculating the tryte equivalent (e.g. 100 === 19 + 3 * 27)
|
||||
* a. The first tryte value is the decimal value modulo 27 (27 trytes)
|
||||
* b. The second value is the remainder (decimal value - first value), divided by 27
|
||||
* 3. The two values returned from Step 2. are then input as indices into the available values list ('9ABCDEFGHIJKLMNOPQRSTUVWXYZ') to get the correct tryte value
|
||||
* <p>
|
||||
* <p>
|
||||
*
|
||||
*
|
||||
* EXAMPLE
|
||||
* <p>
|
||||
*
|
||||
* Lets say we want to convert the ASCII character "Z".
|
||||
* 1. 'Z' has a decimal value of 90.
|
||||
* 2. 90 can be represented as 9 + 3 * 27. To make it simpler:
|
||||
|
||||
Reference in New Issue
Block a user