diff --git a/gradle.properties b/gradle.properties
index 1053dd5..5bfcab3 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -17,8 +17,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
-VERSION_NAME=0.4.4
-VERSION_CODE=6
+VERSION_NAME=0.4.6
+VERSION_CODE=9
GROUP=com.github.bilthon
POM_DESCRIPTION=A Java library for mobile app Developers; Graphene/Bitshares blockchain.
diff --git a/graphenej/build.gradle b/graphenej/build.gradle
index 64f87e8..0d30268 100644
--- a/graphenej/build.gradle
+++ b/graphenej/build.gradle
@@ -1,5 +1,5 @@
-group 'de.bitsharesmunich'
-version '0.4.4'
+group 'cy.agorise'
+version '0.4.6'
apply plugin: 'com.android.library'
apply from: 'maven-push.gradle'
@@ -21,9 +21,8 @@ android {
defaultConfig {
minSdkVersion 9
targetSdkVersion 24
- versionCode 6
- versionName "0.4.4"
-
+ versionCode 9
+ versionName "0.4.6"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
diff --git a/graphenej/src/main/AndroidManifest.xml b/graphenej/src/main/AndroidManifest.xml
index b86d91f..4df96c3 100644
--- a/graphenej/src/main/AndroidManifest.xml
+++ b/graphenej/src/main/AndroidManifest.xml
@@ -1,9 +1,8 @@
-
+ package="cy.agorise.graphenej"
+ android:versionCode="9"
+ android:versionName="0.4.6" >
\ No newline at end of file
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/AccountOptions.java b/graphenej/src/main/java/cy/agorise/graphenej/AccountOptions.java
similarity index 96%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/AccountOptions.java
rename to graphenej/src/main/java/cy/agorise/graphenej/AccountOptions.java
index 43c060e..3a58cab 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/AccountOptions.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/AccountOptions.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonArray;
@@ -12,8 +12,8 @@ import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
-import de.bitsharesmunich.graphenej.errors.MalformedAddressException;
-import de.bitsharesmunich.graphenej.interfaces.GrapheneSerializable;
+import cy.agorise.graphenej.errors.MalformedAddressException;
+import cy.agorise.graphenej.interfaces.GrapheneSerializable;
/**
* Created by nelson on 12/5/16.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Address.java b/graphenej/src/main/java/cy/agorise/graphenej/Address.java
similarity index 94%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Address.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Address.java
index b2c9ed0..0a60048 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Address.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Address.java
@@ -1,7 +1,7 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.common.primitives.Bytes;
-import de.bitsharesmunich.graphenej.errors.MalformedAddressException;
+import cy.agorise.graphenej.errors.MalformedAddressException;
import org.bitcoinj.core.Base58;
import org.bitcoinj.core.ECKey;
import org.spongycastle.crypto.digests.RIPEMD160Digest;
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Asset.java b/graphenej/src/main/java/cy/agorise/graphenej/Asset.java
similarity index 87%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Asset.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Asset.java
index 8ea2b77..880df66 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Asset.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Asset.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.common.primitives.UnsignedLong;
import com.google.gson.JsonDeserializationContext;
@@ -10,7 +10,7 @@ import com.google.gson.JsonParseException;
import java.lang.reflect.Type;
/**
- * Created by nelson on 11/9/16.
+ * Class used to represent a specific asset on the Graphene platform
*/
public class Asset extends GrapheneObject {
public final static String TAG = "Asset";
@@ -83,6 +83,22 @@ public class Asset extends GrapheneObject {
this.issuer = issuer;
}
+ /**
+ * Copy constructor
+ * @param asset Another asset instance
+ */
+ public Asset(Asset asset){
+ super(asset.getObjectId());
+ this.symbol = asset.getSymbol();
+ this.precision = asset.getPrecision();
+ this.issuer = asset.getIssuer();
+ this.description = asset.getDescription();
+ this.dynamic_asset_data_id = asset.getDynamicAssetDataId();
+ this.options = asset.getAssetOptions();
+ this.bitasset_data_id = asset.getBitassetId();
+ this.mAssetType = asset.getAssetType();
+ }
+
public String getSymbol(){
return this.symbol;
}
@@ -111,6 +127,14 @@ public class Asset extends GrapheneObject {
return description;
}
+ public String getDynamicAssetDataId() {
+ return dynamic_asset_data_id;
+ }
+
+ public void setDynamicAssetDataId(String dynamic_asset_data_id) {
+ this.dynamic_asset_data_id = dynamic_asset_data_id;
+ }
+
public void setAssetOptions(AssetOptions options){
this.options = options;
}
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/AssetAmount.java b/graphenej/src/main/java/cy/agorise/graphenej/AssetAmount.java
similarity index 80%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/AssetAmount.java
rename to graphenej/src/main/java/cy/agorise/graphenej/AssetAmount.java
index cd0ea49..6ac3a7a 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/AssetAmount.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/AssetAmount.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.common.math.DoubleMath;
import com.google.common.primitives.Bytes;
@@ -17,14 +17,15 @@ import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Type;
+import java.math.BigDecimal;
import java.math.RoundingMode;
-import de.bitsharesmunich.graphenej.errors.IncompatibleOperation;
-import de.bitsharesmunich.graphenej.interfaces.ByteSerializable;
-import de.bitsharesmunich.graphenej.interfaces.JsonSerializable;
+import cy.agorise.graphenej.errors.IncompatibleOperation;
+import cy.agorise.graphenej.interfaces.ByteSerializable;
+import cy.agorise.graphenej.interfaces.JsonSerializable;
/**
- * Created by nelson on 11/7/16.
+ * Class used to represent a specific amount of a certain asset
*/
public class AssetAmount implements ByteSerializable, JsonSerializable {
/**
@@ -36,11 +37,25 @@ public class AssetAmount implements ByteSerializable, JsonSerializable {
private UnsignedLong amount;
private Asset asset;
+ /**
+ * Class constructor
+ * @param amount The amount
+ * @param asset The asset
+ */
public AssetAmount(UnsignedLong amount, Asset asset){
this.amount = amount;
this.asset = asset;
}
+ /**
+ * Copy constructor
+ * @param assetAmount The other instance
+ */
+ public AssetAmount(AssetAmount assetAmount){
+ this.amount = UnsignedLong.valueOf(assetAmount.getAmount().toString());
+ this.asset = new Asset(assetAmount.getAsset());
+ }
+
/**
* Adds two asset amounts. They must refer to the same Asset type.
* @param other: The other AssetAmount to add to this.
@@ -91,8 +106,10 @@ public class AssetAmount implements ByteSerializable, JsonSerializable {
* @return The same AssetAmount instance, but with the changed amount value.
*/
public AssetAmount multiplyBy(double factor, RoundingMode roundingMode){
- this.amount = UnsignedLong.valueOf(DoubleMath.roundToLong(this.amount.longValue() * factor, roundingMode));
- return this;
+ BigDecimal originalAmount = new BigDecimal(amount.bigIntegerValue());
+ BigDecimal decimalResult = originalAmount.multiply(new BigDecimal(factor));
+ UnsignedLong resultingAmount = UnsignedLong.valueOf(DoubleMath.roundToBigInteger(decimalResult.doubleValue(), roundingMode));
+ return new AssetAmount(resultingAmount, new Asset(asset));
}
/**
@@ -110,9 +127,11 @@ public class AssetAmount implements ByteSerializable, JsonSerializable {
* @param divisor: The divisor
* @return: The same AssetAMount instance, but with the divided amount value
*/
- public AssetAmount dividedBy(double divisor, RoundingMode roundingMode){
- this.amount = UnsignedLong.valueOf(DoubleMath.roundToLong(this.amount.longValue() / divisor, roundingMode));
- return this;
+ public AssetAmount divideBy(double divisor, RoundingMode roundingMode){
+ BigDecimal originalAmount = new BigDecimal(amount.bigIntegerValue());
+ BigDecimal decimalAmount = originalAmount.divide(new BigDecimal(divisor), 18, RoundingMode.HALF_UP);
+ UnsignedLong resultingAmount = UnsignedLong.valueOf(DoubleMath.roundToBigInteger(decimalAmount.doubleValue(), roundingMode));
+ return new AssetAmount(resultingAmount, new Asset(asset));
}
@@ -122,8 +141,8 @@ public class AssetAmount implements ByteSerializable, JsonSerializable {
* @param divisor: The divisor
* @return: The same AssetAMount instance, but with the divided amount value
*/
- public AssetAmount dividedBy(double divisor){
- return this.dividedBy(divisor, RoundingMode.HALF_DOWN);
+ public AssetAmount divideBy(double divisor){
+ return this.divideBy(divisor, RoundingMode.HALF_DOWN);
}
public void setAmount(UnsignedLong amount){
@@ -136,6 +155,10 @@ public class AssetAmount implements ByteSerializable, JsonSerializable {
public Asset getAsset(){ return this.asset; }
+ public void setAsset(Asset asset){
+ this.asset = asset;
+ }
+
@Override
public byte[] toBytes() {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/AssetOptions.java b/graphenej/src/main/java/cy/agorise/graphenej/AssetOptions.java
similarity index 98%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/AssetOptions.java
rename to graphenej/src/main/java/cy/agorise/graphenej/AssetOptions.java
index 06fee0b..8ed4205 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/AssetOptions.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/AssetOptions.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.common.primitives.UnsignedLong;
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Authority.java b/graphenej/src/main/java/cy/agorise/graphenej/Authority.java
similarity index 98%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Authority.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Authority.java
index 3bd4dc2..7c2f02e 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Authority.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Authority.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonArray;
@@ -13,8 +13,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-import de.bitsharesmunich.graphenej.errors.MalformedAddressException;
-import de.bitsharesmunich.graphenej.interfaces.GrapheneSerializable;
+import cy.agorise.graphenej.errors.MalformedAddressException;
+import cy.agorise.graphenej.interfaces.GrapheneSerializable;
/**
* Class used to represent the weighted set of keys and accounts that must approve operations.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/AuthorityType.java b/graphenej/src/main/java/cy/agorise/graphenej/AuthorityType.java
similarity index 85%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/AuthorityType.java
rename to graphenej/src/main/java/cy/agorise/graphenej/AuthorityType.java
index ab0faa8..2fb52b8 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/AuthorityType.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/AuthorityType.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
/**
* Enum-type used to specify the different roles of an authority.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/BIP39.java b/graphenej/src/main/java/cy/agorise/graphenej/BIP39.java
similarity index 98%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/BIP39.java
rename to graphenej/src/main/java/cy/agorise/graphenej/BIP39.java
index ecb532d..fa882be 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/BIP39.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/BIP39.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import java.util.Arrays;
import org.bitcoinj.core.Base58;
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/BaseOperation.java b/graphenej/src/main/java/cy/agorise/graphenej/BaseOperation.java
similarity index 82%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/BaseOperation.java
rename to graphenej/src/main/java/cy/agorise/graphenej/BaseOperation.java
index 9a727cd..bafbea9 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/BaseOperation.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/BaseOperation.java
@@ -1,9 +1,9 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
-import de.bitsharesmunich.graphenej.interfaces.ByteSerializable;
-import de.bitsharesmunich.graphenej.interfaces.JsonSerializable;
+import cy.agorise.graphenej.interfaces.ByteSerializable;
+import cy.agorise.graphenej.interfaces.JsonSerializable;
/**
* Created by nelson on 11/5/16.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/BlockData.java b/graphenej/src/main/java/cy/agorise/graphenej/BlockData.java
similarity index 97%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/BlockData.java
rename to graphenej/src/main/java/cy/agorise/graphenej/BlockData.java
index 4a65917..d8457f5 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/BlockData.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/BlockData.java
@@ -1,6 +1,6 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
-import de.bitsharesmunich.graphenej.interfaces.ByteSerializable;
+import cy.agorise.graphenej.interfaces.ByteSerializable;
/**
* This class encapsulates all block-related information needed in order to build a valid transaction.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/BrainKey.java b/graphenej/src/main/java/cy/agorise/graphenej/BrainKey.java
similarity index 97%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/BrainKey.java
rename to graphenej/src/main/java/cy/agorise/graphenej/BrainKey.java
index 7812ee9..e54e3b7 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/BrainKey.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/BrainKey.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import org.bitcoinj.core.DumpedPrivateKey;
import org.bitcoinj.core.ECKey;
@@ -10,7 +10,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
-import de.bitsharesmunich.graphenej.crypto.SecureRandomGenerator;
+import cy.agorise.graphenej.crypto.SecureRandomGenerator;
/**
* Class used to encapsulate all BrainKey-related operations.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Chains.java b/graphenej/src/main/java/cy/agorise/graphenej/Chains.java
similarity index 93%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Chains.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Chains.java
index 775bbf2..c26a7e1 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Chains.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Chains.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
/**
* Created by nelson on 11/8/16.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Converter.java b/graphenej/src/main/java/cy/agorise/graphenej/Converter.java
similarity index 97%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Converter.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Converter.java
index 257c422..f0706f6 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Converter.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Converter.java
@@ -1,10 +1,10 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import java.math.BigDecimal;
import java.math.MathContext;
-import de.bitsharesmunich.graphenej.errors.IncompleteAssetError;
-import de.bitsharesmunich.graphenej.models.BucketObject;
+import cy.agorise.graphenej.errors.IncompleteAssetError;
+import cy.agorise.graphenej.models.BucketObject;
/**
* Generic converter class used to translate the market information contained in a BucketObject and/or Price instances.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Extensions.java b/graphenej/src/main/java/cy/agorise/graphenej/Extensions.java
similarity index 83%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Extensions.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Extensions.java
index 1848855..ada71a3 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Extensions.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Extensions.java
@@ -1,9 +1,9 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
-import de.bitsharesmunich.graphenej.interfaces.ByteSerializable;
-import de.bitsharesmunich.graphenej.interfaces.JsonSerializable;
+import cy.agorise.graphenej.interfaces.ByteSerializable;
+import cy.agorise.graphenej.interfaces.JsonSerializable;
import java.util.ArrayList;
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/FileBin.java b/graphenej/src/main/java/cy/agorise/graphenej/FileBin.java
similarity index 98%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/FileBin.java
rename to graphenej/src/main/java/cy/agorise/graphenej/FileBin.java
index 703102f..0eb0711 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/FileBin.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/FileBin.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
@@ -13,8 +13,8 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
-import de.bitsharesmunich.graphenej.crypto.SecureRandomStrengthener;
-import de.bitsharesmunich.graphenej.models.backup.WalletBackup;
+import cy.agorise.graphenej.crypto.SecureRandomStrengthener;
+import cy.agorise.graphenej.models.backup.WalletBackup;
/**
* Class to manage the backup files
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/GrapheneObject.java b/graphenej/src/main/java/cy/agorise/graphenej/GrapheneObject.java
similarity index 99%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/GrapheneObject.java
rename to graphenej/src/main/java/cy/agorise/graphenej/GrapheneObject.java
index aaee8b5..072355b 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/GrapheneObject.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/GrapheneObject.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.gson.annotations.Expose;
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Invoice.java b/graphenej/src/main/java/cy/agorise/graphenej/Invoice.java
similarity index 96%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Invoice.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Invoice.java
index cdd7364..7b1dc37 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Invoice.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Invoice.java
@@ -1,11 +1,11 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import org.bitcoinj.core.Base58;
-import de.bitsharesmunich.graphenej.interfaces.JsonSerializable;
+import cy.agorise.graphenej.interfaces.JsonSerializable;
/**
* Class used to handle invoice generation, compression and QR-Code data derivation,
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/LimitOrder.java b/graphenej/src/main/java/cy/agorise/graphenej/LimitOrder.java
similarity index 92%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/LimitOrder.java
rename to graphenej/src/main/java/cy/agorise/graphenej/LimitOrder.java
index 77d5d7c..50a5c33 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/LimitOrder.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/LimitOrder.java
@@ -1,5 +1,6 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
+import com.google.common.primitives.UnsignedLong;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
@@ -12,7 +13,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Type;
-import de.bitsharesmunich.graphenej.interfaces.ByteSerializable;
+import cy.agorise.graphenej.interfaces.ByteSerializable;
/**
*
@@ -28,7 +29,7 @@ public class LimitOrder extends GrapheneObject implements ByteSerializable {
private String expiration;
private UserAccount seller;
- private long forSale;
+ private UnsignedLong forSale;
private long deferredFee;
private Price sellPrice;
@@ -52,11 +53,11 @@ public class LimitOrder extends GrapheneObject implements ByteSerializable {
this.seller = seller;
}
- public long getForSale() {
+ public UnsignedLong getForSale() {
return forSale;
}
- public void setForSale(long forSale) {
+ public void setForSale(UnsignedLong forSale) {
this.forSale = forSale;
}
@@ -127,7 +128,7 @@ public class LimitOrder extends GrapheneObject implements ByteSerializable {
LimitOrder limitOrder = new LimitOrder(id);
limitOrder.setExpiration(expiration);
limitOrder.setSeller(seller);
- limitOrder.setForSale(Long.parseLong(forSale));
+ limitOrder.setForSale(UnsignedLong.valueOf(forSale));
limitOrder.setSellPrice(price);
limitOrder.setDeferredFee(deferredFee);
return limitOrder;
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/LineItem.java b/graphenej/src/main/java/cy/agorise/graphenej/LineItem.java
similarity index 95%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/LineItem.java
rename to graphenej/src/main/java/cy/agorise/graphenej/LineItem.java
index 9b58fdb..7442ca9 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/LineItem.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/LineItem.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
/**
* Created by nelson on 1/11/17.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/MarketTrade.java b/graphenej/src/main/java/cy/agorise/graphenej/MarketTrade.java
similarity index 80%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/MarketTrade.java
rename to graphenej/src/main/java/cy/agorise/graphenej/MarketTrade.java
index c5aa841..a97220e 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/MarketTrade.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/MarketTrade.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
/**
*
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/ObjectType.java b/graphenej/src/main/java/cy/agorise/graphenej/ObjectType.java
similarity index 99%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/ObjectType.java
rename to graphenej/src/main/java/cy/agorise/graphenej/ObjectType.java
index 537eaf1..ee1ce37 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/ObjectType.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/ObjectType.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
/**
* Enum type used to list all possible object types and obtain their space + type id
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/OperationType.java b/graphenej/src/main/java/cy/agorise/graphenej/OperationType.java
similarity index 97%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/OperationType.java
rename to graphenej/src/main/java/cy/agorise/graphenej/OperationType.java
index 36d9f52..9ea093d 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/OperationType.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/OperationType.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
/**
* Enum type used to keep track of all the operation types and their corresponding ids.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Optional.java b/graphenej/src/main/java/cy/agorise/graphenej/Optional.java
similarity index 87%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Optional.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Optional.java
index 8f48c5e..c32c83a 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Optional.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Optional.java
@@ -1,9 +1,9 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.gson.JsonElement;
-import de.bitsharesmunich.graphenej.interfaces.ByteSerializable;
-import de.bitsharesmunich.graphenej.interfaces.GrapheneSerializable;
+import cy.agorise.graphenej.interfaces.ByteSerializable;
+import cy.agorise.graphenej.interfaces.GrapheneSerializable;
/**
* Container template class used whenever we have an optional field.
diff --git a/graphenej/src/main/java/cy/agorise/graphenej/OrderBook.java b/graphenej/src/main/java/cy/agorise/graphenej/OrderBook.java
new file mode 100644
index 0000000..f383a08
--- /dev/null
+++ b/graphenej/src/main/java/cy/agorise/graphenej/OrderBook.java
@@ -0,0 +1,135 @@
+package cy.agorise.graphenej;
+
+import com.google.common.primitives.UnsignedLong;
+
+import java.util.List;
+
+import cy.agorise.graphenej.operations.LimitOrderCreateOperation;
+
+/**
+ * This class will maintain a snapshot of the order book between two assets.
+ *
+ * It also provides a handy method that should return the appropriate LimitOrderCreateOperation
+ * object needed in case the user wants to perform market-priced operations.
+ *
+ * It is important to keep the order book updated, ideally by listening to blockchain events,
+ * and calling the 'update' method.
+ *
+ */
+public class OrderBook {
+ private List limitOrders;
+
+ public OrderBook(List limitOrders){
+ this.limitOrders = limitOrders;
+ }
+
+ /**
+ * Replaces the current limit order by the list provided as parameter.
+ * @param limitOrders: New list of orders
+ */
+ public void update(List limitOrders){
+ this.limitOrders = limitOrders;
+ }
+
+ public void update(LimitOrder limitOrder){
+ //TODO: Implement the method that will update a single limit order from the order book
+ }
+
+ /**
+ * High level method used to exchange a specific amount of an asset (The base) for another
+ * one (The quote) at market value.
+ *
+ * It should analyze the order book and figure out the optimal amount of the base asset to give
+ * away in order to obtain the desired amount of the quote asset.
+ *
+ * @param seller: User account of the seller, used to build the limit order create operation
+ * @param myBaseAsset: The asset the user is willing to give away
+ * @param myQuoteAmount: The amount of a given asset the user wants
+ * @param expiration: The expiration time of the limit order
+ *
+ * @return An instance of the LimitOrderCreateOperation class, which is ready to be broadcasted.
+ */
+ public LimitOrderCreateOperation exchange(UserAccount seller, Asset myBaseAsset, AssetAmount myQuoteAmount, int expiration){
+ AssetAmount toSell = new AssetAmount(calculateRequiredBase(myQuoteAmount), myBaseAsset);
+ AssetAmount toReceive = myQuoteAmount;
+ LimitOrderCreateOperation buyOrder = new LimitOrderCreateOperation(seller, toSell, toReceive, expiration, true);
+
+ return buyOrder;
+ }
+
+ public LimitOrderCreateOperation exchange(UserAccount seller, AssetAmount baseAmount, Asset quoteAsset, int expiration){
+ AssetAmount minToReceive = new AssetAmount(calculateObtainedQuote(baseAmount), quoteAsset);
+ return new LimitOrderCreateOperation(seller, baseAmount, minToReceive, expiration, true);
+ }
+
+ /**
+ * Method that calculates the amount of an asset that we will obtain (the quote amount) if we trade
+ * a known fixed amount of the asset we already have (the base amount).
+ *
+ * @param baseAmount The fixed amount of the asset we have and want to sell
+ * @return The equivalent amount to receive in exchange of the base amount
+ */
+ public UnsignedLong calculateObtainedQuote(AssetAmount baseAmount){
+ UnsignedLong myBase = baseAmount.getAmount();
+ UnsignedLong obtainedQuote = UnsignedLong.ZERO;
+ for(int i = 0; i < limitOrders.size() && myBase.compareTo(UnsignedLong.ZERO) > 0; i++){
+ LimitOrder order = limitOrders.get(i);
+
+ // Checking to make sure the order matches our needs
+ if(order.getSellPrice().quote.getAsset().equals(baseAmount.getAsset())){
+ UnsignedLong orderBase = order.getSellPrice().base.getAmount();
+ UnsignedLong orderQuote = order.getSellPrice().quote.getAmount();
+ UnsignedLong availableBase = order.getForSale();
+
+ UnsignedLong myQuote = UnsignedLong.valueOf((long)(myBase.times(orderBase).doubleValue() / (orderQuote.doubleValue())));
+ if(myQuote.compareTo(availableBase) > 0){
+ // We consume this order entirely
+ // myBase = myBase - (for_sale) * (order_quote / order_base)
+ myBase = myBase.minus(availableBase.times(orderQuote).dividedBy(orderBase));
+ // We need more than this order can offer us, but have to take in consideration how much there really is.
+ // (order base / order quote) x (available order base / order base)
+ UnsignedLong thisBatch = UnsignedLong.valueOf((long)(orderBase.times(availableBase).doubleValue() / orderQuote.times(orderBase).doubleValue()));
+ obtainedQuote = obtainedQuote.plus(thisBatch);
+ }else{
+ // This order consumes all our base asset
+ // obtained_quote = obtained_quote + (my base * order_base / order_quote)
+ obtainedQuote = obtainedQuote.plus(myBase.times(orderBase).dividedBy(orderQuote));
+ myBase = UnsignedLong.ZERO;
+ }
+ }
+ }
+ return obtainedQuote;
+ }
+
+ /**
+ * Method that calculates the amount of an asset that we will consume (the base amount) if we want to obtain
+ * a known fixed amount of another asset (the quote amount).
+ * @param quoteAmount The fixed amount of an asset that we want to obtain
+ * @return The amount of an asset we already have that will be consumed by the trade
+ */
+ public UnsignedLong calculateRequiredBase(AssetAmount quoteAmount){
+ UnsignedLong myQuote = quoteAmount.getAmount();
+ UnsignedLong obtainedBase = UnsignedLong.ZERO;
+ for(int i = 0; i < limitOrders.size() && myQuote.compareTo(UnsignedLong.ZERO) > 0; i++){
+ LimitOrder order = limitOrders.get(i);
+
+ // Checking to make sure the order matches our needs
+ if(order.getSellPrice().base.getAsset().equals(quoteAmount.getAsset())){
+ UnsignedLong orderBase = order.getSellPrice().base.getAmount();
+ UnsignedLong orderQuote = order.getSellPrice().quote.getAmount();
+ UnsignedLong forSale = order.getForSale();
+
+ if(forSale.compareTo(myQuote) > 0){
+ // Found an order that fills our requirements
+ obtainedBase = obtainedBase.plus(UnsignedLong.valueOf((long) (myQuote.doubleValue() * orderQuote.doubleValue() / orderBase.doubleValue())));
+ myQuote = UnsignedLong.ZERO;
+ }else{
+ // Found an order that partially fills our needs
+ obtainedBase = obtainedBase.plus(UnsignedLong.valueOf((long) (forSale.doubleValue() * orderQuote.doubleValue() / orderBase.doubleValue())));
+ myQuote = myQuote.minus(forSale);
+ }
+ }
+ }
+ return obtainedBase;
+ }
+}
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Price.java b/graphenej/src/main/java/cy/agorise/graphenej/Price.java
similarity index 77%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Price.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Price.java
index 78e6948..f45c56c 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Price.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Price.java
@@ -1,11 +1,4 @@
-package de.bitsharesmunich.graphenej;
-
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-
-import java.lang.reflect.Type;
+package cy.agorise.graphenej;
/**
* The price struct stores asset prices in the Graphene system.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/PublicKey.java b/graphenej/src/main/java/cy/agorise/graphenej/PublicKey.java
similarity index 92%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/PublicKey.java
rename to graphenej/src/main/java/cy/agorise/graphenej/PublicKey.java
index 5b9e7eb..f20f648 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/PublicKey.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/PublicKey.java
@@ -1,11 +1,11 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import org.bitcoinj.core.ECKey;
import org.spongycastle.math.ec.ECPoint;
import java.io.Serializable;
-import de.bitsharesmunich.graphenej.interfaces.ByteSerializable;
+import cy.agorise.graphenej.interfaces.ByteSerializable;
/**
* Created by nelson on 11/30/16.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/RPC.java b/graphenej/src/main/java/cy/agorise/graphenej/RPC.java
similarity index 95%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/RPC.java
rename to graphenej/src/main/java/cy/agorise/graphenej/RPC.java
index 2375925..ea6c509 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/RPC.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/RPC.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
/**
* Created by nelson on 11/16/16.
@@ -25,6 +25,7 @@ public class RPC {
public static final String GET_ACCOUNT_BALANCES = "get_account_balances";
public static final String CALL_LOOKUP_ASSET_SYMBOLS = "lookup_asset_symbols";
public static final String CALL_GET_BLOCK_HEADER = "get_block_header";
+ public static final String CALL_GET_BLOCK = "get_block";
public static final String CALL_GET_LIMIT_ORDERS = "get_limit_orders";
public static final String CALL_GET_TRADE_HISTORY = "get_trade_history";
public static final String CALL_GET_MARKET_HISTORY = "get_market_history";
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Transaction.java b/graphenej/src/main/java/cy/agorise/graphenej/Transaction.java
similarity index 89%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Transaction.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Transaction.java
index 9c8ca5b..acf5412 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Transaction.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Transaction.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.common.primitives.Bytes;
import com.google.gson.GsonBuilder;
@@ -24,10 +24,11 @@ import java.util.Date;
import java.util.List;
import java.util.TimeZone;
-import de.bitsharesmunich.graphenej.interfaces.ByteSerializable;
-import de.bitsharesmunich.graphenej.interfaces.JsonSerializable;
-import de.bitsharesmunich.graphenej.operations.LimitOrderCreateOperation;
-import de.bitsharesmunich.graphenej.operations.TransferOperation;
+import cy.agorise.graphenej.interfaces.ByteSerializable;
+import cy.agorise.graphenej.interfaces.JsonSerializable;
+import cy.agorise.graphenej.operations.CustomOperation;
+import cy.agorise.graphenej.operations.LimitOrderCreateOperation;
+import cy.agorise.graphenej.operations.TransferOperation;
/**
* Class used to represent a generic Graphene transaction.
@@ -45,29 +46,43 @@ public class Transaction implements ByteSerializable, JsonSerializable {
public static final String KEY_REF_BLOCK_NUM = "ref_block_num";
public static final String KEY_REF_BLOCK_PREFIX = "ref_block_prefix";
+ // Using the bitshares mainnet chain id by default
+ private byte[] chainId = Util.hexToBytes(Chains.BITSHARES.CHAIN_ID);
private ECKey privateKey;
private BlockData blockData;
private List operations;
private Extensions extensions;
/**
- * Transaction constructor.
- * @param privateKey : Instance of a ECKey containing the private key that will be used to sign this transaction.
- * @param blockData : Block data containing important information used to sign a transaction.
- * @param operationList : List of operations to include in the transaction.
+ * Transaction constructor
+ * @param chainId The chain id
+ * @param privateKey Private key used to sign this transaction
+ * @param blockData Block data
+ * @param operations List of operations contained in this transaction
*/
- public Transaction(ECKey privateKey, BlockData blockData, List operationList){
+ public Transaction(byte[] chainId, ECKey privateKey, BlockData blockData, List operations){
+ this.chainId = chainId;
this.privateKey = privateKey;
this.blockData = blockData;
- this.operations = operationList;
+ this.operations = operations;
this.extensions = new Extensions();
}
/**
* Transaction constructor.
- * @param wif: The user's private key in the base58 format.
- * @param block_data: Block data containing important information used to sign a transaction.
- * @param operation_list: List of operations to include in the transaction.
+ * @param privateKey Instance of a ECKey containing the private key that will be used to sign this transaction.
+ * @param blockData Block data containing important information used to sign a transaction.
+ * @param operationList List of operations to include in the transaction.
+ */
+ public Transaction(ECKey privateKey, BlockData blockData, List operationList){
+ this(Util.hexToBytes(Chains.BITSHARES.CHAIN_ID), privateKey, blockData, operationList);
+ }
+
+ /**
+ * Transaction constructor.
+ * @param wif The user's private key in the base58 format.
+ * @param block_data Block data containing important information used to sign a transaction.
+ * @param operation_list List of operations to include in the transaction.
*/
public Transaction(String wif, BlockData block_data, List operation_list){
this(DumpedPrivateKey.fromBase58(null, wif).getKey(), block_data, operation_list);
@@ -76,8 +91,8 @@ public class Transaction implements ByteSerializable, JsonSerializable {
/**
* Constructor used to build a Transaction object without a private key. This kind of object
* is used to represent a transaction data that we don't intend to serialize and sign.
- * @param blockData: Block data instance, containing information about the location of this transaction in the blockchain.
- * @param operationList: The list of operations included in this transaction.
+ * @param blockData Block data instance, containing information about the location of this transaction in the blockchain.
+ * @param operationList The list of operations included in this transaction.
*/
public Transaction(BlockData blockData, List operationList){
this.blockData = blockData;
@@ -86,7 +101,7 @@ public class Transaction implements ByteSerializable, JsonSerializable {
/**
* Updates the block data
- * @param blockData: New block data
+ * @param blockData New block data
*/
public void setBlockData(BlockData blockData){
this.blockData = blockData;
@@ -161,6 +176,18 @@ public class Transaction implements ByteSerializable, JsonSerializable {
return sigData;
}
+ public void setChainId(String chainId){
+ this.chainId = Util.hexToBytes(chainId);
+ }
+
+ public void setChainId(byte[] chainId){
+ this.chainId = chainId;
+ }
+
+ public byte[] getChainId(){
+ return this.chainId;
+ }
+
/**
* Method that creates a serialized byte array with compact information about this transaction
* that is needed for the creation of a signature.
@@ -169,7 +196,7 @@ public class Transaction implements ByteSerializable, JsonSerializable {
public byte[] toBytes(){
// Creating a List of Bytes and adding the first bytes from the chain apiId
List byteArray = new ArrayList();
- byteArray.addAll(Bytes.asList(Util.hexToBytes(Chains.BITSHARES.CHAIN_ID)));
+ byteArray.addAll(Bytes.asList(chainId));
// Adding the block data
byteArray.addAll(Bytes.asList(this.blockData.toBytes()));
@@ -343,7 +370,7 @@ public class Transaction implements ByteSerializable, JsonSerializable {
} else if (operationId == OperationType.WORKER_CREATE_OPERATION.ordinal()) {
//TODO: Add operation deserialization support
} else if (operationId == OperationType.CUSTOM_OPERATION.ordinal()) {
- //TODO: Add operation deserialization support
+ operation = context.deserialize(jsonOperation, CustomOperation.class);
} else if (operationId == OperationType.ASSERT_OPERATION.ordinal()) {
//TODO: Add operation deserialization support
} else if (operationId == OperationType.BALANCE_CLAIM_OPERATION.ordinal()) {
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/UserAccount.java b/graphenej/src/main/java/cy/agorise/graphenej/UserAccount.java
similarity index 98%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/UserAccount.java
rename to graphenej/src/main/java/cy/agorise/graphenej/UserAccount.java
index 4ad4b12..dee9197 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/UserAccount.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/UserAccount.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -19,8 +19,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
-import de.bitsharesmunich.graphenej.interfaces.ByteSerializable;
-import de.bitsharesmunich.graphenej.interfaces.JsonSerializable;
+import cy.agorise.graphenej.interfaces.ByteSerializable;
+import cy.agorise.graphenej.interfaces.JsonSerializable;
/**
* Class that represents a graphene user account.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Util.java b/graphenej/src/main/java/cy/agorise/graphenej/Util.java
similarity index 91%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Util.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Util.java
index 98fd493..4f80a85 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Util.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Util.java
@@ -1,7 +1,22 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import com.google.common.primitives.Bytes;
-import org.tukaani.xz.*;
+import com.google.common.primitives.UnsignedLong;
+
+import org.spongycastle.crypto.DataLengthException;
+import org.spongycastle.crypto.InvalidCipherTextException;
+import org.spongycastle.crypto.engines.AESFastEngine;
+import org.spongycastle.crypto.modes.CBCBlockCipher;
+import org.spongycastle.crypto.paddings.PaddedBufferedBlockCipher;
+import org.spongycastle.crypto.params.KeyParameter;
+import org.spongycastle.crypto.params.ParametersWithIV;
+import org.tukaani.xz.CorruptedInputException;
+import org.tukaani.xz.FinishableOutputStream;
+import org.tukaani.xz.LZMA2Options;
+import org.tukaani.xz.LZMAInputStream;
+import org.tukaani.xz.LZMAOutputStream;
+import org.tukaani.xz.XZInputStream;
+import org.tukaani.xz.XZOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -11,15 +26,10 @@ import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.spongycastle.crypto.DataLengthException;
-import org.spongycastle.crypto.InvalidCipherTextException;
-import org.spongycastle.crypto.engines.AESFastEngine;
-import org.spongycastle.crypto.modes.CBCBlockCipher;
-import org.spongycastle.crypto.paddings.PaddedBufferedBlockCipher;
-import org.spongycastle.crypto.params.KeyParameter;
-import org.spongycastle.crypto.params.ParametersWithIV;
/**
* Class used to encapsulate common utility methods
@@ -84,6 +94,26 @@ public class Util {
return buffer.array();
}
+ /**
+ * Serializes long value to a byte array.
+ * @param data Long value.
+ * @return Array of bytes.
+ */
+ public static byte[] serializeLongToBytes(long data) {
+ List bytes = new LinkedList<>();
+ long value = data;
+ do {
+ byte b = (byte)(value & 0x7F);
+ value >>= 7;
+ if (value != 0) {
+ b |= 0x80;
+ }
+ bytes.add(b);
+ } while (value != 0);
+
+ return Bytes.toArray(bytes);
+ }
+
/**
* Utility function that compresses data using the LZMA algorithm.
* @param inputBytes Input bytes of the data to be compressed.
@@ -210,6 +240,15 @@ public class Util {
return ByteBuffer.allocate(Long.SIZE / 8).putLong(Long.reverseBytes(input)).array();
}
+ /**
+ * Same operation as in the revertInteger function, but with an UnsignedLong object as argument.
+ * @param input An UnsignedLong class instance
+ * @return The array of bytes that represent this value in the reverse format.
+ */
+ public static byte[] revertUnsignedLong(UnsignedLong input){
+ return ByteBuffer.allocate(Long.SIZE / 8).putLong(Long.reverseBytes(input.longValue())).array();
+ }
+
public static byte[] revertBytes(byte[] array){
byte[] reverted = new byte[array.length];
for(int i = 0; i < reverted.length; i++){
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Varint.java b/graphenej/src/main/java/cy/agorise/graphenej/Varint.java
similarity index 99%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Varint.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Varint.java
index c06e05a..0206fdc 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Varint.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Varint.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
import java.io.DataInput;
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Vote.java b/graphenej/src/main/java/cy/agorise/graphenej/Vote.java
similarity index 87%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/Vote.java
rename to graphenej/src/main/java/cy/agorise/graphenej/Vote.java
index 7c50a90..cd22b71 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Vote.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/Vote.java
@@ -1,6 +1,6 @@
-package de.bitsharesmunich.graphenej;
+package cy.agorise.graphenej;
-import de.bitsharesmunich.graphenej.interfaces.ByteSerializable;
+import cy.agorise.graphenej.interfaces.ByteSerializable;
/**
* Created by nelson on 12/5/16.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/BaseGrapheneHandler.java b/graphenej/src/main/java/cy/agorise/graphenej/api/BaseGrapheneHandler.java
similarity index 90%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/BaseGrapheneHandler.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/BaseGrapheneHandler.java
index 80d7e2b..9a203b6 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/BaseGrapheneHandler.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/BaseGrapheneHandler.java
@@ -1,14 +1,12 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.neovisionaries.ws.client.WebSocket;
import com.neovisionaries.ws.client.WebSocketAdapter;
import com.neovisionaries.ws.client.WebSocketException;
-import org.w3c.dom.Node;
-
-import de.bitsharesmunich.graphenej.interfaces.NodeErrorListener;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.BaseResponse;
+import cy.agorise.graphenej.interfaces.NodeErrorListener;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.BaseResponse;
/**
* Base class that should be extended by any implementation of a specific request to the full node.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountBalances.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetAccountBalances.java
similarity index 87%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountBalances.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetAccountBalances.java
index 41f6287..5d65de3 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountBalances.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetAccountBalances.java
@@ -1,16 +1,9 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.neovisionaries.ws.client.WebSocket;
import com.neovisionaries.ws.client.WebSocketFrame;
-import de.bitsharesmunich.graphenej.Asset;
-import de.bitsharesmunich.graphenej.AssetAmount;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.UserAccount;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
import java.io.Serializable;
import java.lang.reflect.Type;
@@ -18,6 +11,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import cy.agorise.graphenej.Asset;
+import cy.agorise.graphenej.AssetAmount;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.UserAccount;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.WitnessResponse;
+
/**
* Class that implements get_account_balances request handler.
*
@@ -71,12 +72,14 @@ public class GetAccountBalances extends BaseGrapheneHandler {
public void onConnected(WebSocket websocket, Map> headers) throws Exception {
ArrayList params = new ArrayList<>();
ArrayList assetList = new ArrayList<>();
- for(Asset asset : mAssetList){
- assetList.add(asset.getObjectId());
+ if(mAssetList != null){
+ for(Asset asset : mAssetList){
+ assetList.add(asset.getObjectId());
+ }
}
params.add(mUserAccount.getObjectId());
params.add(assetList);
- ApiCall apiCall = new ApiCall(0, RPC.GET_ACCOUNT_BALANCES, params, RPC.VERSION, 0);
+ ApiCall apiCall = new ApiCall(0, RPC.GET_ACCOUNT_BALANCES, params, RPC.VERSION, requestId);
websocket.sendText(apiCall.toJsonString());
}
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountByName.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetAccountByName.java
similarity index 89%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountByName.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetAccountByName.java
index d11634f..f2f38f0 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountByName.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetAccountByName.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
@@ -11,13 +11,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.AccountOptions;
-import de.bitsharesmunich.graphenej.Authority;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.AccountProperties;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.AccountOptions;
+import cy.agorise.graphenej.Authority;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.AccountProperties;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.WitnessResponse;
/**
* Class that implements get_account_by_name request handler.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountHistory.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetAccountHistory.java
similarity index 82%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountHistory.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetAccountHistory.java
index 061cedc..76549a2 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountHistory.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetAccountHistory.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
/**
* Created by nelson on 12/26/16.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccounts.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetAccounts.java
similarity index 91%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccounts.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetAccounts.java
index 9350ee5..50f38e7 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccounts.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetAccounts.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
@@ -11,14 +11,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.AccountOptions;
-import de.bitsharesmunich.graphenej.Authority;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.UserAccount;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.AccountProperties;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.AccountOptions;
+import cy.agorise.graphenej.Authority;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.UserAccount;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.AccountProperties;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.WitnessResponse;
/**
* Class that implements get_accounts request handler.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAllAssetHolders.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetAllAssetHolders.java
similarity index 95%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAllAssetHolders.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetAllAssetHolders.java
index 4147bc5..110aefb 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAllAssetHolders.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetAllAssetHolders.java
@@ -1,13 +1,13 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.neovisionaries.ws.client.WebSocket;
import com.neovisionaries.ws.client.WebSocketFrame;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.*;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.*;
import java.io.Serializable;
import java.lang.reflect.Type;
diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/GetBlock.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetBlock.java
new file mode 100644
index 0000000..7d3e882
--- /dev/null
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetBlock.java
@@ -0,0 +1,112 @@
+package cy.agorise.graphenej.api;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+import com.neovisionaries.ws.client.WebSocket;
+import com.neovisionaries.ws.client.WebSocketFrame;
+import cy.agorise.graphenej.AssetAmount;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.Transaction;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.BaseResponse;
+import cy.agorise.graphenej.models.Block;
+import cy.agorise.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.operations.CustomOperation;
+import cy.agorise.graphenej.operations.LimitOrderCreateOperation;
+import cy.agorise.graphenej.operations.TransferOperation;
+
+import java.io.Serializable;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class GetBlock extends BaseGrapheneHandler {
+
+ private final static int LOGIN_ID = 1;
+ private final static int GET_DATABASE_ID = 2;
+ private final static int GET_BLOCK_ID = 3;
+
+ private long blockNumber;
+ private WitnessResponseListener mListener;
+
+ private int currentId = LOGIN_ID;
+
+ private boolean mOneTime;
+
+ public GetBlock(long blockNumber, boolean oneTime, WitnessResponseListener listener){
+ super(listener);
+ this.blockNumber = blockNumber;
+ this.mOneTime = oneTime;
+ this.mListener = listener;
+ }
+
+ public GetBlock(long blockNumber, WitnessResponseListener listener){
+ this(blockNumber, true, listener);
+ }
+
+ @Override
+ public void onConnected(WebSocket websocket, Map> headers) throws Exception {
+ ArrayList loginParams = new ArrayList<>();
+ loginParams.add(null);
+ loginParams.add(null);
+ ApiCall loginCall = new ApiCall(1, RPC.CALL_LOGIN, loginParams, RPC.VERSION, currentId);
+ websocket.sendText(loginCall.toJsonString());
+ }
+
+ @Override
+ public void onTextFrame(WebSocket websocket, WebSocketFrame frame) throws Exception {
+ String response = frame.getPayloadText();
+ System.out.println("<<< "+response);
+
+ Gson gson = new Gson();
+ BaseResponse baseResponse = gson.fromJson(response, BaseResponse.class);
+ if(baseResponse.error != null){
+ mListener.onError(baseResponse.error);
+ if(mOneTime){
+ websocket.disconnect();
+ }
+ } else {
+ currentId++;
+ ArrayList emptyParams = new ArrayList<>();
+ if (baseResponse.id == LOGIN_ID) {
+ ApiCall getDatabaseId = new ApiCall(1, RPC.CALL_DATABASE, emptyParams, RPC.VERSION, currentId);
+ websocket.sendText(getDatabaseId.toJsonString());
+ } else if (baseResponse.id == GET_DATABASE_ID) {
+ Type ApiIdResponse = new TypeToken>() {}.getType();
+ WitnessResponse witnessResponse = gson.fromJson(response, ApiIdResponse);
+ Integer apiId = witnessResponse.result;
+
+ ArrayList params = new ArrayList<>();
+ String blockNum = String.format("%d", this.blockNumber);
+ params.add(blockNum);
+
+ ApiCall loginCall = new ApiCall(apiId, RPC.CALL_GET_BLOCK, params, RPC.VERSION, currentId);
+ websocket.sendText(loginCall.toJsonString());
+ } else if (baseResponse.id == GET_BLOCK_ID) {
+ Type BlockResponse = new TypeToken>(){}.getType();
+ gson = new GsonBuilder()
+ .registerTypeAdapter(Transaction.class, new Transaction.TransactionDeserializer())
+ .registerTypeAdapter(TransferOperation.class, new TransferOperation.TransferDeserializer())
+ .registerTypeAdapter(LimitOrderCreateOperation.class, new LimitOrderCreateOperation.LimitOrderCreateDeserializer())
+ .registerTypeAdapter(CustomOperation.class, new CustomOperation.CustomOperationDeserializer())
+ .registerTypeAdapter(AssetAmount.class, new AssetAmount.AssetAmountDeserializer())
+ .create();
+ WitnessResponse blockResponse = gson.fromJson(response, BlockResponse);
+ mListener.onSuccess(blockResponse);
+ if (mOneTime) {
+ websocket.disconnect();
+ }
+ }
+ }
+
+ }
+
+ @Override
+ public void onFrameSent(WebSocket websocket, WebSocketFrame frame) throws Exception {
+ if(frame.isTextFrame())
+ System.out.println(">>> "+frame.getPayloadText());
+ }
+}
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetBlockHeader.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetBlockHeader.java
similarity index 92%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetBlockHeader.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetBlockHeader.java
index cb59103..d373b83 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetBlockHeader.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetBlockHeader.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@@ -11,12 +11,12 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.BaseResponse;
-import de.bitsharesmunich.graphenej.models.BlockHeader;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.BaseResponse;
+import cy.agorise.graphenej.models.BlockHeader;
+import cy.agorise.graphenej.models.WitnessResponse;
/**
* Class that implements get_block_header request handler.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetKeyReferences.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetKeyReferences.java
similarity index 93%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetKeyReferences.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetKeyReferences.java
index 576d6a6..aa2266e 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetKeyReferences.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetKeyReferences.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
@@ -11,12 +11,12 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.Address;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.UserAccount;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.Address;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.UserAccount;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.WitnessResponse;
/**
* Class that implements get_key_references request handler.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetLimitOrders.java
similarity index 91%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetLimitOrders.java
index 3327ff7..ea67512 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetLimitOrders.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
@@ -12,14 +12,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.AssetAmount;
-import de.bitsharesmunich.graphenej.LimitOrder;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.UserAccount;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.BaseResponse;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.AssetAmount;
+import cy.agorise.graphenej.LimitOrder;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.UserAccount;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.BaseResponse;
+import cy.agorise.graphenej.models.WitnessResponse;
/**
* Class that implements get_limit_orders request handler.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetMarketHistory.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetMarketHistory.java
similarity index 95%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetMarketHistory.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetMarketHistory.java
index 06e2a7f..488486a 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetMarketHistory.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetMarketHistory.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -14,13 +14,13 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.Asset;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.BaseResponse;
-import de.bitsharesmunich.graphenej.models.BucketObject;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.Asset;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.BaseResponse;
+import cy.agorise.graphenej.models.BucketObject;
+import cy.agorise.graphenej.models.WitnessResponse;
/**
* Class that implements get_market_history request handler.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetObjects.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetObjects.java
similarity index 89%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetObjects.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetObjects.java
index 9c34966..ab65206 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetObjects.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetObjects.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -15,17 +15,17 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.AccountOptions;
-import de.bitsharesmunich.graphenej.Asset;
-import de.bitsharesmunich.graphenej.AssetAmount;
-import de.bitsharesmunich.graphenej.Authority;
-import de.bitsharesmunich.graphenej.GrapheneObject;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.UserAccount;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.BitAssetData;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.AccountOptions;
+import cy.agorise.graphenej.Asset;
+import cy.agorise.graphenej.AssetAmount;
+import cy.agorise.graphenej.Authority;
+import cy.agorise.graphenej.GrapheneObject;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.UserAccount;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.BitAssetData;
+import cy.agorise.graphenej.models.WitnessResponse;
/**
*
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRelativeAccountHistory.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetRelativeAccountHistory.java
similarity index 93%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRelativeAccountHistory.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetRelativeAccountHistory.java
index 32da128..935618f 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRelativeAccountHistory.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetRelativeAccountHistory.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -12,16 +12,16 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.AssetAmount;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.UserAccount;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.BaseResponse;
-import de.bitsharesmunich.graphenej.models.HistoricalTransfer;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
-import de.bitsharesmunich.graphenej.objects.Memo;
-import de.bitsharesmunich.graphenej.operations.TransferOperation;
+import cy.agorise.graphenej.AssetAmount;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.UserAccount;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.BaseResponse;
+import cy.agorise.graphenej.models.HistoricalTransfer;
+import cy.agorise.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.objects.Memo;
+import cy.agorise.graphenej.operations.TransferOperation;
/**
* Class used to encapsulate the communication sequence used to retrieve the transaction history of
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRequiredFees.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetRequiredFees.java
similarity index 88%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRequiredFees.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetRequiredFees.java
index 553c95d..5879a99 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRequiredFees.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetRequiredFees.java
@@ -1,20 +1,19 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
-import de.bitsharesmunich.graphenej.AssetAmount;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.BaseResponse;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.AssetAmount;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.BaseResponse;
+import cy.agorise.graphenej.models.WitnessResponse;
import com.neovisionaries.ws.client.WebSocket;
-import com.neovisionaries.ws.client.WebSocketAdapter;
import com.neovisionaries.ws.client.WebSocketException;
import com.neovisionaries.ws.client.WebSocketFrame;
-import de.bitsharesmunich.graphenej.Asset;
-import de.bitsharesmunich.graphenej.BaseOperation;
+import cy.agorise.graphenej.Asset;
+import cy.agorise.graphenej.BaseOperation;
import java.io.Serializable;
import java.lang.reflect.Type;
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetTradeHistory.java b/graphenej/src/main/java/cy/agorise/graphenej/api/GetTradeHistory.java
similarity index 93%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetTradeHistory.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/GetTradeHistory.java
index dde5665..327a04d 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetTradeHistory.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/GetTradeHistory.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
@@ -11,11 +11,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.MarketTrade;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.MarketTrade;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.WitnessResponse;
/**
* Class that implements get_trade_history request handler.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/ListAssets.java b/graphenej/src/main/java/cy/agorise/graphenej/api/ListAssets.java
similarity index 95%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/ListAssets.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/ListAssets.java
index 28fb6bb..df85ac3 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/ListAssets.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/ListAssets.java
@@ -1,14 +1,14 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.neovisionaries.ws.client.WebSocket;
import com.neovisionaries.ws.client.WebSocketFrame;
-import de.bitsharesmunich.graphenej.Asset;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.Asset;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.WitnessResponse;
import java.io.Serializable;
import java.lang.reflect.Type;
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAccounts.java b/graphenej/src/main/java/cy/agorise/graphenej/api/LookupAccounts.java
similarity index 94%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAccounts.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/LookupAccounts.java
index 97ab2bf..afae255 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAccounts.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/LookupAccounts.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
@@ -11,11 +11,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.UserAccount;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.UserAccount;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.WitnessResponse;
/**
* Class that implements lookup_accounts request handler.
diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAssetSymbols.java b/graphenej/src/main/java/cy/agorise/graphenej/api/LookupAssetSymbols.java
similarity index 80%
rename from graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAssetSymbols.java
rename to graphenej/src/main/java/cy/agorise/graphenej/api/LookupAssetSymbols.java
index 2a649d0..d467dde 100644
--- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAssetSymbols.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/LookupAssetSymbols.java
@@ -1,4 +1,4 @@
-package de.bitsharesmunich.graphenej.api;
+package cy.agorise.graphenej.api;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
@@ -11,11 +11,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import de.bitsharesmunich.graphenej.Asset;
-import de.bitsharesmunich.graphenej.RPC;
-import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
-import de.bitsharesmunich.graphenej.models.ApiCall;
-import de.bitsharesmunich.graphenej.models.WitnessResponse;
+import cy.agorise.graphenej.Asset;
+import cy.agorise.graphenej.RPC;
+import cy.agorise.graphenej.interfaces.WitnessResponseListener;
+import cy.agorise.graphenej.models.ApiCall;
+import cy.agorise.graphenej.models.WitnessResponse;
/**
* Class that implements lookup_asset_symbols request handler.
@@ -28,7 +28,7 @@ import de.bitsharesmunich.graphenej.models.WitnessResponse;
*/
public class LookupAssetSymbols extends BaseGrapheneHandler {
private WitnessResponseListener mListener;
- private List assets;
+ private List extends Object> assets;
private boolean mOneTime;
@@ -42,7 +42,7 @@ public class LookupAssetSymbols extends BaseGrapheneHandler {
* be implemented by the party interested in being notified about the
* success/failure of the operation.
*/
- public LookupAssetSymbols(List assets, boolean oneTime, WitnessResponseListener listener){
+ public LookupAssetSymbols(List extends Object> assets, boolean oneTime, WitnessResponseListener listener){
super(listener);
this.assets = assets;
this.mOneTime = oneTime;
@@ -57,7 +57,7 @@ public class LookupAssetSymbols extends BaseGrapheneHandler {
* be implemented by the party interested in being notified about the
* success/failure of the operation.
*/
- public LookupAssetSymbols(List assets, WitnessResponseListener listener){
+ public LookupAssetSymbols(List