Updating Memo class
This commit is contained in:
parent
e9047b55ce
commit
f47ae7191c
1 changed files with 41 additions and 5 deletions
|
@ -30,6 +30,18 @@ public class Memo implements ByteSerializable, JsonSerializable {
|
||||||
private Address to;
|
private Address to;
|
||||||
private long nonce;
|
private long nonce;
|
||||||
private byte[] message;
|
private byte[] message;
|
||||||
|
private String plaintextMessage;
|
||||||
|
|
||||||
|
public String getPlaintextMessage() {
|
||||||
|
if(plaintextMessage == null)
|
||||||
|
return "";
|
||||||
|
else
|
||||||
|
return plaintextMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlaintextMessage(String plaintextMessage) {
|
||||||
|
this.plaintextMessage = plaintextMessage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty Constructor
|
* Empty Constructor
|
||||||
|
@ -62,6 +74,29 @@ public class Memo implements ByteSerializable, JsonSerializable {
|
||||||
this.message = message.getBytes();
|
this.message = message.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Address getSource(){
|
||||||
|
return this.from;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Address getDestination(){
|
||||||
|
return this.to;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getNonce(){
|
||||||
|
return this.nonce;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getByteMessage(){
|
||||||
|
return this.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStringMessage(){
|
||||||
|
if(this.message != null)
|
||||||
|
return new String(this.message);
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method used to decrypt memo data.
|
* Method used to decrypt memo data.
|
||||||
* @param privateKey: Private key of the sender.
|
* @param privateKey: Private key of the sender.
|
||||||
|
@ -160,7 +195,6 @@ public class Memo implements ByteSerializable, JsonSerializable {
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
System.out.println("NoSuchAlgotithmException. Msg:"+ e.getMessage());
|
System.out.println("NoSuchAlgotithmException. Msg:"+ e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return plaintext;
|
return plaintext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,10 +255,12 @@ public class Memo implements ByteSerializable, JsonSerializable {
|
||||||
JsonObject memoObject = new JsonObject();
|
JsonObject memoObject = new JsonObject();
|
||||||
if ((this.from == null) && (this.to == null)) {
|
if ((this.from == null) && (this.to == null)) {
|
||||||
// Public memo
|
// Public memo
|
||||||
memoObject.addProperty(KEY_FROM, "");
|
// TODO: Add public memo support
|
||||||
memoObject.addProperty(KEY_TO, "");
|
// memoObject.addProperty(KEY_FROM, "");
|
||||||
memoObject.addProperty(KEY_NONCE, "");
|
// memoObject.addProperty(KEY_TO, "");
|
||||||
memoObject.addProperty(KEY_MESSAGE, Util.bytesToHex(this.message));
|
// memoObject.addProperty(KEY_NONCE, "");
|
||||||
|
// memoObject.addProperty(KEY_MESSAGE, Util.bytesToHex(this.message));
|
||||||
|
return null;
|
||||||
}else{
|
}else{
|
||||||
memoObject.addProperty(KEY_FROM, this.from.toString());
|
memoObject.addProperty(KEY_FROM, this.from.toString());
|
||||||
memoObject.addProperty(KEY_TO, this.to.toString());
|
memoObject.addProperty(KEY_TO, this.to.toString());
|
||||||
|
|
Loading…
Reference in a new issue