mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2025-10-16 11:45:37 +00:00
fixed NullPoointer
This commit is contained in:
parent
5881879f78
commit
b1c75bf0de
@ -577,10 +577,12 @@ public class IotaAPIProxy {
|
||||
|
||||
// Calls getBalances and formats the output
|
||||
// returns the final inputsObject then
|
||||
public GetBalancesAndFormatResponse getBalanceAndFormat(final List<String> addresses,
|
||||
final List<String> balances, long threshold, int start, int end) {
|
||||
public GetBalancesAndFormatResponse getBalanceAndFormat(final List<String> addresses, List<String> balances, long threshold, int start, int end) {
|
||||
|
||||
GetBalancesResponse bres = getBalances(100, addresses);
|
||||
if (balances == null || balances.isEmpty()) {
|
||||
GetBalancesResponse getBalancesResponse = getBalances(100, addresses);
|
||||
balances = Arrays.asList(getBalancesResponse.getBalances());
|
||||
}
|
||||
|
||||
// If threshold defined, keep track of whether reached or not
|
||||
// else set default to true
|
||||
|
||||
@ -2,14 +2,12 @@ package jota.utils;
|
||||
|
||||
import jota.model.Transaction;
|
||||
import jota.pow.Curl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Converter {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Converter.class);
|
||||
@ -69,12 +67,39 @@ public class Converter {
|
||||
}
|
||||
|
||||
public static int[] trits(final String trytes) {
|
||||
|
||||
final int[] trits = new int[trytes.length() * NUMBER_OF_TRITS_IN_A_TRYTE];
|
||||
for (int i = 0; i < trytes.length(); i++) {
|
||||
System.arraycopy(TRYTE_TO_TRITS_MAPPINGS[Constants.TRYTE_ALPHABET.indexOf(trytes.charAt(i))], 0, trits, i * NUMBER_OF_TRITS_IN_A_TRYTE, NUMBER_OF_TRITS_IN_A_TRYTE);
|
||||
}
|
||||
|
||||
if (InputValidator.isValue(trytes)) {
|
||||
|
||||
int value = Integer.parseInt(trytes);
|
||||
|
||||
long absoluteValue = value < 0 ? -value : value;
|
||||
|
||||
while (absoluteValue > 0) {
|
||||
|
||||
int remainder = (int) (absoluteValue % RADIX);
|
||||
absoluteValue /= RADIX;
|
||||
|
||||
if (remainder > MAX_TRIT_VALUE) {
|
||||
remainder = MIN_TRIT_VALUE;
|
||||
absoluteValue++;
|
||||
}
|
||||
|
||||
trits[trits.length] = remainder;
|
||||
}
|
||||
if (value < 0) {
|
||||
|
||||
for (int i = 0; i < trits.length; i++) {
|
||||
|
||||
trits[i] = -trits[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < trytes.length(); i++) {
|
||||
System.arraycopy(TRYTE_TO_TRITS_MAPPINGS[Constants.TRYTE_ALPHABET.indexOf(trytes.charAt(i))], 0, trits, i * NUMBER_OF_TRITS_IN_A_TRYTE, NUMBER_OF_TRITS_IN_A_TRYTE);
|
||||
}
|
||||
}
|
||||
return trits;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user