Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ plugins {
apply plugin:'java'
apply plugin:'maven'
apply plugin:'maven-publish'
apply plugin:'signing'

repositories {
jcenter()
Expand Down Expand Up @@ -88,6 +87,7 @@ uploadArchives {
}

if (project.hasProperty("signing.keyId")) {
apply plugin: 'signing'
signing {
sign configurations.archives
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Transaction {
Expand All @@ -31,6 +32,7 @@ public class Transaction {
public String signature;
public String signSignature;
public String vendorField;

public String vendorFieldHex;

public static Transaction deserialize(String serialized) {
Expand Down Expand Up @@ -212,10 +214,52 @@ public String serialize() {
}

public String toJson() {

HashMap<String, Object> map = new HashMap<String, Object>();
map.put("network", this.network);
map.put("id", this.id);
map.put("timestamp", this.timestamp);
map.put("expiration", this.expiration);
map.put("type", this.type);
map.put("amount", this.amount);
map.put("fee", this.fee);
map.put("recipientId", this.recipientId);
map.put("signature", this.signature);
map.put("senderPublicKey", this.senderPublicKey);

if (this.vendorField != null && !this.vendorField.isEmpty()) {
map.put("vendorField", this.vendorField);
}

if (this.signSignature!= null && !this.signSignature.isEmpty()) {
map.put("signSignature", this.signSignature);
}

HashMap<String, Object> asset = new HashMap();
if (this.type == Types.SECOND_SIGNATURE_REGISTRATION) {
HashMap<String, String> publicKey = new HashMap();
publicKey.put("publicKey", this.asset.signature.publicKey);
asset.put("signature", publicKey);
} else if (this.type == Types.VOTE) {
asset.put("votes", this.asset.votes);
} else if (this.type == Types.DELEGATE_REGISTRATION) {
HashMap<String, String> delegate = new HashMap();
delegate.put("username", this.asset.delegate.username);
asset.put("delegate", delegate);
} else if (this.type == Types.MULTI_SIGNATURE_REGISTRATION) {
HashMap<String, Object> multisignature = new HashMap();
multisignature.put("min", this.asset.multisignature.min);
multisignature.put("lifetime", this.asset.multisignature.lifetime);
multisignature.put("keysgroup", this.asset.multisignature.keysgroup);
asset.put("multisignature", multisignature);
}

if (!asset.isEmpty()) {
map.put("asset", asset);
}

GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Types.class, new TransactionTypeDeserializer());
gsonBuilder.registerTypeAdapter(Types.class, new TransactionTypeSerializer());
return gsonBuilder.create().toJson(this);
return gsonBuilder.create().toJson(map);
}

private static class TransactionTypeDeserializer implements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public AbstractTransaction() {
this.transaction.type = this.getType();
this.transaction.fee = Fee.get(this.getType());
this.transaction.timestamp = Slot.time();
this.transaction.version = 1;
}

public AbstractTransaction sign(String passphrase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public MultiSignatureRegistration keysgroup(List<String> keysgroup) {
}

public Types getType() {
return Types.TRANSFER;
return Types.MULTI_SIGNATURE_REGISTRATION;
}

}
2 changes: 1 addition & 1 deletion src/main/java/org/arkecosystem/crypto/utils/Slot.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class Slot {
public static int time() {
return (int) (new Date().getTime() - epoch()) / 1000;
return (int)((new Date().getTime() - epoch()) / 1000);
}

public static long epoch() {
Expand Down