Skip to content

Commit d2b33f7

Browse files
committed
refactored
1 parent 3650407 commit d2b33f7

10 files changed

Lines changed: 158 additions & 173 deletions

‎dependency-reduced-pom.xml‎

Lines changed: 131 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,136 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
<groupId>org.iota</groupId>
5-
<artifactId>jota</artifactId>
6-
<name>JOTA</name>
7-
<version>0.9.2</version>
8-
<description>JOTA library is a simple Java wrapper around IOTA Node's JSON-REST HTTP interface.</description>
9-
<licenses>
10-
<license>
11-
<name>Apache License, Version 2.0</name>
12-
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
13-
<distribution>repo</distribution>
14-
</license>
15-
</licenses>
16-
<build>
17-
<plugins>
18-
<plugin>
19-
<artifactId>maven-compiler-plugin</artifactId>
20-
<version>3.3</version>
21-
<configuration>
22-
<source>${java-version}</source>
23-
<target>${java-version}</target>
24-
<testSource>${java-version}</testSource>
25-
<testTarget>${java-version}</testTarget>
26-
</configuration>
27-
</plugin>
28-
<plugin>
29-
<artifactId>maven-shade-plugin</artifactId>
30-
<version>2.4.3</version>
31-
<executions>
32-
<execution>
33-
<phase>package</phase>
34-
<goals>
35-
<goal>shade</goal>
36-
</goals>
37-
</execution>
38-
</executions>
39-
<configuration>
40-
<filters>
41-
<filter>
42-
<artifact>*:*</artifact>
43-
<excludes>
44-
<exclude>META-INF/*.SF</exclude>
45-
<exclude>META-INF/*.DSA</exclude>
46-
<exclude>META-INF/*.RSA</exclude>
47-
</excludes>
48-
</filter>
49-
</filters>
50-
</configuration>
51-
</plugin>
52-
<plugin>
53-
<artifactId>maven-surefire-plugin</artifactId>
54-
<version>2.12.4</version>
55-
<configuration>
56-
<skipTests>${skipTests}</skipTests>
57-
</configuration>
58-
</plugin>
59-
</plugins>
60-
</build>
61-
<profiles>
62-
<profile>
63-
<id>build-extras</id>
64-
<build>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.iota</groupId>
6+
<artifactId>jota</artifactId>
7+
<name>JOTA</name>
8+
<version>0.9.2</version>
9+
<description>JOTA library is a simple Java wrapper around IOTA Node's JSON-REST HTTP interface.</description>
10+
<licenses>
11+
<license>
12+
<name>Apache License, Version 2.0</name>
13+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
14+
<distribution>repo</distribution>
15+
</license>
16+
</licenses>
17+
<build>
6518
<plugins>
66-
<plugin>
67-
<artifactId>maven-source-plugin</artifactId>
68-
<executions>
69-
<execution>
70-
<id>attach-sources</id>
71-
<goals>
72-
<goal>jar</goal>
73-
</goals>
74-
</execution>
75-
</executions>
76-
</plugin>
77-
<plugin>
78-
<artifactId>maven-javadoc-plugin</artifactId>
79-
<version>2.10.4</version>
80-
<executions>
81-
<execution>
82-
<id>attach-javadocs</id>
83-
<goals>
84-
<goal>jar</goal>
85-
</goals>
86-
</execution>
87-
</executions>
88-
<configuration>
89-
<show>private</show>
90-
<nohelp>true</nohelp>
91-
<additionalparam>-Xdoclint:none</additionalparam>
92-
</configuration>
93-
</plugin>
94-
<plugin>
95-
<artifactId>maven-gpg-plugin</artifactId>
96-
<version>1.6</version>
97-
<executions>
98-
<execution>
99-
<id>sign-artifacts</id>
100-
<phase>package</phase>
101-
<goals>
102-
<goal>sign</goal>
103-
</goals>
104-
</execution>
105-
</executions>
106-
</plugin>
19+
<plugin>
20+
<artifactId>maven-compiler-plugin</artifactId>
21+
<version>3.3</version>
22+
<configuration>
23+
<source>${java-version}</source>
24+
<target>${java-version}</target>
25+
<testSource>${java-version}</testSource>
26+
<testTarget>${java-version}</testTarget>
27+
</configuration>
28+
</plugin>
29+
<plugin>
30+
<artifactId>maven-shade-plugin</artifactId>
31+
<version>2.4.3</version>
32+
<executions>
33+
<execution>
34+
<phase>package</phase>
35+
<goals>
36+
<goal>shade</goal>
37+
</goals>
38+
</execution>
39+
</executions>
40+
<configuration>
41+
<filters>
42+
<filter>
43+
<artifact>*:*</artifact>
44+
<excludes>
45+
<exclude>META-INF/*.SF</exclude>
46+
<exclude>META-INF/*.DSA</exclude>
47+
<exclude>META-INF/*.RSA</exclude>
48+
</excludes>
49+
</filter>
50+
</filters>
51+
</configuration>
52+
</plugin>
53+
<plugin>
54+
<artifactId>maven-surefire-plugin</artifactId>
55+
<version>2.12.4</version>
56+
<configuration>
57+
<skipTests>${skipTests}</skipTests>
58+
</configuration>
59+
</plugin>
10760
</plugins>
108-
</build>
109-
<properties>
110-
<gpg.keyname>${env.GPG_KEYNAME}</gpg.keyname>
111-
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
112-
</properties>
113-
</profile>
114-
</profiles>
115-
<dependencies>
116-
<dependency>
117-
<groupId>junit</groupId>
118-
<artifactId>junit</artifactId>
119-
<version>4.12</version>
120-
<scope>test</scope>
121-
<exclusions>
122-
<exclusion>
123-
<artifactId>hamcrest-core</artifactId>
124-
<groupId>org.hamcrest</groupId>
125-
</exclusion>
126-
</exclusions>
127-
</dependency>
128-
</dependencies>
129-
<properties>
130-
<skipTests>true</skipTests>
131-
<java-version>1.7</java-version>
132-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
133-
</properties>
61+
</build>
62+
<profiles>
63+
<profile>
64+
<id>build-extras</id>
65+
<build>
66+
<plugins>
67+
<plugin>
68+
<artifactId>maven-source-plugin</artifactId>
69+
<executions>
70+
<execution>
71+
<id>attach-sources</id>
72+
<goals>
73+
<goal>jar</goal>
74+
</goals>
75+
</execution>
76+
</executions>
77+
</plugin>
78+
<plugin>
79+
<artifactId>maven-javadoc-plugin</artifactId>
80+
<version>2.10.4</version>
81+
<executions>
82+
<execution>
83+
<id>attach-javadocs</id>
84+
<goals>
85+
<goal>jar</goal>
86+
</goals>
87+
</execution>
88+
</executions>
89+
<configuration>
90+
<show>private</show>
91+
<nohelp>true</nohelp>
92+
<additionalparam>-Xdoclint:none</additionalparam>
93+
</configuration>
94+
</plugin>
95+
<plugin>
96+
<artifactId>maven-gpg-plugin</artifactId>
97+
<version>1.6</version>
98+
<executions>
99+
<execution>
100+
<id>sign-artifacts</id>
101+
<phase>package</phase>
102+
<goals>
103+
<goal>sign</goal>
104+
</goals>
105+
</execution>
106+
</executions>
107+
</plugin>
108+
</plugins>
109+
</build>
110+
<properties>
111+
<gpg.keyname>${env.GPG_KEYNAME}</gpg.keyname>
112+
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
113+
</properties>
114+
</profile>
115+
</profiles>
116+
<dependencies>
117+
<dependency>
118+
<groupId>junit</groupId>
119+
<artifactId>junit</artifactId>
120+
<version>4.12</version>
121+
<scope>test</scope>
122+
<exclusions>
123+
<exclusion>
124+
<artifactId>hamcrest-core</artifactId>
125+
<groupId>org.hamcrest</groupId>
126+
</exclusion>
127+
</exclusions>
128+
</dependency>
129+
</dependencies>
130+
<properties>
131+
<skipTests>true</skipTests>
132+
<java-version>1.7</java-version>
133+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
134+
</properties>
134135
</project>
135136

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<artifactId>maven-surefire-plugin</artifactId>
127127
<version>2.12.4</version>
128128
<configuration>
129-
<skipTests>${skipTests}</skipTests>
129+
<skipTests>${skipTests}</skipTests>
130130
</configuration>
131131
</plugin>
132132
</plugins>

‎src/main/java/jota/IotaAPI.java‎

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ public GetNewAddressResponse getNewAddress(final String seed, int security, fina
109109
*/
110110
public GetTransferResponse getTransfers(String seed, int security, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException, NoNodeInfoException, NoInclusionStatesException, InvalidSecurityLevelException, InvalidAddressException {
111111
StopWatch stopWatch = new StopWatch();
112-
// validate & if needed pad seed
113-
if ((seed = InputValidator.validateSeed(seed)) == null) {
112+
// validate seed
113+
if ((!InputValidator.isValidSeed(seed))) {
114114
throw new IllegalStateException("Invalid Seed");
115115
}
116116

@@ -344,14 +344,15 @@ public List<Transaction> findTransactionObjectsByBundle(String[] input) {
344344
public List<String> prepareTransfers(String seed, int security, final List<Transfer> transfers, String remainder, List<Input> inputs) throws NotEnoughBalanceException, InvalidSecurityLevelException, InvalidAddressException, InvalidTransferException {
345345
return prepareTransfers(seed, security, transfers, remainder, inputs, true);
346346
}
347+
347348
/**
348349
* Prepares transfer by generating bundle, finding and signing inputs.
349350
*
350-
* @param seed 81-tryte encoded address of recipient.
351-
* @param security The security level of private key / seed.
352-
* @param transfers Array of transfer objects.
353-
* @param remainder If defined, this address will be used for sending the remainder value (of the inputs) to.
354-
* @param inputs The inputs.
351+
* @param seed 81-tryte encoded address of recipient.
352+
* @param security The security level of private key / seed.
353+
* @param transfers Array of transfer objects.
354+
* @param remainder If defined, this address will be used for sending the remainder value (of the inputs) to.
355+
* @param inputs The inputs.
355356
* @param validateInputs whether or not to validate the balances of the provided inputs
356357
* @return Returns bundle trytes.
357358
* @throws InvalidAddressException is thrown when the specified address is not an valid address.
@@ -366,8 +367,8 @@ public List<String> prepareTransfers(String seed, int security, final List<Trans
366367
throw new InvalidTransferException();
367368
}
368369

369-
// validate & if needed pad seed
370-
if ((seed = InputValidator.validateSeed(seed)) == null) {
370+
// validate seed
371+
if ((!InputValidator.isValidSeed(seed))) {
371372
throw new IllegalStateException("Invalid Seed");
372373
}
373374

@@ -438,11 +439,11 @@ public List<String> prepareTransfers(String seed, int security, final List<Trans
438439

439440
// Get inputs if we are sending tokens
440441
if (totalValue != 0) {
441-
if(!validateInputs)
442+
if (!validateInputs)
442443
return addRemainder(seed, security, inputs, bundle, tag, totalValue, remainder, signatureFragments);
443444
// Case 1: user provided inputs
444445
// Validate the inputs by calling getBalances
445-
if(!validateInputs)
446+
if (!validateInputs)
446447
return addRemainder(seed, security, inputs, bundle, tag, totalValue, remainder, signatureFragments);
447448
if (inputs != null && !inputs.isEmpty()) {
448449

@@ -524,13 +525,9 @@ public List<String> prepareTransfers(String seed, int security, final List<Trans
524525
**/
525526
public GetBalancesAndFormatResponse getInputs(String seed, int security, int start, int end, long threshold) throws InvalidSecurityLevelException, InvalidAddressException {
526527
StopWatch stopWatch = new StopWatch();
527-
// validate the seed
528-
if (!InputValidator.isTrytes(seed, 0)) {
529-
throw new IllegalStateException("Invalid Seed");
530-
}
531528

532-
// validate & if needed pad seed
533-
if ((seed = InputValidator.validateSeed(seed)) == null) {
529+
// validate the seed
530+
if ((!InputValidator.isValidSeed(seed))) {
534531
throw new IllegalStateException("Invalid Seed");
535532
}
536533

‎src/main/java/jota/dto/request/IotaAttachToTangleRequest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/**
66
* This class represents the core API request 'attachToTangle'.
7-
*
7+
* <p>
88
* It is used to attach trytes to the tangle.
99
**/
1010
public class IotaAttachToTangleRequest extends IotaCommandRequest {

‎src/main/java/jota/dto/request/IotaBroadcastTransactionRequest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/**
66
* This class represents the core API request 'broadcastTransaction'.
7-
*
7+
* <p>
88
* Broadcast a list of transactions to all neighbors. The input trytes for this call are provided by attachToTangle
99
**/
1010
public class IotaBroadcastTransactionRequest extends IotaCommandRequest {

‎src/main/java/jota/dto/request/IotaStoreTransactionsRequest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/**
66
* This class represents the core API request 'getTransactionsToApprove'.
7-
*
7+
* <p>
88
* It stores transactions into the local storage. The trytes to be used for this call are returned by attachToTangle.
99
**/
1010
public class IotaStoreTransactionsRequest extends IotaCommandRequest {

‎src/main/java/jota/pow/JCurl.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public JCurl(boolean pair) {
4343
stateLow = null;
4444
}
4545
}
46+
4647
/**
4748
* Absorbs the specified trits.
4849
*

0 commit comments

Comments
 (0)