mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2026-10-03 21:16:59 +00:00
documentation
This commit is contained in:
+147
-141
@@ -37,17 +37,17 @@ public class IotaAPI extends IotaAPICore {
|
||||
|
||||
/**
|
||||
* Generates a new address from a seed and returns the remainderAddress.
|
||||
* This is either done deterministically, or by providing the index of the new remainderAddress
|
||||
* This is either done deterministically, or by providing the index of the new remainderAddress.
|
||||
*
|
||||
* @param seed Tryte-encoded seed. It should be noted that this seed is not transferred
|
||||
* @param security Security level to be used for the private key / address. Can be 1, 2 or 3
|
||||
* @param index Optional (default null). Key index to start search from. If the index is provided, the generation of the address is not deterministic.
|
||||
* @param checksum Optional (default false). Adds 9-tryte address checksum
|
||||
* @param total Optional (default 1)Total number of addresses to generate
|
||||
* @param returnAll If true, it returns all addresses which were deterministically generated (until findTransactions returns null)
|
||||
* @return an array of strings with the specifed number of addresses
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @exception InvalidSecurityLevelException is thrown when the specified security level is not valid
|
||||
* @param seed Tryte-encoded seed. It should be noted that this seed is not transferred.
|
||||
* @param security Security level to be used for the private key / address. Can be 1, 2 or 3.
|
||||
* @param index Key index to start search from. If the index is provided, the generation of the address is not deterministic.
|
||||
* @param checksum Adds 9-tryte address checksum.
|
||||
* @param total Total number of addresses to generate.
|
||||
* @param returnAll If <code>true</code>, it returns all addresses which were deterministically generated (until findTransactions returns null).
|
||||
* @return An array of strings with the specifed number of addresses.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
* @throws InvalidSecurityLevelException is thrown when the specified security level is not valid.
|
||||
*/
|
||||
public GetNewAddressResponse getNewAddress(final String seed, int security, final int index, final boolean checksum, final int total, final boolean returnAll) throws InvalidSecurityLevelException, InvalidAddressException {
|
||||
|
||||
@@ -90,21 +90,21 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param seed tryte-encoded seed. It should be noted that this seed is not transferred
|
||||
* @param security security secuirty level of private key / seed
|
||||
* @param start start Starting key index
|
||||
* @param end end Ending key index
|
||||
* @param inclusionStates Optional (default false). If True, it gets the inclusion states of the transfers.
|
||||
* @return Bundle
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @throws ArgumentException
|
||||
* @throws InvalidBundleException
|
||||
* @throws InvalidSignatureException
|
||||
* @throws NoNodeInfoException
|
||||
* @throws NoInclusionStatesExcpection
|
||||
* @exception InvalidSecurityLevelException is thrown when the specified security level is not valid
|
||||
* @param seed Tryte-encoded seed. It should be noted that this seed is not transferred.
|
||||
* @param security The security level of private key / seed.
|
||||
* @param start Starting key index.
|
||||
* @param end Ending key index.
|
||||
* @param inclusionStates If <code>true</code>, it gets the inclusion states of the transfers.
|
||||
* @return Bundle of transfers.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
* @throws ArgumentException is thrown when an invalid argument is provided.
|
||||
* @throws InvalidBundleException is thrown if an invalid bundle was found or provided.
|
||||
* @throws InvalidSignatureException is thrown when an invalid signature is encountered.
|
||||
* @throws NoNodeInfoException is thrown when its not possible to get node info.
|
||||
* @throws NoInclusionStatesException when it not possible to get a inclusion state.
|
||||
* @throws InvalidSecurityLevelException is thrown when the specified security level is not valid.
|
||||
*/
|
||||
public GetTransferResponse getTransfers(String seed, int security, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException, NoNodeInfoException, NoInclusionStatesExcpection, InvalidSecurityLevelException, InvalidAddressException {
|
||||
public GetTransferResponse getTransfers(String seed, int security, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException, NoNodeInfoException, NoInclusionStatesException, InvalidSecurityLevelException, InvalidAddressException {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
// validate & if needed pad seed
|
||||
if ((seed = InputValidator.validateSeed(seed)) == null) {
|
||||
@@ -131,13 +131,18 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function to get the formatted bundles of a list of addresses
|
||||
*
|
||||
* @param addresses List of addresses
|
||||
* @param inclusionStates Optional (default false). If True, it gets the inclusion states of the transfers.
|
||||
* @return bundles Transaction objects
|
||||
**/
|
||||
public Bundle[] bundlesFromAddresses(String[] addresses, final Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException, NoNodeInfoException, NoInclusionStatesExcpection {
|
||||
* Internal function to get the formatted bundles of a list of addresses.
|
||||
* @param addresses List of addresses.
|
||||
* @param inclusionStates If <code>true</code>, it gets the inclusion states of the transfers.
|
||||
* @return A Transaction objects.
|
||||
* @throws ArgumentException is thrown when an invalid argument is provided.
|
||||
* @throws InvalidBundleException is thrown if an invalid bundle was found or provided.
|
||||
* @throws InvalidSignatureException is thrown when an invalid signature is encountered.
|
||||
* @throws NoNodeInfoException is thrown when its not possible to get node info.
|
||||
* @throws NoInclusionStatesException when it not possible to get a inclusion state.
|
||||
*/
|
||||
public Bundle[] bundlesFromAddresses(String[] addresses, final Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException, NoNodeInfoException, NoInclusionStatesException {
|
||||
|
||||
List<Transaction> trxs = findTransactionObjects(addresses);
|
||||
// set of tail transactions
|
||||
@@ -175,10 +180,10 @@ public class IotaAPI extends IotaAPICore {
|
||||
try {
|
||||
gisr = getLatestInclusion(tailTxArray);
|
||||
} catch (IllegalAccessError ignored) {
|
||||
throw new NoInclusionStatesExcpection();
|
||||
throw new NoInclusionStatesException();
|
||||
}
|
||||
if (gisr == null || gisr.getStates() == null || gisr.getStates().length == 0) {
|
||||
throw new NoInclusionStatesExcpection();
|
||||
throw new NoInclusionStatesException();
|
||||
}
|
||||
}
|
||||
final GetInclusionStateResponse finalInclusionStates = gisr;
|
||||
@@ -217,8 +222,11 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param trytes the trytes
|
||||
* @return a StoreTransactionsResponse
|
||||
* Wrapper function that broadcasts and stores the specified trytes.
|
||||
*
|
||||
* @param trytes The trytes.
|
||||
* @return A StoreTransactionsResponse.
|
||||
* @throws BroadcastAndStoreException is thrown if its not possible to broadcast and store.
|
||||
*/
|
||||
public StoreTransactionsResponse broadcastAndStore(final String... trytes) throws BroadcastAndStoreException {
|
||||
|
||||
@@ -232,12 +240,13 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Facade method: Gets transactions to approve, attaches to Tangle, broadcasts and stores
|
||||
* Facade method: Gets transactions to approve, attaches to Tangle, broadcasts and stores.
|
||||
*
|
||||
* @param trytes the trytes
|
||||
* @param depth the depth
|
||||
* @param minWeightMagnitude the minimum weight magnitude
|
||||
* @return Transactions objects
|
||||
* @param trytes The trytes.
|
||||
* @param depth The depth.
|
||||
* @param minWeightMagnitude The minimum weight magnitude.
|
||||
* @return Transactions objects.
|
||||
* @throws InvalidTrytesException is thrown when invalid trytes is provided.
|
||||
*/
|
||||
public List<Transaction> sendTrytes(final String[] trytes, final int depth, final int minWeightMagnitude) throws InvalidTrytesException {
|
||||
final GetTransactionsToApproveResponse txs = getTransactionsToApprove(depth);
|
||||
@@ -260,12 +269,11 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function for getTrytes and transactionObjects
|
||||
* gets the trytes and transaction object from a list of transaction hashes
|
||||
* Wrapper function for getTrytes and transactionObjects.
|
||||
* Gets the trytes and transaction object from a list of transaction hashes.
|
||||
*
|
||||
* @method getTransactionsObjects
|
||||
* @param hashes the hashes
|
||||
* @return Transaction objects
|
||||
* @param hashes The hashes
|
||||
* @return Transaction objects.
|
||||
**/
|
||||
public List<Transaction> getTransactionsObjects(String[] hashes) {
|
||||
|
||||
@@ -284,13 +292,11 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function for findTransactions, getTrytes and transactionObjects
|
||||
* Returns the transactionObject of a transaction hash. The input can be a valid
|
||||
* findTransactions input
|
||||
* Wrapper function for findTransactions, getTrytes and transactionObjects.
|
||||
* Returns the transactionObject of a transaction hash. The input can be a valid findTransactions input.
|
||||
*
|
||||
* @method getTransactionsObjects
|
||||
* @param input the inputs
|
||||
* @return Transactions
|
||||
* @param input The inputs.
|
||||
* @return Transactions.
|
||||
**/
|
||||
public List<Transaction> findTransactionObjects(String[] input) {
|
||||
FindTransactionResponse ftr = findTransactions(input, null, null, null);
|
||||
@@ -301,12 +307,12 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function for findTransactions, getTrytes and transactionObjects
|
||||
* Returns the transactionObject of a transaction hash. The input can be a valid
|
||||
* Wrapper function for findTransactions, getTrytes and transactionObjects.
|
||||
* Returns the transactionObject of a transaction hash. The input can be a valid.
|
||||
* findTransactions input
|
||||
* @method getTransactionsObjects
|
||||
* @param input the inputs
|
||||
* @return Transactions
|
||||
*
|
||||
* @param input The inputs.
|
||||
* @return Transactions.
|
||||
**/
|
||||
public List<Transaction> findTransactionObjectsByBundle(String[] input) {
|
||||
FindTransactionResponse ftr = findTransactions(null, null, null, input);
|
||||
@@ -318,18 +324,18 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares transfer by generating bundle, finding and signing inputs
|
||||
* Prepares transfer by generating bundle, finding and signing inputs.
|
||||
*
|
||||
* @param seed 81-tryte encoded address of recipient
|
||||
* @param security security secuirty level of private key / seed
|
||||
* @param transfers Array of transfer objects
|
||||
* @param remainder Optional (default null). if defined, this address will be used for sending the remainder value (of the inputs) to.
|
||||
* @param inputs the inputs
|
||||
* @return trytes Returns bundle trytes
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @throws NotEnoughBalanceException
|
||||
* @exception InvalidSecurityLevelException is thrown when the specified security level is not valid
|
||||
* @throws InvalidTransferException
|
||||
* @param seed 81-tryte encoded address of recipient.
|
||||
* @param security The security level of private key / seed.
|
||||
* @param transfers Array of transfer objects.
|
||||
* @param remainder If defined, this address will be used for sending the remainder value (of the inputs) to.
|
||||
* @param inputs The inputs.
|
||||
* @return Returns bundle trytes.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
* @throws NotEnoughBalanceException is thrown when a transfer fails because their is not enough balance to perform the transfer.
|
||||
* @throws InvalidSecurityLevelException is thrown when the specified security level is not valid.
|
||||
* @throws InvalidTransferException is thrown when an invalid transfer is provided.
|
||||
*/
|
||||
public List<String> prepareTransfers(String seed, int security, final List<Transfer> transfers, String remainder, List<Input> inputs) throws NotEnoughBalanceException, InvalidSecurityLevelException, InvalidAddressException, InvalidTransferException {
|
||||
|
||||
@@ -483,13 +489,13 @@ public class IotaAPI extends IotaAPICore {
|
||||
/**
|
||||
* Gets the inputs of a seed
|
||||
*
|
||||
* @param seed tryte-encoded seed. It should be noted that this seed is not transferred
|
||||
* @param security security secuirty level of private key / seed
|
||||
* @param start start Starting key index
|
||||
* @param end end Ending key index
|
||||
* @param threshold threshold Min balance required
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @exception InvalidSecurityLevelException
|
||||
* @param seed Tryte-encoded seed. It should be noted that this seed is not transferred.
|
||||
* @param security The Security level of private key / seed.
|
||||
* @param start Starting key index.
|
||||
* @param end Ending key index.
|
||||
* @param threshold Min balance required.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
* @throws InvalidSecurityLevelException is thrown when the specified security level is not valid.
|
||||
|
||||
**/
|
||||
public GetBalancesAndFormatResponse getInputs(String seed, int security, int start, int end, long threshold) throws InvalidSecurityLevelException, InvalidAddressException {
|
||||
@@ -542,16 +548,16 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the balances and formats the output
|
||||
* Gets the balances and formats the output.
|
||||
*
|
||||
* @param addresses the addresses
|
||||
* @param threshold threshold Min balance required
|
||||
* @param start start Starting key index
|
||||
* @param end end Ending key index
|
||||
* @param stopWatch the stopwatch
|
||||
* @param security security secuirty level of private key / seed
|
||||
* @return Inputs object
|
||||
* @exception InvalidSecurityLevelException is thrown when the specified security level is not valid
|
||||
* @param addresses The addresses.
|
||||
* @param threshold Min balance required.
|
||||
* @param start Starting key index.
|
||||
* @param end Ending key index.
|
||||
* @param stopWatch the stopwatch.
|
||||
* @param security The security level of private key / seed.
|
||||
* @return Inputs object.
|
||||
* @throws InvalidSecurityLevelException is thrown when the specified security level is not valid.
|
||||
**/
|
||||
public GetBalancesAndFormatResponse getBalanceAndFormat(final List<String> addresses, long threshold, int start, int end, StopWatch stopWatch, int security) throws InvalidSecurityLevelException {
|
||||
|
||||
@@ -595,13 +601,14 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated bundle transactions of a single transaction
|
||||
* Does validation of signatures, total sum as well as bundle order
|
||||
* @param transaction the transaction encoded in trytes
|
||||
* Gets the associated bundle transactions of a single transaction.
|
||||
* Does validation of signatures, total sum as well as bundle order.
|
||||
*
|
||||
* @param transaction The transaction encoded in trytes.
|
||||
* @return an array of bundle, if there are multiple arrays it means that there are conflicting bundles.
|
||||
* @throws ArgumentException
|
||||
* @throws InvalidBundleException
|
||||
* @throws InvalidSignatureException
|
||||
* @throws ArgumentException is thrown when an invalid argument is provided.
|
||||
* @throws InvalidBundleException is thrown if an invalid bundle was found or provided.
|
||||
* @throws InvalidSignatureException is thrown when an invalid signature is encountered.
|
||||
*/
|
||||
public GetBundleResponse getBundle(String transaction) throws ArgumentException, InvalidBundleException, InvalidSignatureException {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
@@ -679,16 +686,16 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Replays a transfer by doing Proof of Work again
|
||||
* Replays a transfer by doing Proof of Work again.
|
||||
*
|
||||
* @param transaction the transaction
|
||||
* @param depth the depth
|
||||
* @param minWeightMagnitude the minimum weight magnitude
|
||||
* @return analyzed Transaction objects
|
||||
* @throws InvalidBundleException
|
||||
* @throws ArgumentException
|
||||
* @throws InvalidSignatureException
|
||||
* @throws InvalidTrytesException
|
||||
* @param transaction The transaction.
|
||||
* @param depth The depth.
|
||||
* @param minWeightMagnitude The minimum weight magnitude.
|
||||
* @return Analyzed Transaction objects.
|
||||
* @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();
|
||||
@@ -720,9 +727,9 @@ public class IotaAPI extends IotaAPICore {
|
||||
/**
|
||||
* Wrapper function for getNodeInfo and getInclusionStates
|
||||
*
|
||||
* @param hashes the hashes
|
||||
* @return inclusion state
|
||||
* @throws NoNodeInfoException
|
||||
* @param hashes The hashes.
|
||||
* @return Inclusion state.
|
||||
* @throws NoNodeInfoException is thrown when its not possible to get node info.
|
||||
*/
|
||||
public GetInclusionStateResponse getLatestInclusion(String[] hashes) throws NoNodeInfoException {
|
||||
GetNodeInfoResponse getNodeInfoResponse = getNodeInfo();
|
||||
@@ -736,20 +743,20 @@ public class IotaAPI extends IotaAPICore {
|
||||
/**
|
||||
* Wrapper function that basically does prepareTransfers, as well as attachToTangle and finally, it broadcasts and stores the transactions locally.
|
||||
*
|
||||
* @param seed tryte-encoded seed
|
||||
* @param security security secuirty level of private key / seed
|
||||
* @param depth the depth
|
||||
* @param minWeightMagnitude the minimum weight magnitude
|
||||
* @param transfers array of transfer objects
|
||||
* @param inputs List of inputs used for funding the transfer
|
||||
* @param address if defined, this address will be used for sending the remainder value (of the inputs) to
|
||||
* @return array of Transaction objects
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @throws NotEnoughBalanceException
|
||||
* @exception InvalidSecurityLevelException is thrown when the specified security level is not valid
|
||||
* @throws InvalidTrytesException
|
||||
* @throws InvalidAddressException
|
||||
* @throws InvalidTransferException
|
||||
* @param seed Tryte-encoded seed
|
||||
* @param security The security level of private key / seed.
|
||||
* @param depth The depth.
|
||||
* @param minWeightMagnitude The minimum weight magnitude.
|
||||
* @param transfers Array of transfer objects.
|
||||
* @param inputs List of inputs used for funding the transfer.
|
||||
* @param address If defined, this address will be used for sending the remainder value (of the inputs) to.
|
||||
* @return Array of Transaction objects.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
* @throws NotEnoughBalanceException is thrown when a transfer fails because their is not enough balance to perform the transfer.
|
||||
* @throws InvalidSecurityLevelException is thrown when the specified security level is not valid.
|
||||
* @throws InvalidTrytesException is thrown when invalid trytes is provided.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
* @throws InvalidTransferException is thrown when an invalid transfer is provided.
|
||||
*/
|
||||
public SendTransferResponse sendTransfer(String seed, int security, int depth, int minWeightMagnitude, final List<Transfer> transfers, Input[] inputs, String address) throws NotEnoughBalanceException, InvalidSecurityLevelException, InvalidTrytesException, InvalidAddressException, InvalidTransferException {
|
||||
|
||||
@@ -779,11 +786,11 @@ public class IotaAPI extends IotaAPICore {
|
||||
* the bundle hash of the transaction is no longer the same. In case the input
|
||||
* transaction hash is not a tail, we return an error.
|
||||
*
|
||||
* @param trunkTx Hash of a trunk or a tail transaction of a bundle
|
||||
* @param bundleHash the bundle hashes
|
||||
* @param bundle List of bundles to be populated
|
||||
* @return bundle Transaction objects
|
||||
* @throws ArgumentException
|
||||
* @param trunkTx Hash of a trunk or a tail transaction of a bundle.
|
||||
* @param bundleHash The bundle hashes.
|
||||
* @param bundle List of bundles to be populated.
|
||||
* @return Transaction objects.
|
||||
* @throws ArgumentException is thrown when an invalid argument is provided.
|
||||
*/
|
||||
public Bundle traverseBundle(String trunkTx, String bundleHash, Bundle bundle) throws ArgumentException {
|
||||
GetTrytesResponse gtr = getTrytes(trunkTx);
|
||||
@@ -828,16 +835,15 @@ public class IotaAPI extends IotaAPICore {
|
||||
|
||||
|
||||
/**
|
||||
* Prepares transfer by generating the bundle with the corresponding cosigner transactions
|
||||
* Does not contain signatures
|
||||
* Prepares transfer by generating the bundle with the corresponding cosigner transactions.
|
||||
* Does not contain signatures.
|
||||
*
|
||||
* @param securitySum sum of security levels used by all co-signers
|
||||
* @param inputAddress array of input addresses as well as the securitySum
|
||||
* @param remainderAddress has to be generated by the cosigners before initiating the transfer, can be null if fully spent
|
||||
* @return bundle of transaction objects
|
||||
* @throws InvalidAddressException
|
||||
* @throws InvalidBundleException
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @param securitySum The sum of security levels used by all co-signers.
|
||||
* @param inputAddress Array of input addresses as well as the securitySum.
|
||||
* @param remainderAddress Has to be generated by the cosigners before initiating the transfer, can be null if fully spent.
|
||||
* @return Bundle of transaction objects.
|
||||
* @throws InvalidBundleException is thrown if an invalid bundle was found or provided.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
*/
|
||||
private GetTransferResponse initiateTransfer(int securitySum, final List<String> inputAddress, String remainderAddress, final List<Transfer> transfers) throws InvalidAddressException, InvalidBundleException, InvalidTransferException {
|
||||
StopWatch sw = new StopWatch();
|
||||
@@ -1005,8 +1011,8 @@ public class IotaAPI extends IotaAPICore {
|
||||
|
||||
/**
|
||||
* @param hash The hash.
|
||||
* @return
|
||||
* @throws ArgumentException
|
||||
* @return A bundle.
|
||||
* @throws ArgumentException is thrown when an invalid argument is provided.
|
||||
*/
|
||||
public String findTailTransactionHash(String hash) throws ArgumentException {
|
||||
GetTrytesResponse gtr = getTrytes(hash);
|
||||
@@ -1026,18 +1032,18 @@ public class IotaAPI extends IotaAPICore {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param seed tryte-encoded seed
|
||||
* @param security security secuirty level of private key / seed
|
||||
* @param inputs List of inputs used for funding the transfer
|
||||
* @param bundle to be populated
|
||||
* @param tag the tag.
|
||||
* @param totalValue The total value.
|
||||
* @param remainderAddress if defined, this address will be used for sending the remainder value (of the inputs) to
|
||||
* @param seed Tryte-encoded seed.
|
||||
* @param security The security level of private key / seed.
|
||||
* @param inputs List of inputs used for funding the transfer.
|
||||
* @param bundle To be populated.
|
||||
* @param tag The tag.
|
||||
* @param totalValue The total value.
|
||||
* @param remainderAddress If defined, this address will be used for sending the remainder value (of the inputs) to.
|
||||
* @param signatureFragments The signature fragments.
|
||||
* @return
|
||||
* @throws NotEnoughBalanceException
|
||||
* @throws InvalidSecurityLevelException is thrown when the specified security level is not valid
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address
|
||||
*
|
||||
* @throws NotEnoughBalanceException is thrown when a transfer fails because their is not enough balance to perform the transfer.
|
||||
* @throws InvalidSecurityLevelException is thrown when the specified security level is not valid.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
*/
|
||||
public List<String> addRemainder(final String seed,
|
||||
final int security,
|
||||
|
||||
@@ -25,15 +25,26 @@ public enum IotaAPICommands {
|
||||
private String command;
|
||||
private int params;
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* @param params
|
||||
*/
|
||||
IotaAPICommands(String command, int params) {
|
||||
this.command = command;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String command() {
|
||||
return command;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int params() {
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,11 @@ public class IotaAPICore {
|
||||
private IotaAPIService service;
|
||||
private String protocol, host, port;
|
||||
|
||||
/**
|
||||
* Build the API core.
|
||||
*
|
||||
* @param builder The builder.
|
||||
*/
|
||||
protected IotaAPICore(final Builder builder) {
|
||||
protocol = builder.protocol;
|
||||
host = builder.host;
|
||||
@@ -37,6 +42,11 @@ 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();
|
||||
@@ -54,6 +64,12 @@ 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) {
|
||||
@@ -64,6 +80,9 @@ public class IotaAPICore {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void postConstruct() {
|
||||
|
||||
final String nodeUrl = protocol + "://" + host + ":" + port;
|
||||
@@ -208,6 +227,9 @@ public class IotaAPICore {
|
||||
return new IotaAPICore(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private boolean checkPropertiesFiles() {
|
||||
|
||||
try {
|
||||
@@ -236,22 +258,40 @@ public class IotaAPICore {
|
||||
return (port != null && protocol != null && host != null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void checkEnviromentVariables() {
|
||||
protocol = env("IOTA_NODE_PROTOCOL", "http");
|
||||
host = env("IOTA_NODE_HOST", "localhost");
|
||||
port = env("IOTA_NODE_PORT", "14265");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class IotaAttachToTangleRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the trunk transaction.
|
||||
*
|
||||
* @return trunkTransaction The trunk transaction.
|
||||
* @return The trunk transaction.
|
||||
*/
|
||||
public String getTrunkTransaction() {
|
||||
return trunkTransaction;
|
||||
@@ -50,9 +50,9 @@ public class IotaAttachToTangleRequest extends IotaCommandRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the brancht ransaction.
|
||||
* Gets the branch transaction.
|
||||
*
|
||||
* @return branchTransaction The branch transaction.
|
||||
* @return The branch transaction.
|
||||
*/
|
||||
public String getBranchTransaction() {
|
||||
return branchTransaction;
|
||||
@@ -70,7 +70,7 @@ public class IotaAttachToTangleRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the min weight magnitude.
|
||||
*
|
||||
* @return minWeightMagnitude The min weight magnitude.
|
||||
* @return The min weight magnitude.
|
||||
*/
|
||||
public Integer getMinWeightMagnitude() {
|
||||
return minWeightMagnitude;
|
||||
@@ -88,7 +88,7 @@ public class IotaAttachToTangleRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the trytes.
|
||||
*
|
||||
* @return trytes The trytes.
|
||||
* @return The trytes.
|
||||
*/
|
||||
public String[] getTrytes() {
|
||||
return trytes;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class IotaBroadcastTransactionRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the trytes.
|
||||
*
|
||||
* @return trytes The trytes.
|
||||
* @return The trytes.
|
||||
*/
|
||||
public String[] getTrytes() {
|
||||
return trytes;
|
||||
|
||||
@@ -9,22 +9,45 @@ public class IotaCommandRequest {
|
||||
|
||||
final String command;
|
||||
|
||||
/**
|
||||
* @param command
|
||||
*/
|
||||
protected IotaCommandRequest(IotaAPICommands command) {
|
||||
this.command = command.command();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about the node.
|
||||
*
|
||||
* @return The Node info.
|
||||
*/
|
||||
public static IotaCommandRequest createNodeInfoRequest() {
|
||||
return new IotaCommandRequest(IotaAPICommands.GET_NODE_INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tips of the node.
|
||||
*
|
||||
* @return The tips of the node.
|
||||
*/
|
||||
public static IotaCommandRequest createGetTipsRequest() {
|
||||
return new IotaCommandRequest(IotaAPICommands.GET_TIPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the neighbours of the node.
|
||||
*
|
||||
* @return The list of neighbors.
|
||||
*/
|
||||
public static IotaCommandRequest createGetNeighborsRequest() {
|
||||
return new IotaCommandRequest(IotaAPICommands.GET_NEIGHBORS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupt attaching to the tangle
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static IotaCommandRequest createInterruptAttachToTangleRequest() {
|
||||
return new IotaCommandRequest(IotaAPICommands.INTERRUPT_ATTACHING_TO_TANGLE);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class IotaFindTransactionsRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the bundles.
|
||||
*
|
||||
* @return bundles The bundles.
|
||||
* @return The bundles.
|
||||
*/
|
||||
public String[] getBundles() {
|
||||
return bundles;
|
||||
@@ -79,7 +79,7 @@ public class IotaFindTransactionsRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the addresses.
|
||||
*
|
||||
* @return addresses The addresses.
|
||||
* @return The addresses.
|
||||
*/
|
||||
public String[] getAddresses() {
|
||||
return addresses;
|
||||
@@ -97,7 +97,7 @@ public class IotaFindTransactionsRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the tags.
|
||||
*
|
||||
* @return tags The tags.
|
||||
* @return The tags.
|
||||
*/
|
||||
public String[] getTags() {
|
||||
return tags;
|
||||
@@ -115,7 +115,7 @@ public class IotaFindTransactionsRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the approvees.
|
||||
*
|
||||
* @return approvees The approvees.
|
||||
* @return The approvees.
|
||||
*/
|
||||
public String[] getApprovees() {
|
||||
return approvees;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class IotaGetBalancesRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the addresses.
|
||||
*
|
||||
* @return addresses The addresses.
|
||||
* @return The addresses.
|
||||
*/
|
||||
public String[] getAddresses() {
|
||||
return addresses;
|
||||
@@ -47,7 +47,7 @@ public class IotaGetBalancesRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the threshold.
|
||||
*
|
||||
* @return threshold The threshold.
|
||||
* @return The threshold.
|
||||
*/
|
||||
public Integer getThreshold() {
|
||||
return threshold;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class IotaGetInclusionStateRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the transactions.
|
||||
*
|
||||
* @return transactions The transactions.
|
||||
* @return The transactions.
|
||||
*/
|
||||
public String[] getTransactions() {
|
||||
return transactions;
|
||||
@@ -58,7 +58,7 @@ public class IotaGetInclusionStateRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the tips.
|
||||
*
|
||||
* @return tips The tips.
|
||||
* @return The tips.
|
||||
*/
|
||||
public String[] getTips() {
|
||||
return tips;
|
||||
@@ -67,7 +67,7 @@ public class IotaGetInclusionStateRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Sets the tips.
|
||||
*
|
||||
* @param tips The tips.
|
||||
* @param tips The tips.
|
||||
*/
|
||||
public void setTips(String[] tips) {
|
||||
this.tips = tips;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class IotaGetTransactionsToApproveRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the depth.
|
||||
*
|
||||
* @return depth The depth.
|
||||
* @return The depth.
|
||||
*/
|
||||
public Integer getDepth() {
|
||||
return depth;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class IotaGetTrytesRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the hashes.
|
||||
*
|
||||
* @return hashes The hashes.
|
||||
* @return The hashes.
|
||||
*/
|
||||
public String[] getHashes() {
|
||||
return hashes;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class IotaNeighborsRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the uris.
|
||||
*
|
||||
* @return uris The uris.
|
||||
* @return The uris.
|
||||
*/
|
||||
public String[] getUris() {
|
||||
return uris;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class IotaStoreTransactionsRequest extends IotaCommandRequest {
|
||||
/**
|
||||
* Gets the trytes.
|
||||
*
|
||||
* @return trytes The trytes.
|
||||
* @return The trytes.
|
||||
*/
|
||||
public String[] getTrytes() {
|
||||
return trytes;
|
||||
|
||||
@@ -12,10 +12,20 @@ public abstract class AbstractResponse {
|
||||
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
* Gets the duration.
|
||||
*
|
||||
* @return The duration.
|
||||
*/
|
||||
public Long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the duration.
|
||||
*
|
||||
* @param duration The duration
|
||||
*/
|
||||
public void setDuration(Long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public class AddNeighborsResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the number of added neighbors.
|
||||
*
|
||||
* @return addedNeighbors The number of added neighbors.
|
||||
* @return The number of added neighbors.
|
||||
*/
|
||||
public int getAddedNeighbors() {
|
||||
return addedNeighbors;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class FindTransactionResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the hashes.
|
||||
*
|
||||
* @return hashes trytes The hashes.
|
||||
* @return The hashes.
|
||||
*/
|
||||
public String[] getHashes() {
|
||||
return hashes;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class GetAttachToTangleResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the rytes.
|
||||
*
|
||||
* @return trytes The trytes.
|
||||
* @return The trytes.
|
||||
*/
|
||||
public String[] getTrytes() {
|
||||
return trytes;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class GetBalancesAndFormatResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the input.
|
||||
*
|
||||
* @return transactions The transactions.
|
||||
* @return The transactions.
|
||||
*/
|
||||
public List<Input> getInput() {
|
||||
return input;
|
||||
@@ -44,7 +44,7 @@ public class GetBalancesAndFormatResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the total balance.
|
||||
*
|
||||
* @return totalBalance The total balance.
|
||||
* @return The total balance.
|
||||
*/
|
||||
public long getTotalBalance() {
|
||||
return totalBalance;
|
||||
@@ -53,7 +53,7 @@ public class GetBalancesAndFormatResponse extends AbstractResponse {
|
||||
/**
|
||||
* Sets the total balance.
|
||||
*
|
||||
* @param totalBalance The total balance.
|
||||
* @param totalBalance The total balance.
|
||||
*/
|
||||
public void setTotalBalance(long totalBalance) {
|
||||
this.totalBalance = totalBalance;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class GetBalancesResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the milestone index.
|
||||
*
|
||||
* @return milestoneIndex The milestone index.
|
||||
* @return The milestone index.
|
||||
*/
|
||||
public int getMilestoneIndex() {
|
||||
return milestoneIndex;
|
||||
@@ -21,7 +21,7 @@ public class GetBalancesResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the milestone.
|
||||
*
|
||||
* @return milestone The milestone.
|
||||
* @return The milestone.
|
||||
*/
|
||||
public String getMilestone() {
|
||||
return milestone;
|
||||
@@ -29,7 +29,7 @@ public class GetBalancesResponse extends AbstractResponse {
|
||||
|
||||
/**
|
||||
* Gets the balances.
|
||||
* @return balances The balances.
|
||||
* @return The balances.
|
||||
*/
|
||||
public String[] getBalances() {
|
||||
return balances;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class GetBundleResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the transactions.
|
||||
*
|
||||
* @return transactions The transactions.
|
||||
* @return The transactions.
|
||||
*/
|
||||
public List<Transaction> getTransactions() {
|
||||
return transactions;
|
||||
|
||||
@@ -5,12 +5,12 @@ package jota.dto.response;
|
||||
**/
|
||||
public class GetInclusionStateResponse extends AbstractResponse {
|
||||
|
||||
boolean[] states;
|
||||
private boolean[] states;
|
||||
|
||||
/**
|
||||
* Gets the states.
|
||||
*
|
||||
* @return states The states.
|
||||
* @return The states.
|
||||
*/
|
||||
public boolean[] getStates() {
|
||||
return states;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class GetNeighborsResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the neighbors.
|
||||
*
|
||||
* @return neighbors The neighbors.
|
||||
* @return The neighbors.
|
||||
*/
|
||||
public List<Neighbor> getNeighbors() {
|
||||
return neighbors;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class GetNewAddressResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the addresses.
|
||||
*
|
||||
* @return addresses The addresses.
|
||||
* @return The addresses.
|
||||
*/
|
||||
public List<String> getAddresses() {
|
||||
return addresses;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* The version of the IOTA software you're currently running.
|
||||
*
|
||||
* @return
|
||||
* @return The version of the IOTA software you're currently running.
|
||||
*/
|
||||
public String getAppVersion() {
|
||||
return appVersion;
|
||||
@@ -43,7 +43,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* The version of running java version.
|
||||
*
|
||||
* @return
|
||||
* @return The version of running java version.
|
||||
*/
|
||||
public String getJreVersion() {
|
||||
return jreVersion;
|
||||
@@ -52,7 +52,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* Available cores on your machine for JRE.
|
||||
*
|
||||
* @return
|
||||
* @return Available cores on your machine for JRE.
|
||||
*/
|
||||
public Integer getJreAvailableProcessors() {
|
||||
return jreAvailableProcessors;
|
||||
@@ -61,7 +61,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* The amount of free memory in the Java Virtual Machine.
|
||||
*
|
||||
* @return
|
||||
* @return The amount of free memory in the Java Virtual Machine.
|
||||
*/
|
||||
public long getJreFreeMemory() {
|
||||
return jreFreeMemory;
|
||||
@@ -70,7 +70,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* The maximum amount of memory that the Java virtual machine will attempt to use.
|
||||
*
|
||||
* @return
|
||||
* @return The maximum amount of memory that the Java virtual machine will attempt to use.
|
||||
*/
|
||||
public long getJreMaxMemory() {
|
||||
return jreMaxMemory;
|
||||
@@ -79,7 +79,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* The total amount of memory in the Java virtual machine.
|
||||
*
|
||||
* @return
|
||||
* @return The total amount of memory in the Java virtual machine.
|
||||
*/
|
||||
public long getJreTotalMemory() {
|
||||
return jreTotalMemory;
|
||||
@@ -88,7 +88,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* Latest milestone that was signed off by the coordinator.
|
||||
*
|
||||
* @return
|
||||
* @return Latest milestone that was signed off by the coordinator.
|
||||
*/
|
||||
public String getLatestMilestone() {
|
||||
return latestMilestone;
|
||||
@@ -97,7 +97,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* Index of the latest milestone.
|
||||
*
|
||||
* @return
|
||||
* @return Index of the latest milestone.
|
||||
*/
|
||||
public int getLatestMilestoneIndex() {
|
||||
return latestMilestoneIndex;
|
||||
@@ -108,7 +108,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
* For a milestone to become solid your local node must basically approve the subtangle of coordinator-approved transactions,
|
||||
* and have a consistent view of all referenced transactions.
|
||||
*
|
||||
* @return
|
||||
* @return The latest milestone which is solid and is used for sending transactions.
|
||||
*/
|
||||
public String getLatestSolidSubtangleMilestone() {
|
||||
return latestSolidSubtangleMilestone;
|
||||
@@ -117,7 +117,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* Index of the latest solid subtangle.
|
||||
*
|
||||
* @return
|
||||
* @return Index of the latest solid subtangle.
|
||||
*/
|
||||
public int getLatestSolidSubtangleMilestoneIndex() {
|
||||
return latestSolidSubtangleMilestoneIndex;
|
||||
@@ -126,16 +126,16 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* Number of neighbors you are directly connected with.
|
||||
*
|
||||
* @return
|
||||
* @return Number of neighbors you are directly connected with.
|
||||
*/
|
||||
public int getNeighbors() {
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Packets which are currently queued up
|
||||
* Packets which are currently queued up.
|
||||
*
|
||||
* @return
|
||||
* @return Packets which are currently queued up.
|
||||
*/
|
||||
public int getPacketsQueueSize() {
|
||||
return packetsQueueSize;
|
||||
@@ -144,7 +144,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* Current UNIX timestamp.
|
||||
*
|
||||
* @return
|
||||
* @return Current UNIX timestamp.
|
||||
*/
|
||||
public Long getTime() {
|
||||
return time;
|
||||
@@ -153,7 +153,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* Number of tips in the network.
|
||||
*
|
||||
* @return
|
||||
* @return Number of tips in the network.
|
||||
*/
|
||||
public int getTips() {
|
||||
return tips;
|
||||
@@ -162,7 +162,7 @@ public class GetNodeInfoResponse extends AbstractResponse {
|
||||
/**
|
||||
* Transactions to request during syncing process.
|
||||
*
|
||||
* @return
|
||||
* @return Transactions to request during syncing process.
|
||||
*/
|
||||
public int getTransactionsToRequest() {
|
||||
return transactionsToRequest;
|
||||
|
||||
@@ -10,7 +10,7 @@ public class GetTipsResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the hashes.
|
||||
*
|
||||
* @return hashes The hashes.
|
||||
* @return The hashes.
|
||||
*/
|
||||
public String[] getHashes() {
|
||||
return hashes;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class GetTransactionsToApproveResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the trunk transaction.
|
||||
*
|
||||
* @return trunkTransaction The trunk transaction.
|
||||
* @return The trunk transaction.
|
||||
*/
|
||||
public String getTrunkTransaction() {
|
||||
return trunkTransaction;
|
||||
@@ -20,7 +20,7 @@ public class GetTransactionsToApproveResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the branch transaction.
|
||||
*
|
||||
* @return branchTransaction The branch transaction.
|
||||
* @return The branch transaction.
|
||||
*/
|
||||
public String getBranchTransaction() {
|
||||
return branchTransaction;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class GetTransferResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the transfer bundle.
|
||||
*
|
||||
* @return transferBundle The transfer bundle.
|
||||
* @return The transfer bundle.
|
||||
*/
|
||||
public Bundle[] getTransfers() {
|
||||
return transferBundle;
|
||||
|
||||
@@ -10,7 +10,7 @@ public class GetTrytesResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the trytes.
|
||||
*
|
||||
* @return trytes The trytes.
|
||||
* @return The trytes.
|
||||
*/
|
||||
public String[] getTrytes() {
|
||||
return trytes;
|
||||
|
||||
@@ -10,7 +10,7 @@ public class RemoveNeighborsResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the number of removed neighbors.
|
||||
*
|
||||
* @return removedNeighbors The number of removed neighbors.
|
||||
* @return The number of removed neighbors.
|
||||
*/
|
||||
public int getRemovedNeighbors() {
|
||||
return removedNeighbors;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ReplayBundleResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the successfully.
|
||||
*
|
||||
* @return successfully The successfully.
|
||||
* @return The successfully.
|
||||
*/
|
||||
public Boolean[] getSuccessfully() {
|
||||
return successfully;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class SendTransferResponse extends AbstractResponse {
|
||||
/**
|
||||
* Gets the successfully.
|
||||
*
|
||||
* @return successfully The successfully.
|
||||
* @return The successfully.
|
||||
*/
|
||||
public Boolean[] getSuccessfully() {
|
||||
return successfully;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exception occurs when an invalid argument is provided.
|
||||
*
|
||||
* @author Adrian
|
||||
*/
|
||||
public class ArgumentException extends BaseException {
|
||||
@@ -10,10 +12,16 @@ public class ArgumentException extends BaseException {
|
||||
*/
|
||||
private static final long serialVersionUID = -7850044681919575720L;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the ArgumentException.
|
||||
*/
|
||||
public ArgumentException() {
|
||||
super("Wrong arguments passed to function");
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the ArgumentException.
|
||||
*/
|
||||
public ArgumentException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exceptions occurs if its not possible to broadcast and store.
|
||||
*
|
||||
* @author Adrian
|
||||
*/
|
||||
public class BroadcastAndStoreException extends BaseException {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the BroadcastAndStoreException.
|
||||
*/
|
||||
public BroadcastAndStoreException() {
|
||||
super("Impossible to broadcastAndStore, aborting.");
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exception occurs when an invalid address is provided.
|
||||
*
|
||||
* @author Adrian
|
||||
*/
|
||||
public class InvalidAddressException extends BaseException {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the InvalidAddressException.
|
||||
*/
|
||||
public InvalidAddressException() {
|
||||
super("Invalid Address!");
|
||||
}
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exceptions occurs if an invalid bundle was found or provided.
|
||||
*
|
||||
* @author Adrian
|
||||
*/
|
||||
public class InvalidBundleException extends BaseException {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the InvalidBundleException.
|
||||
*/
|
||||
public InvalidBundleException() {
|
||||
super("Invalid Bundle");
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the InvalidBundleException.
|
||||
*/
|
||||
public InvalidBundleException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exception occurs when an invalid security level is provided.
|
||||
*
|
||||
* @author pinpong
|
||||
*/
|
||||
public class InvalidSecurityLevelException extends BaseException {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the InvalidSecurityLevelException.
|
||||
*/
|
||||
public InvalidSecurityLevelException() {
|
||||
super("Invalid security level");
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exception occurs when an invalid signature is encountered.
|
||||
*
|
||||
* @author Adrian
|
||||
*/
|
||||
public class InvalidSignatureException extends BaseException {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the InvalidSignatureException.
|
||||
*/
|
||||
public InvalidSignatureException() {
|
||||
super("Invalid Signatures!");
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exception occurs when an invalid transfer is provided.
|
||||
*
|
||||
* @author pinpong
|
||||
*/
|
||||
public class InvalidTransferException extends BaseException {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the InvalidTransferException.
|
||||
*/
|
||||
public InvalidTransferException() {
|
||||
super("Invalid Transfer!");
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exception occurs when invalid trytes is provided.
|
||||
* @author Adrian
|
||||
*/
|
||||
public class InvalidTrytesException extends BaseException {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the InvalidTrytesException.
|
||||
*/
|
||||
public InvalidTrytesException() {
|
||||
super("Invalid input trytes");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exception occurs when it not possible to get a inclusion state.
|
||||
*
|
||||
* @author Adrian
|
||||
*/
|
||||
public class NoInclusionStatesException extends BaseException {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the NoInclusionStatesException.
|
||||
*/
|
||||
public NoInclusionStatesException() {
|
||||
super("No inclusion states for the provided seed");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* @author Adrian
|
||||
*/
|
||||
public class NoInclusionStatesExcpection extends BaseException {
|
||||
|
||||
public NoInclusionStatesExcpection() {
|
||||
super("No inclusion states for the provided seed");
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exception occurs when its not possible to get node info.
|
||||
* @author Adrian
|
||||
*/
|
||||
public class NoNodeInfoException extends BaseException {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the NoNodeInfoException.
|
||||
*/
|
||||
public NoNodeInfoException() {
|
||||
super("Node info could not be retrieved");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package jota.error;
|
||||
|
||||
/**
|
||||
* This exception occurs when a transfer fails because their is not enough balance to perform the transfer.
|
||||
*
|
||||
* @author Adrian
|
||||
*/
|
||||
public class NotEnoughBalanceException extends BaseException {
|
||||
@@ -10,6 +12,9 @@ public class NotEnoughBalanceException extends BaseException {
|
||||
*/
|
||||
private static final long serialVersionUID = -3807270816402226476L;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the NotEnoughBalanceException.
|
||||
*/
|
||||
public NotEnoughBalanceException() {
|
||||
super("Not enough balance");
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* This class represents a Bundle, a set of transactions
|
||||
* This class represents a Bundle, a set of transactions.
|
||||
*
|
||||
* @author pinpong
|
||||
**/
|
||||
public class Bundle implements Comparable<Bundle> {
|
||||
@@ -55,6 +56,7 @@ public class Bundle implements Comparable<Bundle> {
|
||||
|
||||
/**
|
||||
* Sets the length of the bundle
|
||||
*
|
||||
* @param length The length.
|
||||
*/
|
||||
public void setLength(int length) {
|
||||
@@ -62,7 +64,8 @@ public class Bundle implements Comparable<Bundle> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a bundle entry
|
||||
* Adds a bundle entry.
|
||||
*
|
||||
* @param signatureMessageLength Length of the signature message.
|
||||
* @param address The address.
|
||||
* @param value The value.
|
||||
@@ -81,7 +84,8 @@ public class Bundle implements Comparable<Bundle> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the bundle using the specified curl implementation
|
||||
* Finalizes the bundle using the specified curl implementation,
|
||||
*
|
||||
* @param customCurl The custom curl.
|
||||
*/
|
||||
public void finalize(ICurl customCurl) {
|
||||
@@ -115,6 +119,7 @@ public class Bundle implements Comparable<Bundle> {
|
||||
|
||||
/**
|
||||
* Adds the trytes.
|
||||
*
|
||||
* @param signatureFragments The signature fragments.
|
||||
*/
|
||||
public void addTrytes(List<String> signatureFragments) {
|
||||
@@ -141,6 +146,7 @@ public class Bundle implements Comparable<Bundle> {
|
||||
|
||||
/**
|
||||
* Normalized the bundle.
|
||||
*
|
||||
* @param bundleHash The bundle hash.
|
||||
* @return normalizedBundle A normalized bundle hash.
|
||||
*/
|
||||
@@ -185,6 +191,7 @@ public class Bundle implements Comparable<Bundle> {
|
||||
|
||||
/**
|
||||
* Compares the current object with another object of the same type.
|
||||
*
|
||||
* @param o An object to compare with this object.
|
||||
* @return A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the <paramref name="other" /> parameter.Zero This object is equal to <paramref name="other" />. Greater than zero This object is greater than <paramref name="other" />.
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* This class represents an Input
|
||||
* This class represents an Input.
|
||||
*
|
||||
* @author Adrian
|
||||
**/
|
||||
public class Input {
|
||||
@@ -38,7 +39,7 @@ public class Input {
|
||||
/**
|
||||
* Get the address.
|
||||
*
|
||||
* @return address The address.
|
||||
* @return The address.
|
||||
*/
|
||||
public String getAddress() {
|
||||
return address;
|
||||
@@ -46,7 +47,8 @@ public class Input {
|
||||
|
||||
/**
|
||||
* Get the address.
|
||||
* @param address The address.
|
||||
*
|
||||
* @param address The address.
|
||||
*/
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
@@ -54,7 +56,8 @@ public class Input {
|
||||
|
||||
/**
|
||||
* Get the balance.
|
||||
* @return address The balance.
|
||||
*
|
||||
* @return The balance.
|
||||
*/
|
||||
public long getBalance() {
|
||||
return balance;
|
||||
@@ -62,7 +65,8 @@ public class Input {
|
||||
|
||||
/**
|
||||
* Get the balance.
|
||||
* @param balance The balance.
|
||||
*
|
||||
* @param balance The balance.
|
||||
*/
|
||||
public void setBalance(long balance) {
|
||||
this.balance = balance;
|
||||
@@ -70,7 +74,8 @@ public class Input {
|
||||
|
||||
/**
|
||||
* Get the keyIndex.
|
||||
* @return keyIndex The keyIndex.
|
||||
*
|
||||
* @return The keyIndex.
|
||||
*/
|
||||
public int getKeyIndex() {
|
||||
return keyIndex;
|
||||
@@ -78,7 +83,8 @@ public class Input {
|
||||
|
||||
/**
|
||||
* Get the keyIndex.
|
||||
* @param keyIndex The keyIndex.
|
||||
*
|
||||
* @param keyIndex The keyIndex.
|
||||
*/
|
||||
public void setKeyIndex(int keyIndex) {
|
||||
this.keyIndex = keyIndex;
|
||||
@@ -86,7 +92,8 @@ public class Input {
|
||||
|
||||
/**
|
||||
* Get the security.
|
||||
* @return security The security.
|
||||
*
|
||||
* @return The security.
|
||||
*/
|
||||
public int getSecurity() {
|
||||
return security;
|
||||
@@ -94,7 +101,8 @@ public class Input {
|
||||
|
||||
/**
|
||||
* Get the security.
|
||||
* @param security The security.
|
||||
*
|
||||
* @param security The security.
|
||||
*/
|
||||
public void setSecurity(int security) {
|
||||
this.security = security;
|
||||
|
||||
@@ -5,7 +5,8 @@ import com.google.gson.Gson;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents an Inputs
|
||||
* This class represents an Inputs.
|
||||
*
|
||||
* @author Adrian
|
||||
**/
|
||||
public class Inputs {
|
||||
@@ -34,7 +35,7 @@ public class Inputs {
|
||||
/**
|
||||
* Get the input list.
|
||||
*
|
||||
* @return inputList The input list.
|
||||
* @return The input list.
|
||||
*/
|
||||
public List<Input> getInputsList() {
|
||||
return inputsList;
|
||||
@@ -42,6 +43,7 @@ public class Inputs {
|
||||
|
||||
/**
|
||||
* Set the input list.
|
||||
*
|
||||
* @param inputsList The input list.
|
||||
*/
|
||||
public void setInputsList(List<Input> inputsList) {
|
||||
@@ -50,7 +52,8 @@ public class Inputs {
|
||||
|
||||
/**
|
||||
* Get the total balance.
|
||||
* @return totalBalance The total balance.
|
||||
*
|
||||
* @return The total balance.
|
||||
*/
|
||||
public long getTotalBalance() {
|
||||
return totalBalance;
|
||||
@@ -58,6 +61,7 @@ public class Inputs {
|
||||
|
||||
/**
|
||||
* Set the total balance.
|
||||
*
|
||||
* @param totalBalance The total balance.
|
||||
*/
|
||||
public void setTotalBalance(long totalBalance) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package jota.model;
|
||||
|
||||
/**
|
||||
* This class represents an Neighbor
|
||||
* This class represents an Neighbor.
|
||||
*
|
||||
* @author pinpong
|
||||
**/
|
||||
public class Neighbor {
|
||||
@@ -24,7 +25,7 @@ public class Neighbor {
|
||||
/**
|
||||
* Get the address.
|
||||
*
|
||||
* @return address The address.
|
||||
* @return The address.
|
||||
*/
|
||||
public String getAddress() {
|
||||
return address;
|
||||
@@ -33,7 +34,7 @@ public class Neighbor {
|
||||
/**
|
||||
* Get the number of all transactions.
|
||||
*
|
||||
* @return numberOfAllTransactions The number of all transactions.
|
||||
* @return The number of all transactions.
|
||||
*/
|
||||
public Integer getNumberOfAllTransactions() {
|
||||
return numberOfAllTransactions;
|
||||
@@ -41,7 +42,8 @@ public class Neighbor {
|
||||
|
||||
/**
|
||||
* Get the number of invalid transactions.
|
||||
* @return numberOfInvalidTransactions The number of invalid transactions.
|
||||
*
|
||||
* @return The number of invalid transactions.
|
||||
*/
|
||||
public Integer getNumberOfInvalidTransactions() {
|
||||
return numberOfInvalidTransactions;
|
||||
@@ -49,7 +51,8 @@ public class Neighbor {
|
||||
|
||||
/**
|
||||
* Get the number of nwe transactions.
|
||||
* @return numberOfNewTransactions The number of new transactions.
|
||||
*
|
||||
* @return The number of new transactions.
|
||||
*/
|
||||
public Integer getNumberOfNewTransactions() {
|
||||
return numberOfNewTransactions;
|
||||
|
||||
@@ -4,7 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents an Signature
|
||||
* This class represents an Signature.
|
||||
*
|
||||
* @author Adrian
|
||||
**/
|
||||
public class Signature {
|
||||
@@ -22,7 +23,7 @@ public class Signature {
|
||||
/**
|
||||
* Get the address.
|
||||
*
|
||||
* @return address The address.
|
||||
* @return The address.
|
||||
*/
|
||||
public String getAddress() {
|
||||
return address;
|
||||
@@ -39,7 +40,8 @@ public class Signature {
|
||||
|
||||
/**
|
||||
* Get the signatureFragments.
|
||||
* @return signatureFragments The signatureFragments.
|
||||
*
|
||||
* @return The signatureFragments.
|
||||
*/
|
||||
public List<String> getSignatureFragments() {
|
||||
return signatureFragments;
|
||||
@@ -47,6 +49,7 @@ public class Signature {
|
||||
|
||||
/**
|
||||
* Set the signatureFragments.
|
||||
*
|
||||
* @param signatureFragments The signatureFragments.
|
||||
*/
|
||||
public void setSignatureFragments(List<String> signatureFragments) {
|
||||
|
||||
@@ -12,7 +12,8 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This class represents an iota transaction
|
||||
* This class represents an iota transaction.
|
||||
*
|
||||
* @author pinpong
|
||||
*/
|
||||
public class Transaction {
|
||||
@@ -105,7 +106,7 @@ public class Transaction {
|
||||
/**
|
||||
* Get the hash.
|
||||
*
|
||||
* @return hash The hash.
|
||||
* @return The hash.
|
||||
*/
|
||||
public String getHash() {
|
||||
return hash;
|
||||
@@ -113,6 +114,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the hash.
|
||||
*
|
||||
* @param hash The hash.
|
||||
*/
|
||||
public void setHash(String hash) {
|
||||
@@ -121,7 +123,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the signature fragments.
|
||||
* @return signatureFragments The signature fragments.
|
||||
*
|
||||
* @return The signature fragments.
|
||||
*/
|
||||
public String getSignatureFragments() {
|
||||
return signatureFragments;
|
||||
@@ -129,6 +132,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the signature fragments.
|
||||
*
|
||||
* @param signatureFragments The signature fragments.
|
||||
*/
|
||||
public String setSignatureFragments(String signatureFragments) {
|
||||
@@ -137,7 +141,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the address.
|
||||
* @return address The address.
|
||||
*
|
||||
* @return The address.
|
||||
*/
|
||||
public String getAddress() {
|
||||
return address;
|
||||
@@ -145,6 +150,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the address.
|
||||
*
|
||||
* @param address The address.
|
||||
*/
|
||||
public void setAddress(String address) {
|
||||
@@ -153,7 +159,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the value.
|
||||
* @return value The value.
|
||||
*
|
||||
* @return The value.
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
@@ -161,6 +168,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the value.
|
||||
*
|
||||
* @param value The value.
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
@@ -169,7 +177,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the tag.
|
||||
* @return tag The tag.
|
||||
*
|
||||
* @return The tag.
|
||||
*/
|
||||
public String getTag() {
|
||||
return tag;
|
||||
@@ -177,6 +186,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*/
|
||||
public void setTag(String tag) {
|
||||
@@ -185,7 +195,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the timestamp.
|
||||
* @return timestamp The timestamp.
|
||||
*
|
||||
* @return The timestamp.
|
||||
*/
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
@@ -193,6 +204,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the timestamp.
|
||||
*
|
||||
* @param timestamp The timestamp.
|
||||
*/
|
||||
public void setTimestamp(String timestamp) {
|
||||
@@ -201,7 +213,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the current index.
|
||||
* @return currentIndex The current index.
|
||||
*
|
||||
* @return The current index.
|
||||
*/
|
||||
public String getCurrentIndex() {
|
||||
return currentIndex;
|
||||
@@ -217,7 +230,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the last index.
|
||||
* @return lastIndex The last index.
|
||||
*
|
||||
* @return The last index.
|
||||
*/
|
||||
public String getLastIndex() {
|
||||
return lastIndex;
|
||||
@@ -225,6 +239,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the last index.
|
||||
*
|
||||
* @param lastIndex The last index.
|
||||
*/
|
||||
public String setLastIndex(String lastIndex) {
|
||||
@@ -233,7 +248,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the bundle.
|
||||
* @return bundle The bundle.
|
||||
*
|
||||
* @return The bundle.
|
||||
*/
|
||||
public String getBundle() {
|
||||
return bundle;
|
||||
@@ -241,6 +257,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the bundle.
|
||||
*
|
||||
* @param bundle The bundle.
|
||||
*/
|
||||
public void setBundle(String bundle) {
|
||||
@@ -249,7 +266,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the trunk transaction.
|
||||
* @return trunkTransaction The trunk transaction.
|
||||
*
|
||||
* @return The trunk transaction.
|
||||
*/
|
||||
public String getTrunkTransaction() {
|
||||
return trunkTransaction;
|
||||
@@ -257,6 +275,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the trunk transaction.
|
||||
*
|
||||
* @param trunkTransaction The trunk transaction.
|
||||
*/
|
||||
public void setTrunkTransaction(String trunkTransaction) {
|
||||
@@ -265,7 +284,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the branch transaction.
|
||||
* @return branchTransaction The branch transaction.
|
||||
*
|
||||
* @return The branch transaction.
|
||||
*/
|
||||
public String getBranchTransaction() {
|
||||
return branchTransaction;
|
||||
@@ -273,6 +293,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the branch transaction.
|
||||
*
|
||||
* @param branchTransaction The branch transaction.
|
||||
*/
|
||||
public void setBranchTransaction(String branchTransaction) {
|
||||
@@ -281,7 +302,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the nonce.
|
||||
* @return nonce The nonce.
|
||||
*
|
||||
* @return The nonce.
|
||||
*/
|
||||
public String getNonce() {
|
||||
return nonce;
|
||||
@@ -289,6 +311,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the nonce.
|
||||
*
|
||||
* @param nonce The trunk nonce.
|
||||
*/
|
||||
public void setNonce(String nonce) {
|
||||
@@ -297,7 +320,8 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Get the persistence.
|
||||
* @return persistence The persistence.
|
||||
*
|
||||
* @return The persistence.
|
||||
*/
|
||||
public Boolean getPersistence() {
|
||||
return persistence;
|
||||
@@ -305,6 +329,7 @@ public class Transaction {
|
||||
|
||||
/**
|
||||
* Set the persistence.
|
||||
*
|
||||
* @param persistence The persistence.
|
||||
*/
|
||||
public void setPersistence(Boolean persistence) {
|
||||
|
||||
@@ -3,7 +3,8 @@ package jota.model;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* This class represents a Transfer
|
||||
* This class represents a Transfer.
|
||||
*
|
||||
* @author pinpong
|
||||
*/
|
||||
public class Transfer {
|
||||
@@ -54,14 +55,15 @@ public class Transfer {
|
||||
/**
|
||||
* Get the address.
|
||||
*
|
||||
* @return address The address.
|
||||
* @return The address.
|
||||
*/
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the address
|
||||
* Set the address.
|
||||
*
|
||||
* @param address The address.
|
||||
*/
|
||||
public void setAddress(String address) {
|
||||
@@ -70,14 +72,16 @@ public class Transfer {
|
||||
|
||||
/**
|
||||
* Get the hash.
|
||||
* @return hash The hash.
|
||||
*
|
||||
* @return The hash.
|
||||
*/
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the hash
|
||||
* Set the hash.
|
||||
*
|
||||
* @param hash The hash.
|
||||
*/
|
||||
public void setHash(String hash) {
|
||||
@@ -86,14 +90,16 @@ public class Transfer {
|
||||
|
||||
/**
|
||||
* Get the persistence.
|
||||
* @return persistence The persistence.
|
||||
*
|
||||
* @return The persistence.
|
||||
*/
|
||||
public Boolean getPersistence() {
|
||||
return persistence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the persistence
|
||||
* Set the persistence.
|
||||
*
|
||||
* @param persistence The persistence.
|
||||
*/
|
||||
public void setPersistence(Boolean persistence) {
|
||||
@@ -102,14 +108,16 @@ public class Transfer {
|
||||
|
||||
/**
|
||||
* Get the timestamp.
|
||||
* @return timestamp The timestamp.
|
||||
*
|
||||
* @return The timestamp.
|
||||
*/
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timestamp
|
||||
* Set the timestamp.
|
||||
*
|
||||
* @param timestamp The timestamp.
|
||||
*/
|
||||
public void setTimestamp(String timestamp) {
|
||||
@@ -118,14 +126,16 @@ public class Transfer {
|
||||
|
||||
/**
|
||||
* Get the value.
|
||||
* @return value The value.
|
||||
*
|
||||
* @return The value.
|
||||
*/
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value
|
||||
* Set the value.
|
||||
*
|
||||
* @param value The value.
|
||||
*/
|
||||
public void setValue(long value) {
|
||||
@@ -134,14 +144,16 @@ public class Transfer {
|
||||
|
||||
/**
|
||||
* Get the message.
|
||||
* @return message The message.
|
||||
*
|
||||
* @return The message.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message
|
||||
* Set the message.
|
||||
*
|
||||
* @param message The message.
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
@@ -150,14 +162,16 @@ public class Transfer {
|
||||
|
||||
/**
|
||||
* Get the tag.
|
||||
* @return tag The tag.
|
||||
*
|
||||
* @return The tag.
|
||||
*/
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tag
|
||||
* Set the tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*/
|
||||
public void setTag(String tag) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package jota.pow;
|
||||
|
||||
/**
|
||||
* This interface abstracts the curl hashing algorithm
|
||||
* This interface abstracts the curl hashing algorithm.
|
||||
*
|
||||
* @author Adrian
|
||||
*/
|
||||
public interface ICurl {
|
||||
@@ -12,7 +13,7 @@ public interface ICurl {
|
||||
* @param trits The trits.
|
||||
* @param offset The offset to start from.
|
||||
* @param length The length.
|
||||
* @return
|
||||
* @return The ICurl instance (used for method chaining).
|
||||
*/
|
||||
ICurl absorb(final int[] trits, int offset, int length);
|
||||
|
||||
@@ -20,53 +21,60 @@ public interface ICurl {
|
||||
* Absorbs the specified trits.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @return
|
||||
* @return The ICurl instance (used for method chaining).
|
||||
*/
|
||||
ICurl absorb(final int[] trits);
|
||||
|
||||
/**
|
||||
* Squeezes the specified trits.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @param offset The offset to start from.
|
||||
* @param length The length.
|
||||
* @return
|
||||
* @return The squeezed trits.
|
||||
*/
|
||||
int[] squeeze(final int[] trits, int offset, int length);
|
||||
|
||||
/**
|
||||
* Squeezes the specified trits.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @return
|
||||
* @return The squeezed trits.
|
||||
*/
|
||||
int[] squeeze(final int[] trits);
|
||||
|
||||
/**
|
||||
* Transforms this instance.
|
||||
* @return
|
||||
*
|
||||
* @return The ICurl instance (used for method chaining).
|
||||
*/
|
||||
ICurl transform();
|
||||
|
||||
/**
|
||||
* Resets this state.
|
||||
* @return
|
||||
*
|
||||
* @return The ICurl instance (used for method chaining).
|
||||
*/
|
||||
ICurl reset();
|
||||
|
||||
/**
|
||||
* Gets or sets the state.
|
||||
* @return
|
||||
*
|
||||
* @return The stae.
|
||||
*/
|
||||
int[] getState();
|
||||
|
||||
/**
|
||||
* Sets or sets the state.
|
||||
* @param state
|
||||
*
|
||||
* @param state The state.
|
||||
*/
|
||||
void setState(int[] state);
|
||||
|
||||
/**
|
||||
* Clones this instance.
|
||||
* @return
|
||||
*
|
||||
* @return A new instance.
|
||||
*/
|
||||
ICurl clone();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ package jota.pow;
|
||||
*/
|
||||
public class JCurl implements ICurl {
|
||||
|
||||
/**
|
||||
* The hash length.
|
||||
*/
|
||||
public static final int HASH_LENGTH = 243;
|
||||
private static final int STATE_LENGTH = 3 * HASH_LENGTH;
|
||||
|
||||
@@ -15,6 +18,14 @@ public class JCurl implements ICurl {
|
||||
|
||||
private int[] state = new int[STATE_LENGTH];
|
||||
|
||||
/**
|
||||
* Absorbs the specified trits.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @param offset The offset to start from.
|
||||
* @param length The length.
|
||||
* @return The ICurl instance (used for method chaining).
|
||||
*/
|
||||
public JCurl absorb(final int[] trits, int offset, int length) {
|
||||
|
||||
do {
|
||||
@@ -26,11 +37,21 @@ public class JCurl implements ICurl {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Absorbs the specified trits.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @return The ICurl instance (used for method chaining).
|
||||
*/
|
||||
public JCurl absorb(final int[] trits) {
|
||||
return absorb(trits, 0, trits.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms this instance.
|
||||
*
|
||||
* @return The ICurl instance (used for method chaining).
|
||||
*/
|
||||
public JCurl transform() {
|
||||
|
||||
final int[] scratchpad = new int[STATE_LENGTH];
|
||||
@@ -44,6 +65,11 @@ public class JCurl implements ICurl {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets this state.
|
||||
*
|
||||
* @return The ICurl instance (used for method chaining).
|
||||
*/
|
||||
public JCurl reset() {
|
||||
for (int stateIndex = 0; stateIndex < STATE_LENGTH; stateIndex++) {
|
||||
state[stateIndex] = 0;
|
||||
@@ -51,6 +77,14 @@ public class JCurl implements ICurl {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Squeezes the specified trits.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @param offset The offset to start from.
|
||||
* @param length The length.
|
||||
* @return The squeezes trits.
|
||||
*/
|
||||
public int[] squeeze(final int[] trits, int offset, int length) {
|
||||
|
||||
do {
|
||||
@@ -62,18 +96,39 @@ public class JCurl implements ICurl {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Squeezes the specified trits.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @return The squeezes trits.
|
||||
*/
|
||||
public int[] squeeze(final int[] trits) {
|
||||
return squeeze(trits, 0, trits.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the states.
|
||||
*
|
||||
* @return The state.
|
||||
*/
|
||||
public int[] getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state.
|
||||
*
|
||||
* @param state The states.
|
||||
*/
|
||||
public void setState(int[] state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones this instance.
|
||||
*
|
||||
* @return A new instance.
|
||||
*/
|
||||
@Override
|
||||
public ICurl clone() {
|
||||
return new JCurl();
|
||||
|
||||
@@ -4,17 +4,18 @@ import jota.error.InvalidAddressException;
|
||||
import jota.pow.JCurl;
|
||||
|
||||
/**
|
||||
* This class defines utility methods to add/remove the checksum to/from an address
|
||||
* This class defines utility methods to add/remove the checksum to/from an address.
|
||||
*
|
||||
* @author pinpong
|
||||
*/
|
||||
public class Checksum {
|
||||
|
||||
/**
|
||||
* Adds the checksum to the specified address
|
||||
* Adds the checksum to the specified address.
|
||||
*
|
||||
* @param address address without checksum
|
||||
* @return the address with the appended checksum
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @param address The address without checksum.
|
||||
* @return The address with the appended checksum.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
**/
|
||||
public static String addChecksum(String address) throws InvalidAddressException {
|
||||
InputValidator.checkAddress(address);
|
||||
@@ -24,35 +25,29 @@ public class Checksum {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the checksum to the specified address
|
||||
* Remove the checksum to the specified address.
|
||||
*
|
||||
* @param address address with checksum
|
||||
* @return the address without checksum
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an address with checksum
|
||||
* @param address The address with checksum.
|
||||
* @return The address without checksum.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an address with checksum.
|
||||
**/
|
||||
public static String removeChecksum(String address) throws InvalidAddressException {
|
||||
if (isAddressWithChecksum(address)) {
|
||||
return getAddress(address);
|
||||
return removeChecksumFromAddress(address);
|
||||
}
|
||||
throw new InvalidAddressException();
|
||||
}
|
||||
|
||||
/**
|
||||
* remove checksum length
|
||||
*
|
||||
* @param addressWithChecksum address with checksum
|
||||
* @return address without checksum
|
||||
**/
|
||||
private static String getAddress(String addressWithChecksum) {
|
||||
private static String removeChecksumFromAddress(String addressWithChecksum) {
|
||||
return addressWithChecksum.substring(0, Constants.ADDRESS_LENGTH_WITHOUT_CHECKSUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified address with checksum has a valid checksum.
|
||||
*
|
||||
* @param addressWithChecksum address
|
||||
* @return <c>true</c> if the specified address with checksum has a valid checksum [the specified address with checksum]; otherwise, <c>false</c>.
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @param addressWithChecksum The address with checksum.
|
||||
* @return <code>true</code> if the specified address with checksum has a valid checksum [the specified address with checksum]; otherwise, <code>false</code>.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
**/
|
||||
public static boolean isValidChecksum(String addressWithChecksum) throws InvalidAddressException {
|
||||
String addressWithoutChecksum = removeChecksum(addressWithChecksum);
|
||||
@@ -62,11 +57,11 @@ public class Checksum {
|
||||
|
||||
|
||||
/**
|
||||
* check if specified address is a address with checksum
|
||||
* Check if specified address is a address with checksum.
|
||||
*
|
||||
* @param address address
|
||||
* @return boolean
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @param address The address to check.
|
||||
* @return <code>true</code> if the specified address is with checksum ; otherwise, <code>false</code>.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address
|
||||
**/
|
||||
public static boolean isAddressWithChecksum(String address) throws InvalidAddressException {
|
||||
return InputValidator.checkAddress(address) && address.length() == Constants.ADDRESS_LENGTH_WITH_CHECKSUM;
|
||||
@@ -78,18 +73,12 @@ public class Checksum {
|
||||
*
|
||||
* @param address address
|
||||
* @return boolean
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address
|
||||
**/
|
||||
public static boolean isAddressWithoutChecksum(String address) throws InvalidAddressException {
|
||||
return InputValidator.checkAddress(address) && address.length() == Constants.ADDRESS_LENGTH_WITHOUT_CHECKSUM;
|
||||
}
|
||||
|
||||
/**
|
||||
* calculate the checksum to the specified address
|
||||
*
|
||||
* @param address address
|
||||
* @return the checksum
|
||||
**/
|
||||
private static String calculateChecksum(String address) {
|
||||
JCurl curl = new JCurl();
|
||||
curl.reset();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package jota.utils;
|
||||
|
||||
/**
|
||||
* This class defines the global constants
|
||||
* This class defines the global constants.
|
||||
*
|
||||
* @author pinpong
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class provides a set of utility methods to are used to convert between different formats
|
||||
* This class provides a set of utility methods to are used to convert between different formats.
|
||||
*/
|
||||
public class Converter {
|
||||
|
||||
@@ -47,12 +47,12 @@ public class Converter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the specified trits array to bytes
|
||||
* Converts the specified trits array to bytes.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @param trits The trits.
|
||||
* @param offset The offset to start from.
|
||||
* @param size The size.
|
||||
* @return bytes
|
||||
* @param size The size.
|
||||
* @return The bytes.
|
||||
*/
|
||||
public static byte[] bytes(final int[] trits, final int offset, final int size) {
|
||||
|
||||
@@ -74,7 +74,7 @@ public class Converter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the trits from the specified bytes and stores it into the provided trits array
|
||||
* Gets the trits from the specified bytes and stores it into the provided trits array.
|
||||
*
|
||||
* @param bytes The bytes.
|
||||
* @param trits The trits.
|
||||
@@ -104,7 +104,7 @@ public class Converter {
|
||||
*
|
||||
* @param trytes The trytes.
|
||||
* @param length The length
|
||||
* @return a trits array.
|
||||
* @return A trits array.
|
||||
*/
|
||||
public static int[] trits(final String trytes, int length) {
|
||||
int[] trits = trits(trytes);
|
||||
@@ -121,10 +121,10 @@ public class Converter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the specified trinary encoded trytes string to trits
|
||||
* Converts the specified trinary encoded trytes string to trits.
|
||||
*
|
||||
* @param trytes The trytes.
|
||||
* @return a trits array
|
||||
* @return A trits array.
|
||||
*/
|
||||
public static int[] tritsString(final String trytes) {
|
||||
int[] d = new int[3 * trytes.length()];
|
||||
@@ -135,10 +135,10 @@ public class Converter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts trytes into trits
|
||||
* Converts trytes into trits.
|
||||
*
|
||||
* @param trytes trytes to be converted
|
||||
* @return array of trits
|
||||
* @param trytes The trytes to be converted.
|
||||
* @return Array of trits.
|
||||
**/
|
||||
public static int[] trits(final String trytes) {
|
||||
final List<Integer> trits = new LinkedList<>();
|
||||
@@ -180,9 +180,9 @@ public class Converter {
|
||||
/**
|
||||
* Copies the trits from the input string into the destination array
|
||||
*
|
||||
* @param input The input String.
|
||||
* @param input The input String.
|
||||
* @param destination The destination array.
|
||||
* @return destination The destination.
|
||||
* @return The destination.
|
||||
*/
|
||||
public static int[] copyTrits(final String input, final int[] destination) {
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
@@ -195,12 +195,12 @@ public class Converter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts trites to trytes
|
||||
* Converts trites to trytes.
|
||||
*
|
||||
* @param trits trits to be converted
|
||||
* @param offset
|
||||
* @param size
|
||||
* @return trytes
|
||||
* @param trits Teh trits to be converted.
|
||||
* @param offset The offset to start from.
|
||||
* @param size The size.
|
||||
* @return The trytes.
|
||||
**/
|
||||
public static String trytes(final int[] trits, final int offset, final int size) {
|
||||
|
||||
@@ -222,21 +222,21 @@ public class Converter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the specified trits array to trytes in integer representation
|
||||
* Converts the specified trits array to trytes in integer representation.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @param offset The offset.
|
||||
* @return value The value.
|
||||
* @param offset The offset to start from.
|
||||
* @return The value.
|
||||
*/
|
||||
public static int tryteValue(final int[] trits, final int offset) {
|
||||
return trits[offset] + trits[offset + 1] * 3 + trits[offset + 2] * 9;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the specified trits to its corresponding integer value
|
||||
* Converts the specified trits to its corresponding integer value.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @return value The value.
|
||||
* @return The value.
|
||||
*/
|
||||
public static int value(final int[] trits) {
|
||||
int value = 0;
|
||||
@@ -248,10 +248,10 @@ public class Converter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the specified trits to its corresponding integer value
|
||||
* Converts the specified trits to its corresponding integer value.
|
||||
*
|
||||
* @param trits The trits.
|
||||
* @return value The value
|
||||
* @return The value.
|
||||
*/
|
||||
public static long longValue(final int[] trits) {
|
||||
long value = 0;
|
||||
|
||||
@@ -8,16 +8,17 @@ import org.apache.commons.lang3.math.NumberUtils;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class provides methods to validate the parameters of different iota API methods
|
||||
* This class provides methods to validate the parameters of different iota API methods.
|
||||
*
|
||||
* @author pinpong
|
||||
*/
|
||||
public class InputValidator {
|
||||
|
||||
/**
|
||||
* Determines whether the specified string is an adrdress.
|
||||
* Determines whether the specified string is an address.
|
||||
*
|
||||
* @param address address to validate
|
||||
* @return <c>true</c> if the specified string is an address; otherwise, <c>false</c>.
|
||||
* @param address The address to validate.
|
||||
* @return <code>true</code> if the specified string is an address; otherwise, <code>false</code>.
|
||||
**/
|
||||
public static boolean isAddress(String address) {
|
||||
return (address.length() == Constants.ADDRESS_LENGTH_WITHOUT_CHECKSUM ||
|
||||
@@ -25,11 +26,11 @@ public class InputValidator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the specified address is an address and throws and exception if the address is invalid
|
||||
* Checks whether the specified address is an address and throws and exception if the address is invalid.
|
||||
*
|
||||
* @param address address to validate
|
||||
* @return <c>true</c> if the specified string is an address; otherwise, <c>false</c>.
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @param address The address to validate.
|
||||
* @return <code>true</code> if the specified string is an address; otherwise, <code>false</code>.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
**/
|
||||
public static boolean checkAddress(String address) throws InvalidAddressException {
|
||||
if (!isAddress(address)) {
|
||||
@@ -39,11 +40,11 @@ public class InputValidator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified string contains only characters from the trytes alphabet (see <see cref="Constants.TryteAlphabet"/>)
|
||||
* Determines whether the specified string contains only characters from the trytes alphabet (see <see cref="Constants.TryteAlphabet"/>).
|
||||
*
|
||||
* @param trytes the trytes
|
||||
* @param length the length
|
||||
* @return <c>true</c> if the specified trytes are trytes otherwise, <c>false</c>.
|
||||
* @param trytes The trytes to validate.
|
||||
* @param length The length.
|
||||
* @return <code>true</code> if the specified trytes are trytes otherwise, <code>false</code>.
|
||||
**/
|
||||
public static boolean isTrytes(final String trytes, final int length) {
|
||||
return trytes.matches("^[A-Z9]{" + (length == 0 ? "0," : length) + "}$");
|
||||
@@ -52,29 +53,29 @@ public class InputValidator {
|
||||
/**
|
||||
* Determines whether the specified string consist only of '9'.
|
||||
*
|
||||
* @param trytes The trytes.
|
||||
* @param trytes The trytes to validate.
|
||||
* @param length The length.
|
||||
* @return <c>true</c> if the specified string consist only of '9'; otherwise, <c>false</c>.
|
||||
* @return <code>true</code> if the specified string consist only of '9'; otherwise, <code>false</code>.
|
||||
**/
|
||||
public static boolean isNinesTrytes(final String trytes, final int length) {
|
||||
return trytes.matches("^[9]{" + (length == 0 ? "0," : length) + "}$");
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified string represents a signed integer
|
||||
* Determines whether the specified string represents a signed integer.
|
||||
*
|
||||
* @param value the value
|
||||
* @return <c>true</c> the specified string represents an integer value; otherwise, <c>false</c>.
|
||||
* @param value The value to validate.
|
||||
* @return <code>true</code> the specified string represents an integer value; otherwise, <code>false</code>.
|
||||
**/
|
||||
public static boolean isValue(final String value) {
|
||||
return NumberUtils.isNumber(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified string array contains only trytes
|
||||
* Determines whether the specified string array contains only trytes.
|
||||
*
|
||||
* @param trytes The trytes.
|
||||
* @return <c>true</c> if the specified array contains only valid trytes otherwise, <c>false</c>.
|
||||
* @param trytes The trytes array to validate.
|
||||
* @return <code>true</code> if the specified array contains only valid trytes otherwise, <code>false</code>.
|
||||
**/
|
||||
public static boolean isArrayOfTrytes(String[] trytes){
|
||||
for (String tryte : trytes) {
|
||||
@@ -87,10 +88,10 @@ public class InputValidator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified array contains only valid hashes
|
||||
* Determines whether the specified array contains only valid hashes.
|
||||
*
|
||||
* @param hashes The hashes.
|
||||
* @return <c>true</c> the specified array contains only valid hashes; otherwise, <c>false</c>.
|
||||
* @param hashes The hashes array to validate.
|
||||
* @return <code>true</code> the specified array contains only valid hashes; otherwise, <code>false</code>.
|
||||
**/
|
||||
public static boolean isArrayOfHashes(String[] hashes) {
|
||||
if (hashes == null)
|
||||
@@ -112,10 +113,10 @@ public class InputValidator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified transfers are valid
|
||||
* Determines whether the specified transfers are valid.
|
||||
*
|
||||
* @param transfers The transfers.
|
||||
* @return <c>true</c> if the specified transfers are valid; otherwise, <c>false</c>.
|
||||
* @param transfers The transfers list to validate.
|
||||
* @return <code>true</code> if the specified transfers are valid; otherwise, <code>false</code>.
|
||||
**/
|
||||
public static boolean isTransfersCollectionValid(final List<Transfer> transfers) {
|
||||
|
||||
@@ -130,8 +131,8 @@ public class InputValidator {
|
||||
/**
|
||||
* Determines whether the specified transfer is valid.
|
||||
*
|
||||
* @param transfer The transfer.
|
||||
* @return <c>true</c> if the specified transfer is valid; otherwise, <c>false</c>.
|
||||
* @param transfer The transfer to validate.
|
||||
* @return <code>true</code> if the specified transfer is valid; otherwise, <code>false</code>>.
|
||||
**/
|
||||
public static boolean isValidTransfer(final Transfer transfer) {
|
||||
|
||||
@@ -151,9 +152,9 @@ public class InputValidator {
|
||||
/**
|
||||
* Checks if the seed is valid. If not, an exception is thrown.
|
||||
*
|
||||
* @param seed the seed
|
||||
* @return validated seed
|
||||
* @exception IllegalStateException Format not in trytes or Invalid Seed: Seed too long
|
||||
* @param seed The seed to validate.
|
||||
* @return The validated seed.
|
||||
* @throws IllegalStateException Format not in trytes or Invalid Seed: Seed too long.
|
||||
**/
|
||||
public static String validateSeed(String seed) {
|
||||
if (seed.length() > 81)
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Client Side computation service
|
||||
* Client Side computation service.
|
||||
*
|
||||
* @author davassi
|
||||
*/
|
||||
@@ -21,13 +21,13 @@ public class IotaAPIUtils {
|
||||
/**
|
||||
* Generates a new address
|
||||
*
|
||||
* @param seed tryte-encoded seed. It should be noted that this seed is not transferred
|
||||
* @param security security secuirty level of private key / seed
|
||||
* @param index key index to start search from. If the index is provided, the generation of the address is not deterministic.
|
||||
* @param checksum adds 9-tryte address checksum
|
||||
* @param curl
|
||||
* @return an String with address
|
||||
* @exception InvalidAddressException is thrown when the specified address is not an valid address
|
||||
* @param seed The tryte-encoded seed. It should be noted that this seed is not transferred.
|
||||
* @param security The secuirty level of private key / seed.
|
||||
* @param index The index to start search from. If the index is provided, the generation of the address is not deterministic.
|
||||
* @param checksum The adds 9-tryte address checksum
|
||||
* @param curl The curl instance.
|
||||
* @return An String with address.
|
||||
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
|
||||
*/
|
||||
public static String newAddress(String seed, int security, int index, boolean checksum, ICurl curl) throws InvalidAddressException {
|
||||
Signing signing = new Signing(curl);
|
||||
|
||||
@@ -3,18 +3,19 @@ package jota.utils;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* This class provides methods to convert Iota to different units
|
||||
* This class provides methods to convert Iota to different units.
|
||||
*
|
||||
* @author sascha
|
||||
*/
|
||||
public class IotaUnitConverter {
|
||||
|
||||
/**
|
||||
* convert the iota amount
|
||||
* Convert the iota amount.
|
||||
*
|
||||
* @param amount the amount
|
||||
* @param fromUnit the source unit e.g. the unit of amount
|
||||
* @param toUnit the target unit
|
||||
* @return the specified amount in the target unit
|
||||
* @param amount The amount.
|
||||
* @param fromUnit The source unit e.g. the unit of amount.
|
||||
* @param toUnit The target unit.
|
||||
* @return The specified amount in the target unit.
|
||||
**/
|
||||
public static long convertUnits(long amount, IotaUnits fromUnit, IotaUnits toUnit) {
|
||||
long amountInSource = (long) (amount * Math.pow(10, fromUnit.getValue()));
|
||||
@@ -22,22 +23,22 @@ public class IotaUnitConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* convert unit
|
||||
* Convert unit.
|
||||
*
|
||||
* @param amount the amount
|
||||
* @param toUnit the target unit
|
||||
* @return the specified amount in the target unit
|
||||
* @param amount The amount.
|
||||
* @param toUnit The target unit.
|
||||
* @return The specified amount in the target unit.
|
||||
**/
|
||||
private static long convertUnits(long amount, IotaUnits toUnit) {
|
||||
return (long) (amount / Math.pow(10, toUnit.getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* convert the iota amount to text
|
||||
* Convert the iota amount to text.
|
||||
*
|
||||
* @param amount the amount
|
||||
* @param extended extended length
|
||||
* @return the specified amount in the target unit
|
||||
* @param amount The amount.
|
||||
* @param extended Extended length.
|
||||
* @return The specified amount in the target unit.
|
||||
**/
|
||||
public static String convertRawIotaAmountToDisplayText(long amount, boolean extended) {
|
||||
IotaUnits unit = findOptimalIotaUnitToDisplay(amount);
|
||||
@@ -46,22 +47,22 @@ public class IotaUnitConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* convert amount to target unit
|
||||
* Convert amount to target unit.
|
||||
*
|
||||
* @param amount the amount
|
||||
* @return the target unit
|
||||
* @param amount The amount.
|
||||
* @return The target unit.
|
||||
**/
|
||||
public static double convertAmountTo(long amount, IotaUnits target) {
|
||||
return amount / Math.pow(10, target.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* create amount with unit text
|
||||
* Create amount with unit text.
|
||||
*
|
||||
* @param amountInUnit the amount in units
|
||||
* @param unit the unit
|
||||
* @param extended extended length
|
||||
* @return the target unit
|
||||
* @param amountInUnit The amount in units.
|
||||
* @param unit The unit.
|
||||
* @param extended Extended length.
|
||||
* @return The target unit.
|
||||
**/
|
||||
private static String createAmountWithUnitDisplayText(double amountInUnit, IotaUnits unit, boolean extended) {
|
||||
String result = createAmountDisplayText(amountInUnit, unit, extended);
|
||||
@@ -70,12 +71,12 @@ public class IotaUnitConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* create amount text
|
||||
* Create amount text.
|
||||
*
|
||||
* @param amountInUnit the amount in units
|
||||
* @param unit the unit
|
||||
* @param extended extended length
|
||||
* @return the target unit
|
||||
* @param amountInUnit The amount in units.
|
||||
* @param unit The unit.
|
||||
* @param extended Extended length.
|
||||
* @return The target unit.
|
||||
**/
|
||||
public static String createAmountDisplayText(double amountInUnit, IotaUnits unit, boolean extended) {
|
||||
DecimalFormat df;
|
||||
@@ -90,10 +91,10 @@ public class IotaUnitConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* finds the optimal unit to display the specified amount in
|
||||
* Finds the optimal unit to display the specified amount in.
|
||||
*
|
||||
* @param amount the amount
|
||||
* @return the optimal IotaUnit
|
||||
* @param amount The amount.
|
||||
* @return The optimal IotaUnit.
|
||||
**/
|
||||
public static IotaUnits findOptimalIotaUnitToDisplay(long amount) {
|
||||
int length = String.valueOf(amount).length();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package jota.utils;
|
||||
|
||||
/**
|
||||
* Table of IOTA units based off of the standard system of Units
|
||||
* Table of IOTA units based off of the standard system of Units.
|
||||
*
|
||||
* @author pinpong
|
||||
**/
|
||||
public enum IotaUnits {
|
||||
@@ -27,7 +28,7 @@ public enum IotaUnits {
|
||||
/**
|
||||
* Gets the unit.
|
||||
*
|
||||
* @return unit The IOTA Unit.
|
||||
* @return The IOTA Unit.
|
||||
*/
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
@@ -36,7 +37,7 @@ public enum IotaUnits {
|
||||
/**
|
||||
* Gets the value.
|
||||
*
|
||||
* @return unit The value.
|
||||
* @return The value.
|
||||
*/
|
||||
public long getValue() {
|
||||
return value;
|
||||
|
||||
@@ -129,7 +129,7 @@ public class Multisig {
|
||||
* @param bundleToSign
|
||||
* @param inputAddress
|
||||
* @param keyTrytes
|
||||
* @return trytes Returns bundle trytes
|
||||
* @return Returns bundle trytes.
|
||||
**/
|
||||
private void addSignature(Bundle[] bundleToSign, String inputAddress, String keyTrytes) {
|
||||
|
||||
|
||||
@@ -8,13 +8,21 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
* @author Adrian
|
||||
*/
|
||||
public class NamedThreadFactory implements ThreadFactory {
|
||||
|
||||
private final String baseName;
|
||||
private final AtomicInteger threadNum = new AtomicInteger(0);
|
||||
|
||||
/**
|
||||
* @param baseName
|
||||
*/
|
||||
public NamedThreadFactory(String baseName) {
|
||||
this.baseName = baseName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param r
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public synchronized Thread newThread(Runnable r) {
|
||||
Thread t = Executors.defaultThreadFactory().newThread(r);
|
||||
|
||||
@@ -11,10 +11,15 @@ import java.util.concurrent.Executors;
|
||||
* @author Adrian
|
||||
*/
|
||||
public class Parallel {
|
||||
private static final int NUM_CORES = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
private static final int NUM_CORES = Runtime.getRuntime().availableProcessors();
|
||||
private static final ExecutorService forPool = Executors.newFixedThreadPool(NUM_CORES * 2, new NamedThreadFactory("Parallel.For"));
|
||||
|
||||
/**
|
||||
* @param elements
|
||||
* @param operation
|
||||
* @param <T>
|
||||
*/
|
||||
public static <T> void For(final Iterable<T> elements, final Operation<T> operation) {
|
||||
try {
|
||||
// invokeAll blocks for us until all submitted tasks in the call complete
|
||||
@@ -24,6 +29,12 @@ public class Parallel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param elements
|
||||
* @param operation
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> Collection<Callable<Void>> createCallables(final Iterable<T> elements, final Operation<T> operation) {
|
||||
List<Callable<Void>> callables = new LinkedList<>();
|
||||
for (final T elem : elements) {
|
||||
@@ -39,6 +50,10 @@ public class Parallel {
|
||||
return callables;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface Operation<T> {
|
||||
void perform(T pParameter);
|
||||
}
|
||||
|
||||
@@ -3,16 +3,17 @@ package jota.utils;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
/**
|
||||
* This class allows to create a secure random generated seed
|
||||
* This class allows to create a secure random generated seed.
|
||||
*
|
||||
* @author pinpong
|
||||
*/
|
||||
public class SeedRandomGenerator {
|
||||
|
||||
|
||||
/**
|
||||
* generate a new seed
|
||||
* Generate a new seed.
|
||||
*
|
||||
* @return random generated seed
|
||||
* @return Random generated seed.
|
||||
**/
|
||||
public static String generateNewSeed() {
|
||||
char[] chars = Constants.TRYTE_ALPHABET.toCharArray();
|
||||
|
||||
@@ -9,6 +9,10 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Signing {
|
||||
|
||||
/**
|
||||
* Ask @come-from-beyond
|
||||
*/
|
||||
private ICurl curl;
|
||||
|
||||
public Signing() {
|
||||
|
||||
@@ -4,36 +4,56 @@ package jota.utils;
|
||||
* @author adrian
|
||||
*/
|
||||
public class StopWatch {
|
||||
|
||||
private long startTime = 0;
|
||||
private boolean running = false;
|
||||
private long currentTime = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public StopWatch() {
|
||||
this.startTime = System.currentTimeMillis();
|
||||
this.running = true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void reStart() {
|
||||
this.startTime = System.currentTimeMillis();
|
||||
this.running = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public StopWatch stop() {
|
||||
this.running = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void pause() {
|
||||
this.running = false;
|
||||
currentTime = System.currentTimeMillis() - startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void resume() {
|
||||
this.running = true;
|
||||
this.startTime = System.currentTimeMillis() - currentTime;
|
||||
}
|
||||
|
||||
//elaspsed time in milliseconds
|
||||
/**
|
||||
* Elapsed time in milliseconds.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getElapsedTimeMili() {
|
||||
long elapsed = 0;
|
||||
if (running) {
|
||||
@@ -42,7 +62,11 @@ public class StopWatch {
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
//elaspsed time in seconds
|
||||
/**
|
||||
* Elapsed time in seconds.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getElapsedTimeSecs() {
|
||||
long elapsed = 0;
|
||||
if (running) {
|
||||
@@ -51,7 +75,11 @@ public class StopWatch {
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
//elaspsed time in minutes
|
||||
/**
|
||||
* Elapsed time in minutes.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getElapsedTimeMin() {
|
||||
long elapsed = 0;
|
||||
if (running) {
|
||||
@@ -60,7 +88,11 @@ public class StopWatch {
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
//elaspsed time in hours
|
||||
/**
|
||||
* Elapsed time in hours.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getElapsedTimeHour() {
|
||||
long elapsed = 0;
|
||||
if (running) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package jota.utils;
|
||||
|
||||
/**
|
||||
* This class allows to convert between ASCII and tryte encoded strings
|
||||
* This class allows to convert between ASCII and tryte encoded strings.
|
||||
*
|
||||
* @author pinpong
|
||||
*/
|
||||
public class TrytesConverter {
|
||||
@@ -34,7 +35,7 @@ public class TrytesConverter {
|
||||
* Our tryte pair is "IC"
|
||||
*
|
||||
*
|
||||
* @param inputString
|
||||
* @param inputString The input String.
|
||||
* @return The ASCII char "Z" is represented as "IC" in trytes.
|
||||
*/
|
||||
public static String toTrytes(String inputString) {
|
||||
|
||||
@@ -131,7 +131,7 @@ public class IotaAPITest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetTransfers() throws InvalidBundleException, ArgumentException, InvalidSignatureException, NoInclusionStatesExcpection, NoNodeInfoException, InvalidSecurityLevelException, InvalidAddressException {
|
||||
public void shouldGetTransfers() throws InvalidBundleException, ArgumentException, InvalidSignatureException, NoInclusionStatesException, NoNodeInfoException, InvalidSecurityLevelException, InvalidAddressException {
|
||||
GetTransferResponse gtr = iotaClient.getTransfers(TEST_SEED1, 2, 0, 0, false);
|
||||
assertThat(gtr.getTransfers(), IsNull.notNullValue());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user