OSDN Git Service

merge tx signer
[bytom/bytom-java-sdk.git] / tx-signer / src / main / java / io / bytom / api / Receiver.java
diff --git a/tx-signer/src/main/java/io/bytom/api/Receiver.java b/tx-signer/src/main/java/io/bytom/api/Receiver.java
new file mode 100755 (executable)
index 0000000..f13ab85
--- /dev/null
@@ -0,0 +1,48 @@
+package io.bytom.api;\r
+\r
+import com.google.gson.annotations.SerializedName;\r
+import io.bytom.common.Utils;\r
+import io.bytom.exception.JSONException;\r
+\r
+/**\r
+ * Receivers are used to facilitate payments between accounts on different\r
+ * cores. They contain a control program and an expiration date. In the future,\r
+ * more payment-related metadata may be placed here.\r
+ * <p>\r
+ * Receivers are typically created under accounts via the\r
+ */\r
+public class Receiver {\r
+\r
+    @SerializedName("address")\r
+    public String address;\r
+    /**\r
+     * Hex-encoded string representation of the control program.\r
+     */\r
+    @SerializedName("control_program")\r
+    public String controlProgram;\r
+\r
+\r
+    /**\r
+     * Serializes the receiver into a form that is safe to transfer over the wire.\r
+     *\r
+     * @return the JSON-serialized representation of the Receiver object\r
+     */\r
+    public String toJson() {\r
+        return Utils.serializer.toJson(this);\r
+    }\r
+\r
+    /**\r
+     * Deserializes a Receiver from JSON.\r
+     *\r
+     * @param json a JSON-serialized Receiver object\r
+     * @return the deserialized Receiver object\r
+     * @throws JSONException Raised if the provided string is not valid JSON.\r
+     */\r
+    public static Receiver fromJson(String json) throws JSONException {\r
+        try {\r
+            return Utils.serializer.fromJson(json, Receiver.class);\r
+        } catch (IllegalStateException e) {\r
+            throw new JSONException("Unable to parse serialized receiver: " + e.getMessage());\r
+        }\r
+    }\r
+}\r