From 5a1c9d5834acc39bb1769ee94e7dbac673db9b51 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Sat, 20 May 2017 16:31:08 -0500 Subject: [PATCH 1/8] Version bump --- graphenej/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphenej/build.gradle b/graphenej/build.gradle index e194d62..f4958c6 100644 --- a/graphenej/build.gradle +++ b/graphenej/build.gradle @@ -21,8 +21,8 @@ android { defaultConfig { minSdkVersion 3 targetSdkVersion 24 - versionCode 3 - versionName "0.4.1" + versionCode 4 + versionName "0.4.2" vectorDrawables.useSupportLibrary = true } From 519a1a4dd8d6640e87aca8c89a6b45d7aa528d73 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Sat, 20 May 2017 19:31:57 -0500 Subject: [PATCH 2/8] Updating repo references --- README.md | 2 +- build.gradle | 4 ---- gradle.properties | 16 ++++++++-------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e6bcb63..e24059d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ In yout app module, add the following dependency: ```Groovy dependencies { - compile 'com.github.kenCode-de:graphenej:0.4.1' + compile 'com.github.bilthon:graphenej:0.4.2' } ``` diff --git a/build.gradle b/build.gradle index 18d4faf..676dacc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,3 @@ -allprojects { - task hello << { task -> println "I'm $task.project.name" } -} - subprojects { repositories { mavenCentral() diff --git a/gradle.properties b/gradle.properties index 2dc6a3e..e5ca248 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,17 +17,17 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=0.4.1-SNAPSHOT -VERSION_CODE=3 -GROUP=com.github.kenCode-de +VERSION_NAME=0.4.2 +VERSION_CODE=4 +GROUP=com.github.bilthon POM_DESCRIPTION=A Java library for mobile app Developers; Graphene/Bitshares blockchain. -POM_URL=https://github.com/kenCode-de/graphenej -POM_SCM_URL=https://github.com/kenCode-de/graphenej -POM_SCM_CONNECTION=scm:git@github.com:kenCode-de/graphenej.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:kenCode-de/graphenej.git +POM_URL=https://github.com/bilthon/graphenej +POM_SCM_URL=https://github.com/bilthon/graphenej +POM_SCM_CONNECTION=scm:git@github.com:bilthon/graphenej.git +POM_SCM_DEV_CONNECTION=scm:git@github.com:bilthon/graphenej.git POM_LICENCE_NAME=MIT License -POM_LICENCE_URL=https://github.com/kenCode-de/graphenej/blob/master/LICENSE +POM_LICENCE_URL=https://github.com/bilthon/graphenej/blob/master/LICENSE POM_LICENCE_DIST=repo POM_DEVELOPER_ID=bilthon POM_DEVELOPER_NAME=bilthon \ No newline at end of file From 7b9b694a7132964fdbd764ff73c80c5cb6dd0c5f Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Mon, 26 Jun 2017 13:59:43 -0500 Subject: [PATCH 3/8] Implementing the UserAccount#toJsonString method --- .../graphenej/UserAccount.java | 47 +++++++++++---- .../graphenej/UserAccountTest.java | 60 +++++++++++++++++++ 2 files changed, 97 insertions(+), 10 deletions(-) create mode 100644 graphenej/src/test/java/de/bitsharesmunich/graphenej/UserAccountTest.java diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/UserAccount.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/UserAccount.java index 49b66b0..4ad4b12 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/UserAccount.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/UserAccount.java @@ -1,11 +1,14 @@ package de.bitsharesmunich.graphenej; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; +import com.google.gson.annotations.Expose; import java.io.ByteArrayOutputStream; import java.io.DataOutput; @@ -20,8 +23,7 @@ import de.bitsharesmunich.graphenej.interfaces.ByteSerializable; import de.bitsharesmunich.graphenej.interfaces.JsonSerializable; /** - * Class tha represents a graphene user account. - * Created by nelson on 11/8/16. + * Class that represents a graphene user account. */ public class UserAccount extends GrapheneObject implements ByteSerializable, JsonSerializable { @@ -46,19 +48,43 @@ public class UserAccount extends GrapheneObject implements ByteSerializable, Jso public static final String KEY_ACTIVE_SPECIAL_AUTHORITY = "active_special_authority"; public static final String KEY_N_CONTROL_FLAGS = "top_n_control_flags"; - private long membershipExpirationDate; - private String registrar; - private String referrer; - private String lifetimeReferrer; - private long networkFeePercentage; - private long lifetimeReferrerFeePercentage; - private long referrerRewardsPercentage; + @Expose private String name; + + @Expose private Authority owner; + + @Expose private Authority active; + + @Expose private AccountOptions options; + + @Expose private String statistics; + @Expose + private long membershipExpirationDate; + + @Expose + private String registrar; + + @Expose + private String referrer; + + @Expose + private String lifetimeReferrer; + + @Expose + private long networkFeePercentage; + + @Expose + private long lifetimeReferrerFeePercentage; + + @Expose + private long referrerRewardsPercentage; + + /** * Constructor that expects a user account in the string representation. @@ -120,7 +146,8 @@ public class UserAccount extends GrapheneObject implements ByteSerializable, Jso @Override public String toJsonString() { - return this.getObjectId(); + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + return gson.toJson(this); } @Override diff --git a/graphenej/src/test/java/de/bitsharesmunich/graphenej/UserAccountTest.java b/graphenej/src/test/java/de/bitsharesmunich/graphenej/UserAccountTest.java new file mode 100644 index 0000000..644c6f6 --- /dev/null +++ b/graphenej/src/test/java/de/bitsharesmunich/graphenej/UserAccountTest.java @@ -0,0 +1,60 @@ +package de.bitsharesmunich.graphenej; + +import com.neovisionaries.ws.client.WebSocketException; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import de.bitsharesmunich.graphenej.api.BaseApiTest; +import de.bitsharesmunich.graphenej.api.GetObjects; +import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener; +import de.bitsharesmunich.graphenej.models.BaseResponse; +import de.bitsharesmunich.graphenej.models.WitnessResponse; + +/** + * Created by nelson on 5/20/17. + */ +public class UserAccountTest extends BaseApiTest { + private final UserAccount bilthon_25 = new UserAccount("1.2.151069"); + + @Test + public void testToJsonString() { + try{ + ArrayList ids = new ArrayList<>(); + ids.add(bilthon_25.getObjectId()); + mWebSocket.addListener(new GetObjects(ids, new WitnessResponseListener() { + + @Override + public void onSuccess(WitnessResponse response) { + System.out.println("onSuccess"); + List result = (List) response.result; + UserAccount userAccount = (UserAccount) result.get(0); + System.out.println("user account: "+userAccount.toJsonString()); + + synchronized (UserAccountTest.this){ + UserAccountTest.this.notifyAll(); + } + } + + @Override + public void onError(BaseResponse.Error error) { + System.out.println("onError"); + synchronized (UserAccountTest.this){ + UserAccountTest.this.notifyAll(); + } + } + })); + + mWebSocket.connect(); + synchronized (this){ + wait(); + } + }catch (WebSocketException e) { + System.out.println("WebSocketException. Msg: " + e.getMessage()); + } catch (InterruptedException e) { + System.out.println("InterruptedException. Msg: "+e.getMessage()); + } + } +} \ No newline at end of file From ea0bab5179e384c4831d74de5ebbeff0c9762d0a Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Mon, 26 Jun 2017 14:01:17 -0500 Subject: [PATCH 4/8] Simple renaming of a variable for semantic purposes --- .../main/java/de/bitsharesmunich/graphenej/FileBin.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/FileBin.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/FileBin.java index ab2023b..703102f 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/FileBin.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/FileBin.java @@ -4,7 +4,8 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import de.bitsharesmunich.graphenej.crypto.SecureRandomStrengthener; + +import org.bitcoinj.core.ECKey; import java.io.UnsupportedEncodingException; import java.math.BigInteger; @@ -12,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 org.bitcoinj.core.ECKey; /** * Class to manage the backup files @@ -89,9 +90,9 @@ public abstract class FileBin { secureRandom.nextBytes(randomKey); ECKey randomECKey = ECKey.fromPrivate(md.digest(randomKey)); byte[] randPubKey = randomECKey.getPubKey(); - byte[] finalKey = randomECKey.getPubKeyPoint().multiply(ECKey.fromPrivate(md.digest(password.getBytes("UTF-8"))).getPrivKey()).normalize().getXCoord().getEncoded(); + byte[] sharedSecret = randomECKey.getPubKeyPoint().multiply(ECKey.fromPrivate(md.digest(password.getBytes("UTF-8"))).getPrivKey()).normalize().getXCoord().getEncoded(); MessageDigest md1 = MessageDigest.getInstance("SHA-512"); - finalKey = md1.digest(finalKey); + byte[] finalKey = md1.digest(sharedSecret); checksummed = Util.encryptAES(checksummed, Util.byteToString(finalKey).getBytes()); byte[] finalPayload = new byte[checksummed.length + randPubKey.length]; From f59cf1afa0e39a7bec96732f9a5bd6014715919a Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Mon, 26 Jun 2017 14:02:25 -0500 Subject: [PATCH 5/8] Adding getter/setter to the weight_threshold field --- .../main/java/de/bitsharesmunich/graphenej/Authority.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Authority.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/Authority.java index 2224225..3bd4dc2 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/Authority.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/Authority.java @@ -59,6 +59,14 @@ public class Authority implements GrapheneSerializable { this.account_auths = new HashMap<>(); } + public long getWeightThreshold() { + return weight_threshold; + } + + public void setWeightThreshold(long weight_threshold) { + this.weight_threshold = weight_threshold; + } + public void setKeyAuthorities(HashMap keyAuths){ if(keyAuths != null){ for(Address address : keyAuths.keySet()){ From 3d74a612f6f00c110e1f5ab878bad14510ecaac8 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Mon, 26 Jun 2017 14:03:39 -0500 Subject: [PATCH 6/8] Making the PublicKey class implement the Serializable interface --- .../main/java/de/bitsharesmunich/graphenej/PublicKey.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/PublicKey.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/PublicKey.java index b331c3d..5b9e7eb 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/PublicKey.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/PublicKey.java @@ -1,13 +1,16 @@ package de.bitsharesmunich.graphenej; -import de.bitsharesmunich.graphenej.interfaces.ByteSerializable; import org.bitcoinj.core.ECKey; import org.spongycastle.math.ec.ECPoint; +import java.io.Serializable; + +import de.bitsharesmunich.graphenej.interfaces.ByteSerializable; + /** * Created by nelson on 11/30/16. */ -public class PublicKey implements ByteSerializable { +public class PublicKey implements ByteSerializable, Serializable { private ECKey publicKey; public PublicKey(ECKey key) { From 67f3e05b5c1f08ca8832d4d8f665d44b58dcd3b9 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Mon, 26 Jun 2017 14:05:33 -0500 Subject: [PATCH 7/8] Added the @Expose annotation to the GrapheneObject#id field --- .../java/de/bitsharesmunich/graphenej/GrapheneObject.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/GrapheneObject.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/GrapheneObject.java index 88f20a4..aaee8b5 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/GrapheneObject.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/GrapheneObject.java @@ -1,5 +1,7 @@ package de.bitsharesmunich.graphenej; +import com.google.gson.annotations.Expose; + /** *

* Generic class used to represent a graphene object as defined in @@ -13,7 +15,9 @@ public class GrapheneObject { public static final int PROTOCOL_SPACE = 1; public static final int IMPLEMENTATION_SPACE = 2; + @Expose protected String id; + protected int space; protected int type; protected long instance; From c19e618ded02eb442c42cd8a479c3c1f17cd2325 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Mon, 26 Jun 2017 14:12:31 -0500 Subject: [PATCH 8/8] Applying the version bump to the manifest and other gradle files --- gradle.properties | 2 +- graphenej/build.gradle | 2 +- graphenej/src/main/AndroidManifest.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index e5ca248..1c0fbdd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=0.4.2 +VERSION_NAME=0.4.2-SNAPSHOT VERSION_CODE=4 GROUP=com.github.bilthon diff --git a/graphenej/build.gradle b/graphenej/build.gradle index f4958c6..e4badbf 100644 --- a/graphenej/build.gradle +++ b/graphenej/build.gradle @@ -1,5 +1,5 @@ group 'de.bitsharesmunich' -version '0.4.0-SNAPSHOT' +version '0.4.2-SNAPSHOT' apply plugin: 'com.android.library' apply from: 'maven-push.gradle' diff --git a/graphenej/src/main/AndroidManifest.xml b/graphenej/src/main/AndroidManifest.xml index ee81480..441efd0 100644 --- a/graphenej/src/main/AndroidManifest.xml +++ b/graphenej/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="3" + android:versionName="0.4.2" >