Merge branch 'develop' of github.com:Agorise/graphenej into develop

This commit is contained in:
Nelson R. Perez 2019-04-04 15:12:47 -05:00
commit 65b7fef97f
5 changed files with 27 additions and 29 deletions

View file

@ -1,5 +1,6 @@
package cy.agorise.graphenej; package cy.agorise.graphenej;
import com.google.common.base.Objects;
import com.google.common.primitives.Bytes; import com.google.common.primitives.Bytes;
import cy.agorise.graphenej.errors.MalformedAddressException; import cy.agorise.graphenej.errors.MalformedAddressException;
import org.bitcoinj.core.Base58; import org.bitcoinj.core.Base58;
@ -61,4 +62,18 @@ public class Address {
ripemd160Digest.doFinal(checksum, 0); ripemd160Digest.doFinal(checksum, 0);
return Arrays.copyOfRange(checksum, 0, 4); return Arrays.copyOfRange(checksum, 0, 4);
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Address address = (Address) o;
return Objects.equal(publicKey, address.publicKey) &&
Objects.equal(prefix, address.prefix);
}
@Override
public int hashCode() {
return Objects.hashCode(publicKey, prefix);
}
} }

View file

@ -1,15 +1,11 @@
package cy.agorise.graphenej; package cy.agorise.graphenej;
import com.google.common.primitives.Bytes; import com.google.common.primitives.Bytes;
import com.google.gson.Gson; import com.google.gson.*;
import com.google.gson.JsonDeserializationContext; import cy.agorise.graphenej.errors.ChecksumException;
import com.google.gson.JsonDeserializer; import cy.agorise.graphenej.errors.MalformedAddressException;
import com.google.gson.JsonElement; import cy.agorise.graphenej.interfaces.ByteSerializable;
import com.google.gson.JsonObject; import cy.agorise.graphenej.interfaces.JsonSerializable;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import org.bitcoinj.core.ECKey; import org.bitcoinj.core.ECKey;
import org.spongycastle.math.ec.ECPoint; import org.spongycastle.math.ec.ECPoint;
@ -19,11 +15,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Arrays; import java.util.Arrays;
import cy.agorise.graphenej.errors.ChecksumException;
import cy.agorise.graphenej.errors.MalformedAddressException;
import cy.agorise.graphenej.interfaces.ByteSerializable;
import cy.agorise.graphenej.interfaces.JsonSerializable;
/** /**
* Class used to represent a memo data structure * Class used to represent a memo data structure
* {@url https://bitshares.org/doxygen/structgraphene_1_1chain_1_1memo__data.html} * {@url https://bitshares.org/doxygen/structgraphene_1_1chain_1_1memo__data.html}
@ -186,10 +177,6 @@ public class Memo implements ByteSerializable, JsonSerializable {
byte[] seed = Bytes.concat(nonceBytes, Util.hexlify(Util.bytesToHex(ss))); byte[] seed = Bytes.concat(nonceBytes, Util.hexlify(Util.bytesToHex(ss)));
// Calculating checksum
byte[] sha256Msg = sha256.digest(message);
// Applying decryption // Applying decryption
byte[] temp = Util.decryptAES(message, seed); byte[] temp = Util.decryptAES(message, seed);
byte[] checksum = Arrays.copyOfRange(temp, 0, 4); byte[] checksum = Arrays.copyOfRange(temp, 0, 4);
@ -201,7 +188,7 @@ public class Memo implements ByteSerializable, JsonSerializable {
throw new ChecksumException("Invalid checksum found while performing decryption"); throw new ChecksumException("Invalid checksum found while performing decryption");
} }
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgotithmException. Msg:"+ e.getMessage()); System.out.println("NoSuchAlgorithmException. Msg:"+ e.getMessage());
} }
return plaintext; return plaintext;
} }

View file

@ -2,7 +2,6 @@ package cy.agorise.graphenej;
import com.google.common.primitives.Bytes; import com.google.common.primitives.Bytes;
import com.google.common.primitives.UnsignedLong; import com.google.common.primitives.UnsignedLong;
import org.spongycastle.crypto.DataLengthException; import org.spongycastle.crypto.DataLengthException;
import org.spongycastle.crypto.InvalidCipherTextException; import org.spongycastle.crypto.InvalidCipherTextException;
import org.spongycastle.crypto.engines.AESFastEngine; import org.spongycastle.crypto.engines.AESFastEngine;
@ -10,13 +9,7 @@ import org.spongycastle.crypto.modes.CBCBlockCipher;
import org.spongycastle.crypto.paddings.PaddedBufferedBlockCipher; import org.spongycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.spongycastle.crypto.params.KeyParameter; import org.spongycastle.crypto.params.KeyParameter;
import org.spongycastle.crypto.params.ParametersWithIV; import org.spongycastle.crypto.params.ParametersWithIV;
import org.tukaani.xz.CorruptedInputException; import org.tukaani.xz.*;
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.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -320,7 +313,9 @@ public class Util {
} }
byte[] temp = new byte[count]; byte[] temp = new byte[count];
System.arraycopy(out, out.length - count, temp, 0, temp.length); int srcPos = out.length - count > 0 ? out.length - count : 0;
int length = count < out.length ? count : out.length;
System.arraycopy(out, srcPos, temp, 0, length);
byte[] temp2 = new byte[count]; byte[] temp2 = new byte[count];
Arrays.fill(temp2, (byte) count); Arrays.fill(temp2, (byte) count);
if (Arrays.equals(temp, temp2)) { if (Arrays.equals(temp, temp2)) {

View file

@ -160,6 +160,7 @@ public class PerformCallActivity extends ConnectedActivity {
break; break;
case RPC.CALL_GET_LIMIT_ORDERS: case RPC.CALL_GET_LIMIT_ORDERS:
setupGetLimitOrders(); setupGetLimitOrders();
break;
case RPC.CALL_GET_FULL_ACCOUNTS: case RPC.CALL_GET_FULL_ACCOUNTS:
setupGetFullAccounts(); setupGetFullAccounts();
break; break;