public class IotaAPI extends IotaAPICore
IotaAPI api = new IotaAPI.Builder()
.protocol("http")
.nodeAddress("localhost")
.port(12345)
.build();
GetNodeInfoResponse response = api.getNodeInfo();
| Modifier and Type | Class and Description |
|---|---|
static class |
IotaAPI.Builder |
nodes| Modifier | Constructor and Description |
|---|---|
protected |
IotaAPI(ApiOptions options) |
protected |
IotaAPI(IotaAPI.Builder builder) |
| Modifier and Type | Method and Description |
|---|---|
List<String> |
addRemainder(String seed,
int security,
List<Input> inputs,
Bundle bundle,
String tag,
long totalValue,
String remainderAddress,
List<String> signatureFragments)
Uses input, and adds to the bundle, untill totalValue is reached.
|
Bundle[] |
bundlesFromAddresses(Boolean inclusionStates,
String... addresses)
Internal function to get the formatted bundles of a list of addresses.
|
boolean[] |
checkWereAddressSpentFrom(String... addresses)
Check if a list of addresses was ever spent from, in the current epoch, or in previous epochs.
|
Boolean |
checkWereAddressSpentFrom(String address)
Check if an addresses was ever spent from, in the current epoch, or in previous epochs.
|
List<Transaction> |
findTransactionObjectsByAddresses(String[] addresses)
Wrapper function: Finds transactions, gets trytes and turns it into
Transaction objects. |
List<Transaction> |
findTransactionObjectsByApprovees(String... approvees)
Wrapper function: Finds transactions, gets trytes and turns it into
Transaction objects. |
List<Transaction> |
findTransactionObjectsByBundle(String... bundles)
Wrapper function: Finds transactions, gets trytes and turns it into
Transaction objects. |
List<Transaction> |
findTransactionObjectsByTag(String... tags)
Wrapper function: Finds transactions, gets trytes and turns it into
Transaction objects. |
List<Transaction> |
findTransactionsObjectsByHashes(String... hashes)
Wrapper function: get trytes and turns into
Transaction objects. |
GetNewAddressResponse |
generateNewAddresses(AddressRequest addressRequest)
Generates new addresses, meaning addresses which were not spend from, according to the connected node.
|
GetAccountDataResponse |
getAccountData(String seed,
int security,
int index,
boolean checksum,
int total,
boolean returnAll,
int start,
int end,
boolean inclusionStates,
long threshold)
Similar to getTransfers, just that it returns additional account data
|
GetNewAddressResponse |
getAddressesUnchecked(AddressRequest addressRequest)
Generates
amount of addresses, starting from index
This does not mean that these addresses are safe to use (unspent) |
long |
getBalance(int threshold,
String address)
The returned balance is based on the latest confirmed milestone.
|
GetBalancesAndFormatResponse |
getBalanceAndFormat(List<String> addresses,
List<String> tips,
long threshold,
int start,
StopWatch stopWatch,
int security)
Gets the balances and formats the output.
|
GetBundleResponse |
getBundle(String transaction)
Gets the associated bundle transactions of a single transaction.
|
GetBalancesAndFormatResponse |
getInputs(String seed,
int security,
int start,
int end,
long threshold,
String... tips)
Gets the inputs of a seed
If start, end and threshold are 0, checks everything until an address with nothing is found.
|
GetInclusionStateResponse |
getLatestInclusion(String... hashes)
Wrapper function: runs getNodeInfo and getInclusionStates
Uses the latest milestone as tip
|
GetTransferResponse |
getTransfers(String seed,
int security,
Integer start,
Integer end,
Boolean inclusionStates)
Finds all the bundles for all the addresses based on this seed and security.
|
List<Transaction> |
initiateTransfer(int securitySum,
String inputAddress,
String remainderAddress,
List<Transfer> transfers)
Prepares transfer by generating the bundle with the corresponding cosigner transactions.
|
List<Transaction> |
initiateTransfer(int securitySum,
String inputAddress,
String remainderAddress,
List<Transfer> transfers,
boolean testMode)
Prepares transfer by generating the bundle with the corresponding cosigner transactions.
|
List<Transaction> |
initiateTransfer(int securitySum,
String inputAddress,
String remainderAddress,
List<Transfer> transfers,
List<Transaction> tips)
Prepares transfer by generating the bundle with the corresponding cosigner transactions.
|
List<Transaction> |
initiateTransfer(int securitySum,
String inputAddress,
String remainderAddress,
List<Transfer> transfers,
List<Transaction> tips,
boolean testMode)
Prepares transfer by generating the bundle with the corresponding cosigner transactions.
|
boolean |
isPromotable(String tail)
Checks if a transaction hash is promotable
|
boolean |
isPromotable(Transaction tail)
Checks if a transaction hash is promotable
|
List<String> |
prepareTransfers(String seed,
int security,
List<Transfer> transfers,
String remainder,
List<Input> inputs,
List<Transaction> tips,
boolean validateInputs)
Prepares transfer by generating bundle, finding and signing inputs.
|
List<Transaction> |
promoteTransaction(String tail,
int depth,
int minWeightMagnitude,
Bundle bundle)
Attempts to promote a transaction using a provided bundle and, if successful, returns the promoting Transactions.
|
ReplayBundleResponse |
replayBundle(Bundle bundle,
int depth,
int minWeightMagnitude,
String reference)
Replays a transfer by doing Proof of Work again.
|
ReplayBundleResponse |
replayBundle(String tailTransactionHash,
int depth,
int minWeightMagnitude,
String reference)
Replays a transfer by doing Proof of Work again.
|
SendTransferResponse |
sendTransfer(String seed,
int security,
int depth,
int minWeightMagnitude,
List<Transfer> transfers,
List<Input> inputs,
String remainderAddress,
boolean validateInputs,
boolean validateInputAddresses,
List<Transaction> tips)
Wrapper function: Runs prepareTransfers, as well as attachToTangle.
|
List<Transaction> |
sendTrytes(String[] trytes,
int depth,
int minWeightMagnitude,
String reference)
Wrapper method: Gets transactions to approve, attaches to Tangle, broadcasts and stores.
|
BroadcastTransactionsResponse |
storeAndBroadcast(String... trytes)
Wrapper method: stores and broadcasts the specified trytes.
|
Bundle |
traverseBundle(String trunkTx,
String bundleHash,
Bundle bundle)
Traverses the Bundle by going down the trunkTransactions until the bundle hash of the transaction changes.
|
void |
validateTransfersAddresses(String seed,
int security,
List<String> trytes)
Validates the supplied transactions with seed and security.
|
addNeighbors, addNode, attachToTangle, attachToTangleLocalPow, broadcastTransactions, callIxi, checkConsistency, findTransactions, findTransactionsByAddresses, findTransactionsByApprovees, findTransactionsByBundles, findTransactionsByDigests, findTransactionsByTags, getBalances, getBalances, getBalances, getCurl, getHost, getInclusionStates, getLocalPoW, getNeighbors, getNodeInfo, getNodes, getPort, getProtocol, getRandomNode, getTips, getTransactionsToApprove, getTransactionsToApprove, getTrytes, hasNodes, interruptAttachingToTangle, removeNeighbors, removeNode, setCurl, setLocalPoW, storeTransactions, toString, wereAddressesSpentFromprotected IotaAPI(ApiOptions options)
protected IotaAPI(IotaAPI.Builder builder)
public GetNewAddressResponse generateNewAddresses(AddressRequest addressRequest)
AddressRequest.getAmount() of unspent addresses are found, starting from AddressRequest.getIndex()
If AddressRequest.getAmount() is set to 0, we will generate until the first unspent address is found, and stop.addressRequest - AddressRequestGetNewAddressResponsepublic GetNewAddressResponse getAddressesUnchecked(AddressRequest addressRequest) throws ArgumentException
amount of addresses, starting from index
This does not mean that these addresses are safe to use (unspent)addressRequest - AddressRequestGetNewAddressResponseArgumentException - is thrown when the specified input is not valid.public GetTransferResponse getTransfers(String seed, int security, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException
seed - Tryte-encoded seed. It should be noted that this seed is not transferred.security - Security level to be used for the private key / address. Can be 1, 2 or 3.start - Starting key index, must be at least 0.end - Ending key index, must be bigger then startinclusionStates - If true, it also gets the inclusion states of the transfers.GetTransferResponseArgumentException - when start and end are more then 500 apartArgumentException - Invalid security indexIllegalStateException - When the seed is invalidpublic Bundle[] bundlesFromAddresses(Boolean inclusionStates, String... addresses) throws ArgumentException
addresses - If true, it also gets the inclusion state of each bundle.inclusionStates - Array of addresses.null when our thread gets interruptedArgumentException - When the addresses are invalidIllegalStateException - When inclusion state/confirmed could not be determined (null returned)public BroadcastTransactionsResponse storeAndBroadcast(String... trytes) throws ArgumentException
trytes - The trytes.BroadcastTransactionsResponseArgumentException - is thrown when the specified trytes is not valid.ArgumentException - If IotaAPICore.storeTransactions(String...) failsIotaAPICore.storeTransactions(String...),
IotaAPICore.broadcastTransactions(String...)public List<Transaction> sendTrytes(String[] trytes, int depth, int minWeightMagnitude, String reference) throws ArgumentException
trytes - The transaction trytesdepth - The depth for getting transactions to approveminWeightMagnitude - The minimum weight magnitude for doing proof of workreference - Hash of transaction to start random-walk from
This is used to make sure the tips returned reference a given transaction in their past.
This can be null, in that case the latest milestone is used as a reference.Transaction objects.ArgumentException - is thrown when invalid trytes is provided.IotaAPICore.broadcastTransactions(String...),
IotaAPICore.attachToTangle(String, String, Integer, String...),
storeAndBroadcast(String...)public List<Transaction> findTransactionsObjectsByHashes(String... hashes) throws ArgumentException
Transaction objects.
Gets the trytes and transaction object from a list of transaction hashes.hashes - The hashes of the transactions we want to get the transactions fromTransaction objects.ArgumentException - if hashes is not a valid array of hashesIotaAPICore.getTrytes(String...)public List<Transaction> findTransactionObjectsByAddresses(String[] addresses) throws ArgumentException
Transaction objects.addresses - The addresses we should get the transactions for, must contain checksumsTransaction objects.ArgumentException - if addresses is not a valid array of hashesIotaAPICore.findTransactionsByAddresses(String...),
findTransactionsObjectsByHashes(java.lang.String...)public List<Transaction> findTransactionObjectsByTag(String... tags) throws ArgumentException
Transaction objects.tags - The tags the transactions we search for haveTransaction objects.ArgumentException - if any of the tags are not a validIotaAPICore.findTransactionsByTags(String...),
findTransactionsObjectsByHashes(java.lang.String...)public List<Transaction> findTransactionObjectsByApprovees(String... approvees) throws ArgumentException
Transaction objects.approvees - The transaction hashes of which we want to approversTransaction objects.ArgumentException - if addresses is not a valid array of hashesIotaAPICore.findTransactionsByApprovees(java.lang.String...)public List<Transaction> findTransactionObjectsByBundle(String... bundles) throws ArgumentException
Transaction objects.bundles - The bundles for which we will get all its transactionsTransaction objects.ArgumentException - if addresses is not a valid array of hashesIotaAPICore.findTransactionsByBundles(java.lang.String...)public List<String> prepareTransfers(String seed, int security, List<Transfer> transfers, String remainder, List<Input> inputs, List<Transaction> tips, boolean validateInputs) throws ArgumentException
seed - The tryte-encoded seed. It should be noted that this seed is not transferred.
Only required when we are preparing a value transfersecurity - Security level to be used for the private key / address. Can be 1, 2 or 3.transfers - List of transfer objects.
If the total value of the transfers is 0, no signing is performed.remainder - If defined, this address will be used for sending the remainder value (of the inputs) to.
Otherwise, then next available address is used (if the transfer value is over 0)inputs - The inputs used for this transfertips - The starting points we walk back from to find the balance of the addresses, can be nullvalidateInputs - Whether or not to validate the balances of the provided inputs
If no validation is requiredArgumentException - If the seed is invalidArgumentException - If the security level is wrong.IllegalStateException - If the transfers are not all validIllegalStateException - If there is not enough balance in the inputspublic GetBalancesAndFormatResponse getInputs(String seed, int security, int start, int end, long threshold, String... tips) throws ArgumentException
seed - Tryte-encoded seed. It should be noted that this seed is not transferred.security - Security level to be used for the private key / address. Can be 1, 2 or 3.start - Starting key index, must be at least 0.end - Ending key index, must be bigger then start, and cant span more than 500 indexesthreshold - Minimum balance required.tips - The starting points we walk back from to find the balance of the addresses, can be nullGetBalancesAndFormatResponseArgumentException - If the seed is invalidArgumentException - If the security level is wrong.ArgumentException - when start and end are more then 500 apartgetBalanceAndFormat(List, List, long, int, StopWatch, int)public long getBalance(int threshold,
String address)
throws ArgumentException
The returned balance is based on the latest confirmed milestone. In addition to the balances, it also returns the referencing tips (or milestone), as well as the index with which the confirmed balance was determined. The balances are returned as a list in the same order as the addresses were provided as input.
threshold - The confirmation threshold between 0 and 100(inclusive).
Should be set to 100 for getting balance by counting only confirmed transactions.address - The addresses where we will find the balance for.GetBalancesResponseArgumentException - The the request was considered wrong in any way by the nodepublic GetBalancesAndFormatResponse getBalanceAndFormat(List<String> addresses, List<String> tips, long threshold, int start, StopWatch stopWatch, int security) throws ArgumentException, IllegalStateException
addresses - The addresses.tips - The starting points we walk back from to find the balance of the addresses, can be nullthreshold - Min balance required.start - Starting key index.stopWatch - the stopwatch. If you pass null, a new one is created.security - Security level to be used for the private key / address. Can be 1, 2 or 3.GetBalancesAndFormatResponseArgumentException - is thrown when the specified security level is not valid.IllegalStateException - when there is not enough balance on the addressespublic GetBundleResponse getBundle(String transaction) throws ArgumentException
transaction - The transaction hashGetBundleResponseArgumentException - if the transaction hash is invalidArgumentException - if the bundle is invalid or not foundpublic GetAccountDataResponse getAccountData(String seed, int security, int index, boolean checksum, int total, boolean returnAll, int start, int end, boolean inclusionStates, long threshold) throws ArgumentException
seed - Tryte-encoded seed. It should be noted that this seed is not transferred.security - Security level to be used for the private key / address. Can be 1, 2 or 3.index - Key index to start search from. If the index is provided, the generation of the address is not deterministic.checksum - Adds 9-tryte address checksum. Checksum is required for all API calls.total - Total number of addresses to generate.returnAll - If true, it returns all addresses which were deterministically generated (until findTransactions returns null).start - Starting key index, must be at least 0.end - Ending key index, must be bigger then startinclusionStates - If true, it gets the inclusion states of the transfers.threshold - Minimum balance required.GetAccountDataResponseArgumentException - when the specified security level is not valid.ArgumentException - when start and end are invalidgetTransfers(String, int, Integer, Integer, Boolean)public boolean[] checkWereAddressSpentFrom(String... addresses) throws ArgumentException
addresses - the addresses to checkArgumentException - when an address is invalidpublic Boolean checkWereAddressSpentFrom(String address) throws ArgumentException
address - the address to checkArgumentException - when the address is invalidpublic ReplayBundleResponse replayBundle(String tailTransactionHash, int depth, int minWeightMagnitude, String reference) throws ArgumentException
tailTransactionHash - The hash of tail transaction.depth - The depth for getting transactions to approveminWeightMagnitude - The minimum weight magnitude for doing proof of workreference - Hash of transaction to start random-walk from.
This is used to make sure the tips returned reference a given transaction in their past.
Can be null, in that case the latest milestone is used as a reference.ReplayBundleResponseArgumentException - when the tailTransactionHash is invalidArgumentException - when the bundle is invalid or not foundsendTrytes(String[], int, int, String)public ReplayBundleResponse replayBundle(Bundle bundle, int depth, int minWeightMagnitude, String reference) throws ArgumentException
bundle - The bundle we wish to replay on the networkdepth - The depth for getting transactions to approveminWeightMagnitude - The minimum weight magnitude for doing proof of workreference - Hash of transaction to start random-walk from.
This is used to make sure the tips returned reference a given transaction in their past.
Can be null, in that case the latest milestone is used as a reference.ReplayBundleResponseArgumentException - when the tailTransactionHash is invalidArgumentException - when the bundle is invalid or not foundsendTrytes(String[], int, int, String)public GetInclusionStateResponse getLatestInclusion(String... hashes) throws ArgumentException
hashes - The hashes.GetInclusionStateResponseArgumentException - when one of the hashes is invalidIotaAPICore.getNodeInfo(),
IotaAPICore.getInclusionStates(String[], String[])public SendTransferResponse sendTransfer(String seed, int security, int depth, int minWeightMagnitude, List<Transfer> transfers, List<Input> inputs, String remainderAddress, boolean validateInputs, boolean validateInputAddresses, List<Transaction> tips) throws ArgumentException
seed - The tryte-encoded seed. It should be noted that this seed is not transferred.security - Security level to be used for the private key / address. Can be 1, 2 or 3.depth - The depth for getting transactions to approveminWeightMagnitude - The minimum weight magnitude for doing proof of worktransfers - List of Transfer objects.inputs - List of Input used for funding the transfer.remainderAddress - If defined, this remainderAddress will be used for sending the remainder value (of the inputs) to.
When this is not defined, but a remaining exists, the next free address is used.validateInputs - Whether or not to validate the balances of the provided inputs.validateInputAddresses - Whether or not to validate if the destination address is already use.
If a key reuse is detect or it's send to inputs.tips - The starting points we walk back from to find the balance of the addresses
If multiple tips are supplied, only the first tip is used for IotaAPICore.getTransactionsToApprove(Integer, String)SendTransferResponseArgumentException - If the seed is invalidArgumentException - If the security level is wrong.ArgumentException - When validateInputAddresses is true, if validateTransfersAddresses has an error.IllegalStateException - If the transfers are not all validIllegalStateException - If there is not enough balance in the inputs to supply to the transfersprepareTransfers(String, int, List, String, List, List, boolean),
sendTrytes(String[], int, int, String),
validateTransfersAddresses(String, int, List)public Bundle traverseBundle(String trunkTx, String bundleHash, Bundle bundle) throws ArgumentException
trunkTx - Hash of a trunk or a tail transaction of a bundle.bundleHash - The bundle hash. Should be null, and will use the transactions bundle hashbundle - Bundle to be populated by traversing.ArgumentException - when trunkTx is invalid, or has no transactionsArgumentException - when a transaction in the bundle has no reference to the bundleArgumentException - when the first transaction in the bundle is not a tailpublic List<Transaction> initiateTransfer(int securitySum, String inputAddress, String remainderAddress, List<Transfer> transfers) throws ArgumentException
securitySum - The sum of security levels used by all co-signers.inputAddress - Array of input addresses as well as the securitySum.remainderAddress - Has to be generated by the cosigners before initiating the transfer, can be null if fully spent.transfers - List of Transfer we want to make using the unputAddressesTransaction objects in this newly created transferArgumentException - when an address is invalid.ArgumentException - when the security level is wrong.IllegalStateException - when a transfer fails because their is not enough balance to perform the transfer.IllegalStateException - When a remainderAddress is required, but not suppliedRuntimeException - When the total value from the transfers is not 0public List<Transaction> initiateTransfer(int securitySum, String inputAddress, String remainderAddress, List<Transfer> transfers, List<Transaction> tips) throws ArgumentException
securitySum - The sum of security levels used by all co-signers.inputAddress - Array of input addresses as well as the securitySum.remainderAddress - Has to be generated by the cosigners before initiating the transfer, can be null if fully spent.transfers - List of Transfer we want to make using the unputAddressestips - The starting points for checking if the balances of the input addresses contain enough to make this transfer
This can be nullTransaction objects in this newly created transferArgumentException - when an address is invalid.ArgumentException - when the security level is wrong.IllegalStateException - when a transfer fails because their is not enough balance to perform the transfer.IllegalStateException - When a remainderAddress is required, but not suppliedRuntimeException - When the total value from the transfers is not 0public List<Transaction> initiateTransfer(int securitySum, String inputAddress, String remainderAddress, List<Transfer> transfers, boolean testMode) throws ArgumentException
securitySum - The sum of security levels used by all co-signers.inputAddress - Array of input addresses as well as the securitySum.remainderAddress - Has to be generated by the cosigners before initiating the transfer, can be null if fully spent.transfers - List of Transfer we want to make using the unputAddressestestMode - If were running unit tests, set to true to bypass total value checkTransaction objects in this newly created transferArgumentException - when an address is invalid.ArgumentException - when the security level is wrong.IllegalStateException - when a transfer fails because their is not enough balance to perform the transfer.IllegalStateException - When a remainderAddress is required, but not suppliedRuntimeException - When the total value from the transfers is not 0public List<Transaction> initiateTransfer(int securitySum, String inputAddress, String remainderAddress, List<Transfer> transfers, List<Transaction> tips, boolean testMode) throws ArgumentException
securitySum - The sum of security levels used by all co-signers.inputAddress - Input address with checksumremainderAddress - Has to be generated by the cosigners before initiating the transfer, can be null if fully spent.transfers - List of Transfer we want to make using the inputAddresstips - The starting points for checking if the balance of the input address contains enough to make this transfer.
This can be nulltestMode - If were running unit tests, set to true to bypass total value checkTransaction objects in this newly created transferArgumentException - when an address is invalid.ArgumentException - when the security level is wrong.IllegalStateException - when a transfer fails because their is not enough balance to perform the transfer.IllegalStateException - When a remainderAddress is required, but not suppliedRuntimeException - When the total value from the transfers is not 0public void validateTransfersAddresses(String seed, int security, List<String> trytes) throws ArgumentException
Validates the supplied transactions with seed and security. This will check for correct input/output and key reuse
In order to do this we will generate all addresses for this seed which are currently in use. Address checksums will be regenerated and these addresses will be looked up, making this an expensive method call.
If no error is thrown, the transaction trytes are using correct addresses. This will not validate transaction fields.seed - The tryte-encoded seed. It should be noted that this seed is not transferred.security - Security level to be used for the private key / address. Can be 1, 2 or 3.trytes - List of transaction trytes.ArgumentException - when we are sending to our own input addressesArgumentException - when we try to remove funds from an address that is not an inputArgumentException - when we are sending from an address we have already used for sendingpublic List<String> addRemainder(String seed, int security, List<Input> inputs, Bundle bundle, String tag, long totalValue, String remainderAddress, List<String> signatureFragments) throws ArgumentException
seed - The tryte-encoded seed. It should be noted that this seed is not transferred.security - Security level to be used for the private key / address. Can be 1, 2 or 3.inputs - List of inputs used for funding the transfer.bundle - The Bundle to be populated.tag - The tag to add to each bundle entry (input and remainder)totalValue - The total value of the desired transactionremainderAddress - The address used for sending the remainder value (of the last input).
If this is null, generateNewAddresses(AddressRequest) is used.signatureFragments - The signature fragments (message), used for signing.
Should be 2187 characters long, can be padded with 9s.ArgumentException - When the seed is invalidArgumentException - When the security level is wrong.IllegalStateException - When the inputs do not contain enough balance to reach totalValue.IotaAPIUtils.signInputsAndReturn(String, List, Bundle, List, org.iota.jota.pow.ICurl),
generateNewAddresses(AddressRequest)public boolean isPromotable(Transaction tail) throws ArgumentException
tail - the Transaction we want to promoteArgumentException - when we can't get the consistency of this transactionIotaAPICore.checkConsistency(String...)public boolean isPromotable(String tail) throws ArgumentException
tail - the Transaction hash we want to checkArgumentException - when we can't get the consistency of this transaction
or when the transaction is not foundIotaAPICore.checkConsistency(String...)public List<Transaction> promoteTransaction(String tail, int depth, int minWeightMagnitude, Bundle bundle) throws BaseException
tail - bundle tail to promote, cannot be nulldepth - depth for getTransactionsToApproveminWeightMagnitude - minWeightMagnitude to use for Proof-of-Workbundle - the Bundle to attach for promotionTransactions made with the attached transaction trytesArgumentException - When the bundle has no transactionArgumentException - When depth or minWeightMagnitude is lower than 0ArgumentException - When the tail hash is invalidNotPromotableException - When the transaction is not promotableBaseExceptionIotaAPICore.checkConsistency(String...),
IotaAPICore.getTransactionsToApprove(Integer, String),
IotaAPICore.attachToTangle(String, String, Integer, String...),
storeAndBroadcast(String...)Copyright © 2019. All rights reserved.