Finalizing the bundle fails, because the ICurl
instance (jota.pow.Kerl
) can't absorb
due to the supplied trits not having the required length.
Exception in thread "main" java.lang.RuntimeException: Illegal length: 162
at jota.pow.Kerl.absorb(Kerl.java:287)
at jota.pow.Kerl.absorb(Kerl.java:9)
at jota.model.Bundle.finalize(Bundle.java:118)
Below some example code that reproduces the error within my application.
Is there anything I should do different when creating bundles and transactions? How can I prevent this kind of error?
import jota.model.Bundle;
import jota.model.Transaction;
import jota.utils.SeedRandomGenerator;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public class CreateBundle {
public static void main(String[] args) throws IOException {
Transaction tx = new Transaction();
tx.setValue(0);
tx.setAddress("");
tx.setTrunkTransaction("");
tx.setBranchTransaction("");
tx.setAttachmentTimestamp(System.currentTimeMillis() / 1000);
tx.setAttachmentTimestampLowerBound(0);
tx.setAttachmentTimestampUpperBound(3_812_798_742_493L);
//tx.setBundle(""); // set by finalize
tx.setCurrentIndex(0);
tx.setLastIndex(0);
//tx.setHash("");
tx.setObsoleteTag("");
//tx.setPersistence(Boolean.TRUE);
tx.setTag("APPLICATION_TAG");
tx.setTimestamp(System.currentTimeMillis());
String message = "DATA_TO_BE_SAVED_ON_TANGLE".replace('_', '9');
String messageTrytes = message + new String(new char[2187 - message.length()]).replace('\0', '9');
tx.setSignatureFragments(messageTrytes);
System.out.println(tx);
Bundle bundle = new Bundle(Arrays.asList(tx), 1);
//bundle.normalizedBundle();
bundle.finalize(null); // Exception in thread "main" java.lang.RuntimeException: Illegal length: 162
}
}