Merge branch 'master' into develop
This commit is contained in:
commit
980d072c2b
11 changed files with 133 additions and 34 deletions
|
@ -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'
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
allprojects {
|
||||
task hello << { task -> println "I'm $task.project.name" }
|
||||
}
|
||||
|
||||
subprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
|
@ -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-SNAPSHOT
|
||||
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
|
|
@ -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'
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.bitsharesmunich.graphenej"
|
||||
android:versionCode="1"
|
||||
android:versionName="0.4.0" >
|
||||
android:versionCode="3"
|
||||
android:versionName="0.4.2" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="1" />
|
||||
<application/>
|
||||
|
|
|
@ -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<Address, Long> keyAuths){
|
||||
if(keyAuths != null){
|
||||
for(Address address : keyAuths.keySet()){
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.bitsharesmunich.graphenej;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<String> 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<GrapheneObject> result = (List<GrapheneObject>) 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());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue