This commit is contained in:
adrianziser 2017-02-12 23:47:55 +01:00
commit 20ec76240d
71 changed files with 152 additions and 58 deletions

View File

@ -20,7 +20,8 @@ import java.util.Properties;
import java.util.concurrent.TimeUnit;
/**
* Created by Adrian on 15.01.2017.
* This class provides access to the Iota core API
* @author Adrian
*/
public class IotaAPICore {

View File

@ -2,6 +2,10 @@ package jota.dto.request;
import jota.IotaAPICommands;
/**
* This class represents the core API request 'attachToTangle'.
* It is used to attach trytes to the tangle.
**/
public class IotaAttachToTangleRequest extends IotaCommandRequest {
private String trunkTransaction;

View File

@ -2,6 +2,9 @@ package jota.dto.request;
import jota.IotaAPICommands;
/**
* Broadcast a list of transactions to all neighbors. The input trytes for this call are provided by attachToTangle
**/
public class IotaBroadcastTransactionRequest extends IotaCommandRequest {
private String[] trytes;

View File

@ -2,6 +2,9 @@ package jota.dto.request;
import jota.IotaAPICommands;
/**
* This class represents the core api request 'getNodeInfo', 'getNeighbors' and 'interruptAttachToTangle'
**/
public class IotaCommandRequest {
final String command;

View File

@ -2,6 +2,9 @@ package jota.dto.request;
import jota.IotaAPICommands;
/**
* This class represents the core api request 'findTransactions'
**/
public class IotaFindTransactionsRequest extends IotaCommandRequest {
private String[] bundles; // List of bundle hashes. The hashes need to be extended to 81chars by padding the hash with 9's.

View File

@ -2,6 +2,9 @@ package jota.dto.request;
import jota.IotaAPICommands;
/**
* This class represents the core api request 'getBalances'
**/
public class IotaGetBalancesRequest extends IotaCommandRequest {
private String[] addresses;

View File

@ -4,6 +4,9 @@ import jota.IotaAPICommands;
import java.util.Collection;
/**
* This class represents the core API request 'getInclusionStates'
**/
public class IotaGetInclusionStateRequest extends IotaCommandRequest {
private String[] transactions;

View File

@ -2,6 +2,9 @@ package jota.dto.request;
import jota.IotaAPICommands;
/**
* This class represents the core API request 'getTransactionsToApprove'
**/
public class IotaGetTransactionsToApproveRequest extends IotaCommandRequest {
private Integer depth;

View File

@ -2,6 +2,9 @@ package jota.dto.request;
import jota.IotaAPICommands;
/**
* This class represents the core API request 'getTrytes'
**/
public class IotaGetTrytesRequest extends IotaCommandRequest {
private String[] hashes;

View File

@ -2,6 +2,9 @@ package jota.dto.request;
import jota.IotaAPICommands;
/**
* This class represents the core API request 'addNeighbors' and 'removeNeighbors'
**/
public class IotaNeighborsRequest extends IotaCommandRequest {
private String[] uris;

View File

@ -2,6 +2,10 @@ package jota.dto.request;
import jota.IotaAPICommands;
/**
* This class represents the core API request 'getTransactionsToApprove'
* It stores transactions into the local storage. The trytes to be used for this call are returned by attachToTangle.
**/
public class IotaStoreTransactionsRequest extends IotaCommandRequest {
private String[] trytes;

View File

@ -5,6 +5,9 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* Abstract response.
*/
public abstract class AbstractResponse {
private Long duration;

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaNeighborsRequest}
**/
public class AddNeighborsResponse extends AbstractResponse {
private int addedNeighbors;

View File

@ -5,6 +5,9 @@ import jota.model.Transaction;
import java.util.ArrayList;
import java.util.List;
/**
* Response of {@link jota.dto.request.IotaGetBalancesRequest}
**/
public class AnalyzeTransactionResponse extends AbstractResponse {
private List<Transaction> transactions = new ArrayList<>();

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaBroadcastTransactionRequest}
**/
public class BroadcastTransactionsResponse extends AbstractResponse {
// empty response
}

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaFindTransactionsRequest}
**/
public class FindTransactionResponse extends AbstractResponse {
String[] hashes;

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaAttachToTangleRequest}
**/
public class GetAttachToTangleResponse extends AbstractResponse {
private String[] trytes;

View File

@ -4,6 +4,9 @@ import jota.model.Input;
import java.util.List;
/**
* Response of api request 'getBalancesAndFormatResponse'
**/
public class GetBalancesAndFormatResponse extends AbstractResponse {
private List<Input> input;

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaGetBalancesRequest}
**/
public class GetBalancesResponse extends AbstractResponse {
private String[] balances;

View File

@ -5,6 +5,9 @@ import jota.model.Transaction;
import java.util.ArrayList;
import java.util.List;
/**
* Response of api request 'getBundle
**/
public class GetBundleResponse extends AbstractResponse {
private List<Transaction> transactions = new ArrayList<>();

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaGetInclusionStateRequest}
**/
public class GetInclusionStateResponse extends AbstractResponse {
boolean[] states;

View File

@ -1,10 +0,0 @@
package jota.dto.response;
public class GetMilestoneResponse extends AbstractResponse {
private String milestone;
public String getMilestone() {
return milestone;
}
}

View File

@ -5,6 +5,9 @@ import jota.model.Neighbor;
import java.util.ArrayList;
import java.util.List;
/**
* Response of {@link jota.dto.request.IotaCommandRequest}
**/
public class GetNeighborsResponse extends AbstractResponse {
private List<Neighbor> neighbors = new ArrayList<>();

View File

@ -2,6 +2,9 @@ package jota.dto.response;
import java.util.List;
/**
* Response of api request 'getNewAddress'
**/
public class GetNewAddressResponse extends AbstractResponse {
private List<String> addresses;

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaNeighborsRequest}
**/
public class GetNodeInfoResponse extends AbstractResponse {
private String appName;

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaCommandRequest}
**/
public class GetTipsResponse extends AbstractResponse {
private String[] hashes;

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaGetTransactionsToApproveRequest}
**/
public class GetTransactionsToApproveResponse extends AbstractResponse {
private String trunkTransaction;

View File

@ -3,8 +3,8 @@ package jota.dto.response;
import jota.model.Bundle;
/**
* Created by pinpong on 28.12.16.
*/
* Response of api request 'getTransfer'
**/
public class GetTransferResponse extends AbstractResponse {
private Bundle[] transferBundle;

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaGetTrytesRequest}
**/
public class GetTrytesResponse extends AbstractResponse {
private String[] trytes;

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaCommandRequest}
**/
public class InterruptAttachingToTangleResponse extends AbstractResponse {
// empty response
}

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaNeighborsRequest}
**/
public class RemoveNeighborsResponse extends AbstractResponse {
private int removedNeighbors;

View File

@ -1,8 +1,8 @@
package jota.dto.response;
/**
* Created by pinpong on 01.01.17.
*/
* Response of api request 'replayBundle'
**/
public class ReplayBundleResponse extends AbstractResponse {
private Boolean[] successfully;

View File

@ -1,8 +1,8 @@
package jota.dto.response;
/**
* Created by pinpong on 28.12.16.
*/
* Response of api request 'sendTransfer'
**/
public class SendTransferResponse extends AbstractResponse {
private Boolean[] successfully;

View File

@ -1,5 +1,8 @@
package jota.dto.response;
/**
* Response of {@link jota.dto.request.IotaStoreTransactionsRequest}
**/
public class StoreTransactionsResponse extends AbstractResponse {
public StoreTransactionsResponse(long duration) {
setDuration(duration);

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by Adrian on 09.12.2016.
* @author Adrian
*/
public class ArgumentException extends BaseException {

View File

@ -5,7 +5,7 @@ import java.util.Arrays;
import java.util.Collection;
/**
* Created by Adrian on 09.12.2016.
* @author Adrian
*/
public class BaseException extends Exception {

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by Adrian on 22.01.2017.
* @author Adrian
*/
public class BroadcastAndStoreException extends BaseException {

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by pinpong on 05.02.17.
* @author Adrian
*/
public class InvalidAddressException extends BaseException {
public InvalidAddressException() {

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by Adrian on 27.12.2016.
* @author Adrian
*/
public class InvalidBundleException extends BaseException {

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by pinpong on 02.02.17.
* @author pinpong
*/
public class InvalidSecurityLevelException extends BaseException {

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by Adrian on 27.12.2016.
* @author Adrian
*/
public class InvalidSignatureException extends BaseException {
public InvalidSignatureException() {

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by pinpong on 05.02.17.
* @author pinpong
*/
public class InvalidTransferException extends BaseException {
public InvalidTransferException() {

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by Adrian on 04.02.2017.
* @author Adrian
*/
public class InvalidTrytesException extends BaseException {

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by Adrian on 22.01.2017.
* @author Adrian
*/
public class NoInclusionStatesExcpection extends BaseException {

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by Adrian on 22.01.2017.
* @author Adrian
*/
public class NoNodeInfoException extends BaseException {

View File

@ -1,7 +1,7 @@
package jota.error;
/**
* Created by Adrian on 09.12.2016.
* @author Adrian
*/
public class NotEnoughBalanceException extends BaseException {

View File

@ -10,8 +10,9 @@ import java.util.List;
/**
* Created by pinpong on 09.12.16.
*/
* This class represents a Bundle, a set of transactions
* @author pinpong
**/
public class Bundle implements Comparable<Bundle> {
public static String EMPTY_HASH = "999999999999999999999999999999999999999999999999999999999999999999999999999999999";

View File

@ -4,8 +4,9 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* Created by Adrian on 09.12.2016.
*/
* This class represents an Input
* @author Adrian
**/
public class Input {
private String address;
private long balance;

View File

@ -5,8 +5,9 @@ import com.google.gson.Gson;
import java.util.List;
/**
* Created by Adrian on 09.12.2016.
*/
* This class represents an Inputs
* @author Adrian
**/
public class Inputs {
private List<Input> inputsList;
private long totalBalance;

View File

@ -1,8 +1,9 @@
package jota.model;
/**
* Created by pinpong on 02.12.16.
*/
* This class represents an Neighbor
* @author pinpong
**/
public class Neighbor {
private String address;

View File

@ -4,8 +4,9 @@ import java.util.ArrayList;
import java.util.List;
/**
* Created by Adrian on 27.12.2016.
*/
* This class represents an Signature
* @author Adrian
**/
public class Signature {
String address;

View File

@ -12,7 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays;
/**
* Created by pinpong on 02.12.16.
* This class represents an iota transaction
* @author pinpong
*/
public class Transaction {
private static final Logger log = LoggerFactory.getLogger(Transaction.class);

View File

@ -3,7 +3,8 @@ package jota.model;
import com.google.gson.Gson;
/**
* Created by pinpong on 02.12.16.
* This class represents a Transfer
* @author pinpong
*/
public class Transfer {

View File

@ -1,7 +1,7 @@
package jota.pow;
/**
* Created by Adrian on 07.01.2017.
* @author Adrian
*/
public interface ICurl {
ICurl absorb(final int[] trits, int offset, int length);

View File

@ -4,7 +4,8 @@ import jota.error.InvalidAddressException;
import jota.pow.JCurl;
/**
* Created by pinpong on 02.12.16.
* This class defines utility methods to add/remove the checksum to/from an address
* @author pinpong
*/
public class Checksum {

View File

@ -1,7 +1,8 @@
package jota.utils;
/**
* Created by pinpong on 02.12.16.
* This class defines the global constants
* @author pinpong
*/
public class Constants {

View File

@ -8,7 +8,8 @@ import org.apache.commons.lang3.math.NumberUtils;
import java.util.List;
/**
* Created by pinpong on 02.12.16.
* This class provides methods to validate the parameters of different iota API methods
* @author pinpong
*/
public class InputValidator {

View File

@ -3,7 +3,8 @@ package jota.utils;
import java.text.DecimalFormat;
/**
* Created by Sascha on 30.11.16.
* This class provides methods to convert Iota to different units
* @author sascha
*/
public class IotaUnitConverter {

View File

@ -2,6 +2,7 @@ package jota.utils;
/**
* Table of IOTA units based off of the standard system of Units
* @author pinpong
**/
public enum IotaUnits {

View File

@ -7,7 +7,7 @@ import jota.pow.JCurl;
import java.util.Arrays;
/**
* Created by pinpong on 02.02.17.
* @author pinpong
*/
public class Multisig {

View File

@ -5,7 +5,7 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Created by Adrian on 15.01.2017.
* @author Adrian
*/
public class NamedThreadFactory implements ThreadFactory {
private final String baseName;

View File

@ -8,7 +8,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by Adrian on 15.01.2017.
* @author Adrian
*/
public class Parallel {
private static final int NUM_CORES = Runtime.getRuntime().availableProcessors();

View File

@ -3,7 +3,8 @@ package jota.utils;
import java.security.SecureRandom;
/**
* Created by pinpong on 13.12.16.
* This class allows to create a secure random generated seed
* @author pinpong
*/
public class SeedRandomGenerator {

View File

@ -1,7 +1,7 @@
package jota.utils;
/**
* Created by Adrian on 15.01.2017.
* @author adrian
*/
public class StopWatch {
private long startTime = 0;

View File

@ -1,7 +1,8 @@
package jota.utils;
/**
* Created by pinpong on 01.12.16.
* This class allows to convert between ASCII and tryte encoded strings
* @author pinpong
*/
public class TrytesConverter {

View File

@ -7,7 +7,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by pinpong on 02.12.16.
* @author pinpong
*/
public class ChecksumTest {

View File

@ -11,7 +11,7 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
/**
* Created by pinpong on 02.12.16.
* @author pinpong
*/
public class InputValidatorTest {

View File

@ -9,7 +9,7 @@ import org.junit.Test;
import static org.junit.Assert.assertThat;
/**
* Created by Adrian on 15.01.2017.
* @author Adrian
*/
public class IotaCoreApiTest {

View File

@ -7,7 +7,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by pinpong on 30.11.16.
* @author pinpong
*/
public class IotaUnitConverterTest {

View File

@ -8,7 +8,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by pinpong on 13.12.16.
* @author pinpong
*/
public class SeedRandomGeneratorTest {

View File

@ -8,7 +8,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* Created by pinpong on 01.12.16.
* @author pinpong
*/
public class TrytesConverterTest {