mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2026-10-04 13:37:00 +00:00
[WIP]
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
package jota.model;
|
||||
|
||||
import jota.pow.Curl;
|
||||
import jota.utils.Constants;
|
||||
import jota.utils.Converter;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -16,6 +15,9 @@ public class Bundle {
|
||||
private List<Transaction> transactions;
|
||||
private int length;
|
||||
|
||||
public static String EMPTY_HASH = "999999999999999999999999999999999999999999999999999999999999999999999999999999999";
|
||||
|
||||
|
||||
public Bundle() {
|
||||
this(new ArrayList<Transaction>(), 0);
|
||||
}
|
||||
@@ -99,7 +101,7 @@ public class Bundle {
|
||||
|
||||
public void addTrytes(List<String> signatureFragments) {
|
||||
String emptySignatureFragment = "";
|
||||
String emptyHash = "999999999999999999999999999999999999999999999999999999999999999999999999999999999";
|
||||
String emptyHash = EMPTY_HASH;
|
||||
|
||||
for (int j = 0; emptySignatureFragment.length() < 2187; j++) {
|
||||
emptySignatureFragment += '9';
|
||||
@@ -108,9 +110,7 @@ public class Bundle {
|
||||
for (int i = 0; i < this.getTransactions().size(); i++) {
|
||||
|
||||
// Fill empty signatureMessageFragment
|
||||
|
||||
//TODO
|
||||
///this.getTransactions().get(i).signatureMessageFragment(signatureFragments[i] ? signatureFragments[i] : emptySignatureFragment);
|
||||
this.getTransactions().get(i).setSignatureFragments(signatureFragments.get(i) == null ? signatureFragments.get(i) : emptySignatureFragment);
|
||||
// Fill empty trunkTransaction
|
||||
this.getTransactions().get(i).setTrunkTransaction(emptyHash);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
*/
|
||||
public class Transaction {
|
||||
private String hash;
|
||||
private String signatureMessageChunk;
|
||||
private String signatureFragments;
|
||||
private String address;
|
||||
private String value;
|
||||
private String tag;
|
||||
@@ -24,11 +24,11 @@ public class Transaction {
|
||||
|
||||
}
|
||||
|
||||
public Transaction(String signatureMessageChunk, String currentIndex, String lastIndex, String nonce, String hash, String tag, String timestamp, String trunkTransaction, String branchTransaction, String address, String value, String bundle) {
|
||||
public Transaction(String signatureFragments, String currentIndex, String lastIndex, String nonce, String hash, String tag, String timestamp, String trunkTransaction, String branchTransaction, String address, String value, String bundle) {
|
||||
|
||||
this.hash = hash;
|
||||
this.tag = tag;
|
||||
this.signatureMessageChunk = signatureMessageChunk;
|
||||
this.signatureFragments = signatureFragments;
|
||||
this.address = address;
|
||||
this.value = value;
|
||||
this.timestamp = timestamp;
|
||||
@@ -45,69 +45,36 @@ public class Transaction {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
|
||||
public void setSignatureMessageChunk(String signatureMessageChunk) {
|
||||
|
||||
this.signatureMessageChunk = signatureMessageChunk;
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void setHash(String hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
public String getSignatureFragments() {
|
||||
return signatureFragments;
|
||||
}
|
||||
|
||||
public void setTrunkTransaction(String trunkTransaction) {
|
||||
this.trunkTransaction = trunkTransaction;
|
||||
}
|
||||
|
||||
public void setBranchTransaction(String branchTransaction) {
|
||||
this.branchTransaction = branchTransaction;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setBundle(String bundle) {
|
||||
this.bundle = bundle;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getTrunkTransaction() {
|
||||
return trunkTransaction;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
public String setSignatureFragments(String signatureFragments) {
|
||||
return this.signatureFragments = signatureFragments;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public String getBranchTransaction() {
|
||||
return branchTransaction;
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getBundle() {
|
||||
return bundle;
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public String getSignatureMessageChunk() {
|
||||
return signatureMessageChunk;
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
@@ -118,6 +85,14 @@ public class Transaction {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getCurrentIndex() {
|
||||
return currentIndex;
|
||||
}
|
||||
@@ -134,6 +109,30 @@ public class Transaction {
|
||||
return this.lastIndex = lastIndex;
|
||||
}
|
||||
|
||||
public String getBundle() {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
public void setBundle(String bundle) {
|
||||
this.bundle = bundle;
|
||||
}
|
||||
|
||||
public String getTrunkTransaction() {
|
||||
return trunkTransaction;
|
||||
}
|
||||
|
||||
public void setTrunkTransaction(String trunkTransaction) {
|
||||
this.trunkTransaction = trunkTransaction;
|
||||
}
|
||||
|
||||
public String getBranchTransaction() {
|
||||
return branchTransaction;
|
||||
}
|
||||
|
||||
public void setBranchTransaction(String branchTransaction) {
|
||||
this.branchTransaction = branchTransaction;
|
||||
}
|
||||
|
||||
public String getNonce() {
|
||||
return nonce;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class Converter {
|
||||
Transaction trx = new Transaction();
|
||||
|
||||
trx.setHash(Converter.trytes(hash));
|
||||
trx.setSignatureMessageChunk(trytes.substring(0, 2187));
|
||||
trx.setSignatureFragments(trytes.substring(0, 2187));
|
||||
trx.setAddress(trytes.substring(2187, 2268));
|
||||
trx.setValue("" + Converter.value(Arrays.copyOfRange(transactionTrits, 6804, 6837)));
|
||||
trx.setTag(trytes.substring(2295, 2322));
|
||||
|
||||
@@ -69,7 +69,7 @@ public class IotaAPIUtils {
|
||||
lastIndexTrits[lastIndexTrits.length] = 0;
|
||||
}
|
||||
|
||||
return trx.getSignatureMessageChunk()
|
||||
return trx.getSignatureFragments()
|
||||
+ trx.getAddress()
|
||||
+ Converter.trytes(valueTrits)
|
||||
+ trx.getTag()
|
||||
@@ -123,7 +123,7 @@ public class IotaAPIUtils {
|
||||
int[] firstSignedFragment = Signing.signatureFragment(firstBundleFragment, firstFragment);
|
||||
|
||||
// Convert signature to trytes and assign the new signatureFragment
|
||||
bundle.getTransactions().get(i).setSignatureMessageChunk(Converter.trytes(firstSignedFragment));
|
||||
bundle.getTransactions().get(i).setSignatureFragments(Converter.trytes(firstSignedFragment));
|
||||
|
||||
// Because the signature is > 2187 trytes, we need to
|
||||
// find the second transaction to add the remainder of the signature
|
||||
@@ -140,7 +140,7 @@ public class IotaAPIUtils {
|
||||
int[] secondSignedFragment = Signing.signatureFragment(secondBundleFragment, secondFragment);
|
||||
|
||||
// Convert signature to trytes and assign it again to this bundle entry
|
||||
bundle.getTransactions().get(j).setSignatureMessageChunk(Converter.trytes(secondSignedFragment));
|
||||
bundle.getTransactions().get(j).setSignatureFragments(Converter.trytes(secondSignedFragment));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user