fixed almost everything

This commit is contained in:
AZ
2016-12-29 22:02:29 +01:00
parent 4c83f38892
commit 8db0f33481
4 changed files with 19 additions and 10 deletions
+5 -3
View File
@@ -335,6 +335,8 @@ public class IotaAPIProxy {
for (String trx : tailTxArray) {
GetBundleResponse bundleResponse = getBundle(trx);
// TODO: review possibly dirty WA
if(bundleResponse == null) continue;
Bundle gbr = new Bundle(bundleResponse.getTransactions(), bundleResponse.getTransactions().size());
if (gbr != null && gbr.getTransactions() != null) {
if (inclusionStates) {
@@ -349,9 +351,9 @@ public class IotaAPIProxy {
Collections.sort(finalBundles, new Comparator<Bundle>() {
public int compare(Bundle c1, Bundle c2) {
if (Long.parseLong(c1.getTransactions().get(0).getTimestamp()) > Long.parseLong(c2.getTransactions().get(0).getTimestamp()))
return -1;
if (Long.parseLong(c1.getTransactions().get(0).getTimestamp()) < Long.parseLong(c2.getTransactions().get(0).getTimestamp()))
return -1;
if (Long.parseLong(c1.getTransactions().get(0).getTimestamp()) > Long.parseLong(c2.getTransactions().get(0).getTimestamp()))
return 1;
return 0;
}
@@ -790,7 +792,7 @@ public class IotaAPIProxy {
String address = signaturesToValidate.get(i).getAddress();
boolean isValidSignature = Signing.validateSignatures(address, signatureFragments, bundleHash);
//if (!isValidSignature) throw new InvalidSignatureException();
if (!isValidSignature) throw new InvalidSignatureException();
}
return GetBundleResponse.create(bundle.getTransactions());
+1 -1
View File
@@ -115,7 +115,7 @@ public class Bundle {
long sum = 0;
for (int j = 0; j < 27; j++) {
sum += (normalizedBundle[i * 27 + j] = Converter.value(Converter.trits("" + bundleHash.charAt(i * 27 + j))));
sum += (normalizedBundle[i * 27 + j] = Converter.value(Converter.tritsString("" + bundleHash.charAt(i * 27 + j))));
}
if (sum >= 0) {
+12 -5
View File
@@ -11,7 +11,7 @@ import java.util.LinkedList;
import java.util.List;
public class Converter {
private static final Logger log = LoggerFactory.getLogger(Converter.class);
private static final int RADIX = 3;
@@ -91,6 +91,13 @@ public class Converter {
return convertToIntArray(tritsList);
}
public static int[] tritsString(final String trytes){
int[] d = new int[3 * trytes.length()];
for (int i = 0; i < trytes.length(); i++) {
System.arraycopy(TRYTE_TO_TRITS_MAPPINGS[Constants.TRYTE_ALPHABET.indexOf(trytes.charAt(i))], 0, d, i * NUMBER_OF_TRITS_IN_A_TRYTE, NUMBER_OF_TRITS_IN_A_TRYTE);
}
return d;
}
public static int[] trits(final String trytes) {
final List<Integer> trits = new LinkedList<>();
@@ -238,14 +245,14 @@ public class Converter {
+ trx.getBranchTransaction()
+ trx.getNonce();
}
public static Transaction transactionObject(final String trytes) {
if (StringUtils.isEmpty(trytes)) {
log.warn("Warning: empty trytes in input for transactionObject");
return null;
}
// validity check
for (int i = 2279; i < 2295; i++) {
if (trytes.charAt(i) != '9') {
@@ -253,7 +260,7 @@ public class Converter {
return null;
}
}
int[] transactionTrits = Converter.trits(trytes);
int[] hash = new int[243];
+1 -1
View File
@@ -163,7 +163,7 @@ public class Signing {
digests[i * 243 + j] = digestBuffer[j];
}
}
System.out.println(Arrays.toString(digests).replaceAll("\\s+",""));
//System.out.println(Arrays.toString(digests).replaceAll("\\s+",""));
String address = Converter.trytes(address(digests));
return (expectedAddress.equals(address));