Fixing potential serialization bug for the TransferOperation when no fee is specified

This commit is contained in:
Nelson R. Perez 2017-02-16 21:53:43 -05:00
parent 89a7a1423c
commit b543a1c36d

View file

@ -8,7 +8,6 @@ import java.lang.reflect.Type;
/** /**
* Class used to encapsulate the TransferOperation operation related functionalities. * Class used to encapsulate the TransferOperation operation related functionalities.
* TODO: Add extensions support
*/ */
public class TransferOperation extends BaseOperation { public class TransferOperation extends BaseOperation {
public static final String KEY_FEE = "fee"; public static final String KEY_FEE = "fee";
@ -86,6 +85,7 @@ public class TransferOperation extends BaseOperation {
JsonArray array = new JsonArray(); JsonArray array = new JsonArray();
array.add(this.getId()); array.add(this.getId());
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
if(fee != null)
jsonObject.add(KEY_FEE, fee.toJsonObject()); jsonObject.add(KEY_FEE, fee.toJsonObject());
jsonObject.addProperty(KEY_FROM, from.toJsonString()); jsonObject.addProperty(KEY_FROM, from.toJsonString());
jsonObject.addProperty(KEY_TO, to.toJsonString()); jsonObject.addProperty(KEY_TO, to.toJsonString());