mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2026-10-04 13:37:00 +00:00
Bugfixes
This commit is contained in:
@@ -255,7 +255,7 @@ public class IotaAPIProxy {
|
||||
getTransfers
|
||||
sendTransfer
|
||||
getBundle
|
||||
|
||||
|
||||
getTransactionsObjects
|
||||
findTransactionObjects
|
||||
|
||||
@@ -335,7 +335,7 @@ public class IotaAPIProxy {
|
||||
}
|
||||
return trxs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper function for findTransactions, getTrytes and transactionObjects
|
||||
* Returns the transactionObject of a transaction hash. The input can be a valid
|
||||
@@ -628,7 +628,7 @@ public class IotaAPIProxy {
|
||||
bundleTrytes.add(IotaAPIUtils.transactionTrytes(element));
|
||||
}
|
||||
|
||||
return sendTrytes(bundleTrytes, minWeightMagnitude);
|
||||
return sendTrytes(bundleTrytes.get(0), minWeightMagnitude);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,25 +60,14 @@ public class Bundle {
|
||||
|
||||
for (int i = 0; i < this.getTransactions().size(); i++) {
|
||||
|
||||
int[] valueTrits = Converter.trits(this.getTransactions().get(i).getValue());
|
||||
while (valueTrits.length < 81) {
|
||||
valueTrits[valueTrits.length] = 0;
|
||||
}
|
||||
int[] valueTrits = Converter.trits(this.getTransactions().get(i).getValue(),81);
|
||||
|
||||
int[] timestampTrits = Converter.trits(this.getTransactions().get(i).getTimestamp());
|
||||
while (timestampTrits.length < 27) {
|
||||
timestampTrits[timestampTrits.length] = 0;
|
||||
}
|
||||
int[] timestampTrits = Converter.trits(this.getTransactions().get(i).getTimestamp(), 27);
|
||||
|
||||
int[] currentIndexTrits = Converter.trits(this.getTransactions().get(i).setCurrentIndex("" + i));
|
||||
while (currentIndexTrits.length < 27) {
|
||||
currentIndexTrits[currentIndexTrits.length] = 0;
|
||||
}
|
||||
int[] currentIndexTrits = Converter.trits(this.getTransactions().get(i).setCurrentIndex("" + i), 27);
|
||||
|
||||
int[] lastIndexTrits = Converter.trits(this.getTransactions().get(i).setLastIndex("" + (this.getTransactions().size() - 1)), 27);
|
||||
|
||||
int[] lastIndexTrits = Converter.trits(this.getTransactions().get(i).setLastIndex("" + (this.getTransactions().size() - 1)));
|
||||
while (lastIndexTrits.length < 27) {
|
||||
lastIndexTrits[lastIndexTrits.length] = 0;
|
||||
}
|
||||
|
||||
int[] t = Converter.trits(this.getTransactions().get(i).getAddress() + Converter.trytes(valueTrits) + this.getTransactions().get(i).getTag() + Converter.trytes(timestampTrits) + Converter.trytes(currentIndexTrits) + Converter.trytes(lastIndexTrits));
|
||||
curl.absorb(t, 0, t.length);
|
||||
|
||||
@@ -7,6 +7,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class Converter {
|
||||
|
||||
@@ -66,6 +68,30 @@ public class Converter {
|
||||
}
|
||||
}
|
||||
|
||||
public static int[] convertToIntArray(List<Integer> integers)
|
||||
{
|
||||
int[] ret = new int[integers.size()];
|
||||
for (int i=0; i < ret.length; i++)
|
||||
{
|
||||
ret[i] = integers.get(i).intValue();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int[] trits(final String trytes, int length) {
|
||||
int[] trits = trits(trytes);
|
||||
|
||||
List<Integer> tritsList = new LinkedList<>();
|
||||
|
||||
for(int i : trits)
|
||||
tritsList.add(i);
|
||||
|
||||
while(tritsList.size() < length)
|
||||
tritsList.add(0);
|
||||
|
||||
return convertToIntArray(tritsList);
|
||||
}
|
||||
|
||||
public static int[] trits(final String trytes) {
|
||||
final int[] trits = new int[trytes.length() * NUMBER_OF_TRITS_IN_A_TRYTE];
|
||||
|
||||
@@ -75,6 +101,8 @@ public class Converter {
|
||||
|
||||
long absoluteValue = value < 0 ? -value : value;
|
||||
|
||||
int position = 0;
|
||||
|
||||
while (absoluteValue > 0) {
|
||||
|
||||
int remainder = (int) (absoluteValue % RADIX);
|
||||
@@ -85,7 +113,7 @@ public class Converter {
|
||||
absoluteValue++;
|
||||
}
|
||||
|
||||
trits[trits.length] = remainder;
|
||||
trits[position++] = remainder;
|
||||
}
|
||||
if (value < 0) {
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ public class InputValidator {
|
||||
}
|
||||
|
||||
public static boolean isArrayOfHashes(String[] hashes) {
|
||||
if (hashes == null) return false;
|
||||
if (hashes == null)
|
||||
return false;
|
||||
|
||||
for (String hash : hashes) {
|
||||
// Check if address with checksum
|
||||
|
||||
@@ -44,25 +44,16 @@ public class IotaAPIUtils {
|
||||
}
|
||||
|
||||
public static String transactionTrytes(Transaction trx) {
|
||||
int[] valueTrits = Converter.trits(trx.getValue());
|
||||
while (valueTrits.length < 81) {
|
||||
valueTrits[valueTrits.length] = 0;
|
||||
}
|
||||
int[] valueTrits = Converter.trits(trx.getValue(), 81);
|
||||
|
||||
int[] timestampTrits = Converter.trits(trx.getTimestamp());
|
||||
while (timestampTrits.length < 27) {
|
||||
timestampTrits[timestampTrits.length] = 0;
|
||||
}
|
||||
int[] timestampTrits = Converter.trits(trx.getTimestamp(), 27);
|
||||
|
||||
int[] currentIndexTrits = Converter.trits(trx.getTimestamp());
|
||||
while (currentIndexTrits.length < 27) {
|
||||
currentIndexTrits[currentIndexTrits.length] = 0;
|
||||
}
|
||||
|
||||
int[] lastIndexTrits = Converter.trits(trx.getCurrentIndex());
|
||||
while (lastIndexTrits.length < 27) {
|
||||
lastIndexTrits[lastIndexTrits.length] = 0;
|
||||
}
|
||||
int[] currentIndexTrits = Converter.trits(trx.getTimestamp(), 27);
|
||||
|
||||
|
||||
int[] lastIndexTrits = Converter.trits(trx.getCurrentIndex(), 27);
|
||||
|
||||
|
||||
return trx.getSignatureFragments()
|
||||
+ trx.getAddress()
|
||||
|
||||
Reference in New Issue
Block a user