mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2025-10-16 11:45:37 +00:00
fixed timestamp
This commit is contained in:
parent
a27168dee0
commit
c4ab852283
@ -359,9 +359,8 @@ public class IotaAPI extends IotaAPICoreProxy {
|
||||
msgCopy = StringUtils.substring(msgCopy, 2187, msgCopy.length());
|
||||
|
||||
// Pad remainder of fragment
|
||||
for (int j = 0; fragment.length() < 2187; j++) {
|
||||
fragment += "9";
|
||||
}
|
||||
|
||||
fragment = StringUtils.rightPad(fragment, 2187, '9');
|
||||
|
||||
signatureFragments.add(fragment);
|
||||
}
|
||||
@ -369,9 +368,7 @@ public class IotaAPI extends IotaAPICoreProxy {
|
||||
// Else, get single fragment with 2187 of 9's trytes
|
||||
String fragment = StringUtils.substring(transfer.getMessage(), 0, 2187);
|
||||
|
||||
for (int j = 0; fragment.length() < 2187; j++) {
|
||||
fragment += '9';
|
||||
}
|
||||
fragment = StringUtils.rightPad(fragment, 2187, '9');
|
||||
|
||||
signatureFragments.add(fragment);
|
||||
}
|
||||
@ -383,9 +380,7 @@ public class IotaAPI extends IotaAPICoreProxy {
|
||||
tag = transfer.getTag().isEmpty() ? "999999999999999999999999999" : transfer.getTag();
|
||||
|
||||
// Pad for required 27 tryte length
|
||||
for (int j = 0; tag.length() < 27; j++) {
|
||||
tag += '9';
|
||||
}
|
||||
tag = StringUtils.rightPad(tag, 27, '9');
|
||||
|
||||
// Add first entry to the bundle
|
||||
bundle.addEntry(signatureMessageLength, transfer.getAddress(), transfer.getValue(), tag, timestamp);
|
||||
@ -551,7 +546,6 @@ public class IotaAPI extends IotaAPICoreProxy {
|
||||
}
|
||||
|
||||
if (thresholdReached) {
|
||||
long duration = stopWatch.getElapsedTimeMili();
|
||||
return GetBalancesAndFormatResponse.create(inputs, totalBalance, stopWatch.getElapsedTimeMili());
|
||||
}
|
||||
throw new IllegalStateException("Not enough balance");
|
||||
@ -794,7 +788,7 @@ public class IotaAPI extends IotaAPICoreProxy {
|
||||
long thisBalance = inputs.get(i).getBalance();
|
||||
long totalTransferValue = totalValue;
|
||||
long toSubtract = 0 - thisBalance;
|
||||
long timestamp = (new Date()).getTime();
|
||||
long timestamp = (long) Math.floor(Calendar.getInstance().getTimeInMillis() / 1000);
|
||||
|
||||
// Add input as bundle entry
|
||||
bundle.addEntry(2, inputs.get(i).getAddress(), toSubtract, tag, timestamp);
|
||||
|
||||
@ -3,6 +3,7 @@ package jota.model;
|
||||
import jota.pow.ICurl;
|
||||
import jota.pow.JCurl;
|
||||
import jota.utils.Converter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -31,10 +32,6 @@ public class Bundle implements Comparable {
|
||||
return transactions;
|
||||
}
|
||||
|
||||
public void setTransactions(List<Transaction> transactions) {
|
||||
this.transactions = transactions;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return length;
|
||||
}
|
||||
@ -49,7 +46,6 @@ public class Bundle implements Comparable {
|
||||
}
|
||||
|
||||
for (int i = 0; i < signatureMessageLength; i++) {
|
||||
List<Transaction> transactions = new ArrayList<>(getTransactions());
|
||||
Transaction trx = new Transaction(address, String.valueOf(i == 0 ? value : 0), tag, String.valueOf(timestamp));
|
||||
getTransactions().add(trx);
|
||||
}
|
||||
@ -89,9 +85,7 @@ public class Bundle implements Comparable {
|
||||
String emptySignatureFragment = "";
|
||||
String emptyHash = EMPTY_HASH;
|
||||
|
||||
for (int j = 0; emptySignatureFragment.length() < 2187; j++) {
|
||||
emptySignatureFragment += '9';
|
||||
}
|
||||
emptySignatureFragment = StringUtils.rightPad(emptySignatureFragment, 2187, '9');
|
||||
|
||||
for (int i = 0; i < this.getTransactions().size(); i++) {
|
||||
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
package jota.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jota.model.Transfer;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by pinpong on 02.12.16.
|
||||
*/
|
||||
@ -82,8 +83,11 @@ public class InputValidator {
|
||||
}
|
||||
|
||||
public static String validateSeed(String seed) {
|
||||
if (seed.length() > 81) return null;
|
||||
while (seed.length() < 81) seed += 9;
|
||||
if (seed.length() > 81)
|
||||
return null;
|
||||
|
||||
seed = StringUtils.rightPad(seed, 81, '9');
|
||||
|
||||
return seed;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user