g
+ * {@code curl http://localhost:14265 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json'}
+ * {@code -d '{"command": "GetNodeAPIConfiguration"}'}
+ */
+ @Headers({CONTENT_TYPE_HEADER, USER_AGENT_HEADER})
+ @POST("./")
+ Call
diff --git a/jota/src/main/java/org/iota/jota/dto/request/IotaCommandRequest.java b/jota/src/main/java/org/iota/jota/dto/request/IotaCommandRequest.java
index 8b60ae1c..698dfd46 100644
--- a/jota/src/main/java/org/iota/jota/dto/request/IotaCommandRequest.java
+++ b/jota/src/main/java/org/iota/jota/dto/request/IotaCommandRequest.java
@@ -34,6 +34,15 @@ protected IotaCommandRequest(String command) {
public static IotaCommandRequest createNodeInfoRequest() {
return new IotaCommandRequest(IotaAPICommand.GET_NODE_INFO);
}
+
+ /**
+ * Get information about the API configuration.
+ *
+ * @return THe node API configuration
+ */
+ public static IotaCommandRequest createGetNodeAPIConfiguration() {
+ return new IotaCommandRequest(IotaAPICommand.GET_NODE_API_CONFIGURATION);
+ }
/**
* Gets the tips of the node.
diff --git a/jota/src/main/java/org/iota/jota/dto/response/GetNewAddressResponse.java b/jota/src/main/java/org/iota/jota/dto/response/GetNewAddressResponse.java
index ad909586..ff558d9b 100644
--- a/jota/src/main/java/org/iota/jota/dto/response/GetNewAddressResponse.java
+++ b/jota/src/main/java/org/iota/jota/dto/response/GetNewAddressResponse.java
@@ -32,10 +32,10 @@ public Listnull
if there is none
* @return The address
*/
public String first() {
- return addresses.get(0);
+ return addresses.size() > 0 ? addresses.get(0) : null;
}
}
diff --git a/jota/src/main/java/org/iota/jota/dto/response/GetNodeAPIConfigurationResponse.java b/jota/src/main/java/org/iota/jota/dto/response/GetNodeAPIConfigurationResponse.java
new file mode 100644
index 00000000..3cce67b3
--- /dev/null
+++ b/jota/src/main/java/org/iota/jota/dto/response/GetNodeAPIConfigurationResponse.java
@@ -0,0 +1,90 @@
+package org.iota.jota.dto.response;
+
+/**
+ * Contains information about the result of a successful {@link com.iota.iri.service.API#getNodeAPIConfigurationStatement()} API call.
+ * Response of api request 'GetNodeAPIConfiguration'.
+ */
+public class GetNodeAPIConfigurationResponse extends AbstractResponse {
+ private int maxFindTransactions;
+ private int maxRequestsList;
+ private int maxGetTrytes;
+ private int maxBodyLength;
+ private boolean testNet;
+ private int milestoneStartIndex;
+
+ /**
+ * Initializes a new instance of the GetBundleResponse class.
+ */
+ public static AbstractResponse create(int maxFindTransactions, int maxRequestsList, int maxGetTrytes, int maxBodyLength, boolean testNet, int milestoneStartIndex) {
+ final GetNodeAPIConfigurationResponse res = new GetNodeAPIConfigurationResponse();
+
+ res.maxFindTransactions = maxFindTransactions;
+ res.maxRequestsList = maxRequestsList;
+ res.maxGetTrytes = maxGetTrytes;
+ res.maxBodyLength = maxBodyLength;
+ res.testNet = testNet;
+ res.milestoneStartIndex = milestoneStartIndex;
+
+ return res;
+ }
+
+ /**
+ * The maximal number of transactions that may be returned by the "findTransactions" API call.
+ * If the number of transactions found exceeds this number an error will be returned.
+ *
+ * @return The maximum number of transactions returned
+ * */
+ public int getMaxFindTransactions() {
+ return maxFindTransactions;
+ }
+
+ /**
+ * The maximal number of parameters one can place in an API call.
+ * If the number parameters exceeds this number an error will be returned.
+ *
+ * @return The maximum number of request parameters
+ */
+ public int getMaxRequestsList() {
+ return maxRequestsList;
+ }
+
+ /**
+ * The maximal number of trytes that may be returned by the "getTrytes" API call.
+ * If the number of transactions found exceeds this number an error will be returned.
+ *
+ * @return The maximum number of trytes returned
+ */
+ public int getMaxGetTrytes() {
+ return maxGetTrytes;
+ }
+
+ /**
+ * The maximal number of characters the body of an API call may hold.
+ * If a request body length exceeds this number an error will be returned.
+ *
+ * @return The maximum length of the request body
+ */
+ public int getMaxBodyLength() {
+ return maxBodyLength;
+ }
+
+ /**
+ * If this node has started in testnet mode.
+ *
+ * @return true
if it is, otherwise false
+ */
+ public boolean isTestNet() {
+ return testNet;
+ }
+
+ /**
+ * The start index of the milestones.
+ * This index is encoded in each milestone transaction by the coordinator.
+ * Usually the last global snapshot, with local snapshots it is the last/oldest local snapshot milestone
+ *
+ * @return The starting milestone index
+ */
+ public int getMilestoneStartIndex() {
+ return milestoneStartIndex;
+ }
+}
diff --git a/jota/src/main/java/org/iota/jota/model/Bundle.java b/jota/src/main/java/org/iota/jota/model/Bundle.java
index 1fa00d1b..45933ec3 100644
--- a/jota/src/main/java/org/iota/jota/model/Bundle.java
+++ b/jota/src/main/java/org/iota/jota/model/Bundle.java
@@ -1,5 +1,8 @@
package org.iota.jota.model;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@@ -8,9 +11,7 @@
import org.iota.jota.utils.Constants;
import org.iota.jota.utils.Converter;
import org.iota.jota.utils.Signing;
-
-import java.util.ArrayList;
-import java.util.List;
+import org.iota.jota.utils.TrytesConverter;
/**
@@ -94,6 +95,20 @@ public String getBundleHash() {
}
+ public String getMessage() {
+ StringBuilder str = new StringBuilder();
+
+ for (Transaction t : getTransactions()) {
+ if (t.getValue() == 0) {
+ str.append(t.getSignatureFragments());
+ }
+ }
+ if (str.length() % 2 != 0) {
+ str.deleteCharAt(str.length() - 1);
+ }
+ return TrytesConverter.trytesToAscii(str.toString());
+ }
+
public void addTransaction(Transaction transaction) {
if (getTransactions() == null) {
transactions = new ArrayList<>(getTransactions());
diff --git a/jota/src/main/java/org/iota/jota/store/FlatFileStore.java b/jota/src/main/java/org/iota/jota/store/FlatFileStore.java
index 550e3d0b..93b1d6be 100644
--- a/jota/src/main/java/org/iota/jota/store/FlatFileStore.java
+++ b/jota/src/main/java/org/iota/jota/store/FlatFileStore.java
@@ -147,7 +147,7 @@ public boolean canWrite() {
@Override
public String toString() {
- return file.getName();
+ return "FlatFileStore: [" + (file != null ? file.getName() : inputStream.toString()) + "]";
}
@Override
diff --git a/jota/src/main/java/org/iota/jota/store/MemoryStore.java b/jota/src/main/java/org/iota/jota/store/MemoryStore.java
index 5d740ffd..7952dc1f 100644
--- a/jota/src/main/java/org/iota/jota/store/MemoryStore.java
+++ b/jota/src/main/java/org/iota/jota/store/MemoryStore.java
@@ -18,7 +18,8 @@ public MemoryStore() {
}
public MemoryStore(Maptrue
if the specified trytes are trytes otherwise, false
.
**/
public static boolean isTrytesOfExactLength(String trytes, int length) {
- return trytes.matches("^[A-Z9]{" + (length == 0 ? "0," : length) + "}$");
+ return trytes.matches("^[A-Z9]{" + (length == 0 ? "0," : length + ",") + "}$");
}
/**
@@ -158,7 +158,7 @@ public static boolean isTrytes(String trytes, int length) {
* @return true
if the specified string consist only of '9'; otherwise, false
.
**/
public static boolean isNinesTrytes(String trytes, int length) {
- return trytes.matches("^[9]{" + (length == 0 ? "0," : length) + "}$");
+ return trytes.matches("^[9]{" + (length == 0 ? "0," : length + ",") + "}$");
}
/**
diff --git a/jota/src/test/java/org/iota/jota/IotaAccountIntegrationTest.java b/jota/src/test/java/org/iota/jota/IotaAccountIntegrationTest.java
index 5d4eca96..67194c4a 100644
--- a/jota/src/test/java/org/iota/jota/IotaAccountIntegrationTest.java
+++ b/jota/src/test/java/org/iota/jota/IotaAccountIntegrationTest.java
@@ -1,5 +1,14 @@
package org.iota.jota;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import java.util.concurrent.ExecutionException;
+
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.iota.jota.account.deposits.ConditionalDepositAddress;
@@ -18,14 +27,6 @@
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.jupiter.api.Assertions.*;
-import static org.mockito.Mockito.when;
-
public class IotaAccountIntegrationTest {
private static String lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc lorem lorem, tristique vel pharetra in, consectetur sed ex. Maecenas sit amet porttitor mauris, in ullamcorper augue. Etiam pellentesque in velit ut pellentesque. Cras dignissim quam ut imperdiet pellentesque. Proin ac ullamcorper mi. Integer suscipit sagittis augue, quis elementum dui venenatis ut. Phasellus id elit malesuada, convallis libero eget, fringilla sem. In tincidunt semper massa, nec dictum velit hendrerit et. Maecenas venenatis, felis ut eleifend elementum, enim mauris pulvinar mi, mattis posuere dolor nunc quis metus.\n" +
@@ -34,7 +35,8 @@ public class IotaAccountIntegrationTest {
"Interdum et malesuada fames ac ante ipsum primis in faucibus. Aliquam condimentum sapien ac lacinia varius. Proin sollicitudin sem ligula. Morbi suscipit maximus lorem ut aliquet. Vestibulum at feugiat orci. Maecenas condimentum vitae est vitae pretium. Etiam nec metus ut purus ullamcorper sodales at nec quam. Proin eleifend ante felis, et molestie mauris tincidunt ut. Fusce sit amet est tempus, luctus risus ac, imperdiet mi. Aliquam hendrerit leo orci. Mauris sed nisi ut mauris iaculis condimentum vitae fringilla libero. Praesent egestas ultricies nisl, interdum vehicula ipsum lobortis et. Praesent vitae pulvinar lacus, sed vestibulum dui. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec accumsan fermentum euismod.\n" +
"Morbi auctor massa et sem vulputate feugiat. In hac habitasse platea dictumst. Integer ullamcorper ipsum nec orci ultrices consectetur. Nullam id placerat odio, et eleifend lacus. Phasellus id mi ornare, blandit massa sit amet, rhoncus leo. Vestibulum pharetra bibendum lorem, quis efficitur odio consectetur sit amet. Nunc leo diam, interdum ac magna id, ornare porta nunc. Morbi lectus nibh, rutrum in rutrum sit amet, fermentum ut risus. Mauris tempor eget tortor ac iaculis. Suspendisse laoreet ullamcorper turpis, a rutrum diam ornare quis. Proin ac diam sodales risus volutpat pulvinar. Vestibulum scelerisque lorem ac leo auctor, sit amet fringilla dolor viverra. Fusce vel pretium magna. Etiam id dui fermentum, tristique arcu sed, finibus nisi.";
-
+ private static int MWM = 9;
+
private static final String TEST_SEED = "IJEEPFTJEFGFRDTSQGLGEAUZPUJFP9LDMDOOYUNOZFJ9JMJFALJATJGHEUPHHFVTFDYSGZNKMRK9EQKWG";
private static final String TEST_SEED_ID = "J9SPZIPMIHEGZEBNDLMBTVVTCGQREQXZFXUYTJTYVQCR9TUZWZDBSJBOZLTTLJYXCGGVAIEQFPWLNUGHD";
private static final String ADDR_1_SEC_3 = "TAKWNELREDNHLFYCQ9LMGZVYGTPTABFDEPQZILJAYAZSSCPXMEGCVAH9AHTJRDPVDCGIH9APCWG9KBSGA9VKXRLMU9";
@@ -67,7 +69,7 @@ void load() {
store = new AccountFileStore(file);
IotaAccount account = new IotaAccount.Builder(TEST_SEED)
.securityLevel(3)
- .mwm(9)
+ .mwm(MWM)
.store(store)
.api(iotaAPI)
.build();
@@ -85,7 +87,7 @@ void sendZeroValueTest() throws AccountError, InterruptedException, ExecutionExc
JsonFlatFileStore json = new JsonFlatFileStore(this.getClass().getResourceAsStream("/accounts/client-test.store"), new NullOutputStream());
store = new AccountFileStore(json);
- IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(9).store(store).api(iotaAPI).build();
+ IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(MWM).store(store).api(iotaAPI).build();
Bundle sent = account.sendZeroValue("Another IOTA Accounts test run at " + new Date().toString(),
"IOTA9ACCOUNTS",
@@ -100,7 +102,7 @@ void sendLongZeroMessage() throws ArgumentException, SendException, InterruptedE
JsonFlatFileStore json = new JsonFlatFileStore(this.getClass().getResourceAsStream("/accounts/client-test.store"), new NullOutputStream());
store = new AccountFileStore(json);
- IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(9).store(store).api(iotaAPI).build();
+ IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(MWM).store(store).api(iotaAPI).build();
Bundle sent = account.sendZeroValue(lorem, "IOTA9ACCOUNTS",
account.getAccountManager().getNextAddress().getAddress().getHashCheckSum()).get();
@@ -115,7 +117,7 @@ void sendValueTest() throws AccountError, InterruptedException, ExecutionExcepti
JsonFlatFileStore json = new JsonFlatFileStore(this.getClass().getResourceAsStream("/accounts/client-test.store"), new NullOutputStream());
store = new AccountFileStore(json);
- IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(9).store(store).api(iotaAPI).build();
+ IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(MWM).store(store).api(iotaAPI).build();
Date timeOut = new Date(Long.MAX_VALUE);
ConditionalDepositAddress cda = account.newDepositAddress(timeOut, false, 10).get();
@@ -134,7 +136,7 @@ void sendLongValueTest() throws AccountError, InterruptedException, ExecutionExc
JsonFlatFileStore json = new JsonFlatFileStore(this.getClass().getResourceAsStream("/accounts/client-test.store"), new NullOutputStream());
store = new AccountFileStore(json);
- IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(9).store(store).api(iotaAPI).build();
+ IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(MWM).store(store).api(iotaAPI).build();
Date timeOut = new Date(Long.MAX_VALUE);
ConditionalDepositAddress cda = account.newDepositAddress(timeOut, false, 10).get();
@@ -153,7 +155,7 @@ void sendLongMultiValueTest() throws AccountError, InterruptedException, Executi
JsonFlatFileStore json = new JsonFlatFileStore(this.getClass().getResourceAsStream("/accounts/client-testMulti.store"), new NullOutputStream());
store = new AccountFileStore(json);
- IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(9).store(store).api(iotaAPI).build();
+ IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(MWM).store(store).api(iotaAPI).build();
Date timeOut = new Date(Long.MAX_VALUE);
ConditionalDepositAddress cda = account.newDepositAddress(timeOut, false, 10).get();
@@ -172,7 +174,7 @@ void sendLongMultiValueRemainderTest() throws AccountError, InterruptedException
JsonFlatFileStore json = new JsonFlatFileStore(this.getClass().getResourceAsStream("/accounts/client-testMulti.store"), new NullOutputStream());
store = new AccountFileStore(json);
- IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(9).store(store).api(iotaAPI).build();
+ IotaAccount account = new IotaAccount.Builder(TEST_SEED).mwm(MWM).store(store).api(iotaAPI).build();
Date timeOut = new Date(Long.MAX_VALUE);
ConditionalDepositAddress cda = account.newDepositAddress(timeOut, false, 10).get();
diff --git a/jota/src/test/java/org/iota/jota/account/deposits/methods/MagnetTest.java b/jota/src/test/java/org/iota/jota/account/deposits/methods/MagnetTest.java
index d92efb2f..90e97c03 100644
--- a/jota/src/test/java/org/iota/jota/account/deposits/methods/MagnetTest.java
+++ b/jota/src/test/java/org/iota/jota/account/deposits/methods/MagnetTest.java
@@ -1,5 +1,10 @@
package org.iota.jota.account.deposits.methods;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.util.Date;
+
import org.iota.jota.account.deposits.ConditionalDepositAddress;
import org.iota.jota.account.deposits.DepositRequest;
import org.iota.jota.account.deposits.DepositTest;
@@ -7,18 +12,13 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import java.util.Date;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
public class MagnetTest extends DepositTest {
private static final long TIME = 0;
private static final boolean MULTI = false;
private static final long AMOUNT = 5;
- private static final String MAGNET_CHECKSUM = "QC9AIWMMD";
+ private static final String MAGNET_CHECKSUM = "UDJPO99SI";
private static final String MAGNET = "iota://" + DepositTest.depositAddress.getHash() + MAGNET_CHECKSUM + "/?"
+ MagnetMethod.CONDITION_EXPIRES + "=" + TIME + "&"
@@ -43,6 +43,17 @@ public void buildMagnet() {
assertEquals(MagnetTest.MAGNET, magnet);
}
+
+ @Test
+ public void readGoMagnet() {
+ // GO and JS allow 1 instead of true
+ String magnet = "iota://BWNYWGULIIAVRYOOFWZTSDFXFPRCFF9YEHGVBOORLGCPCJSKTHU9OKESUGZGWZXZZDLESFPPTGEHVKTTXG9BQLSIGP/?timeout_at=5174418337&multi_use=1&expected_amount=0";
+ ConditionalDepositAddress cda = DepositFactory.get().parse(magnet, MagnetMethod.class);
+
+ assertEquals(cda.getRequest().getTimeOut().getTime(), 5174418337l);
+ assertEquals(cda.getRequest().getExpectedAmount(), 0);
+ assertEquals(cda.getRequest().getMultiUse(), true);
+ }
@Test
public void readMagnet() {
diff --git a/jota/src/test/java/org/iota/jota/account/store/MongoDBStoreTest.java b/jota/src/test/java/org/iota/jota/account/store/MongoDBStoreTest.java
index 45b73ad5..87ecddb5 100644
--- a/jota/src/test/java/org/iota/jota/account/store/MongoDBStoreTest.java
+++ b/jota/src/test/java/org/iota/jota/account/store/MongoDBStoreTest.java
@@ -1,5 +1,8 @@
package org.iota.jota.account.store;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.util.Arrays;
import java.util.Date;
import java.util.Map;
@@ -18,9 +21,6 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
-
@Disabled
public class MongoDBStoreTest {
@@ -29,10 +29,11 @@ public class MongoDBStoreTest {
@BeforeEach
public void setUp() {
+ int PORT = 12345;
// Want to run this test? Update it with your mongodb details locally for now
- this.store = new MongoStore("databasename", IotaDefaultConfig.Defaults.TABLE_NAME,
- "url", 1337);
- //store.addCredentials("username", "password");
+ this.store = new MongoStore("database", IotaDefaultConfig.Defaults.TABLE_NAME,
+ "url", PORT);
+ store.addCredentials("user", "pass");
}
@AfterEach
@@ -41,7 +42,6 @@ public void tearDown() throws Exception {
store.shutdown();
}
- @Disabled
@Test
public void testConnection() {
try {
@@ -51,7 +51,6 @@ public void testConnection() {
}
}
- @Disabled
@Test
public void depositRequestTest() throws Exception{
store.start();
diff --git a/jota/src/test/java/org/iota/jota/config/FileConfigTest.java b/jota/src/test/java/org/iota/jota/config/FileConfigTest.java
index 37e067ab..e10e6fba 100644
--- a/jota/src/test/java/org/iota/jota/config/FileConfigTest.java
+++ b/jota/src/test/java/org/iota/jota/config/FileConfigTest.java
@@ -25,7 +25,7 @@ public void testNewConfig() throws Exception {
FileConfig config = new FileConfig(store);
assertEquals(500, config.getConnectionTimeout());
- assertEquals("client_new.store", config.getStore().toString());
+ assertEquals("FlatFileStore: [client_new.store]", config.getStore().toString());
assertEquals(15, config.getMwm());
assertEquals(5, config.getDepth());
assertEquals(3, config.getSecurityLevel());
diff --git a/pom.xml b/pom.xml
index 389947ce..6c3b99d6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@