Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / NodeAnnouncement.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7
8
9 /**
10  * A node_announcement message to be sent or received from a peer
11  */
12 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
13 public class NodeAnnouncement extends CommonBase {
14         NodeAnnouncement(Object _dummy, long ptr) { super(ptr); }
15         @Override @SuppressWarnings("deprecation")
16         protected void finalize() throws Throwable {
17                 super.finalize();
18                 if (ptr != 0) { bindings.NodeAnnouncement_free(ptr); }
19         }
20
21         /**
22          * The signature by the node key
23          */
24         public byte[] get_signature() {
25                 byte[] ret = bindings.NodeAnnouncement_get_signature(this.ptr);
26                 return ret;
27         }
28
29         /**
30          * The signature by the node key
31          */
32         public void set_signature(byte[] val) {
33                 bindings.NodeAnnouncement_set_signature(this.ptr, val);
34         }
35
36         /**
37          * The actual content of the announcement
38          */
39         public UnsignedNodeAnnouncement get_contents() {
40                 long ret = bindings.NodeAnnouncement_get_contents(this.ptr);
41                 if (ret < 1024) { return null; }
42                 UnsignedNodeAnnouncement ret_hu_conv = new UnsignedNodeAnnouncement(null, ret);
43                 ret_hu_conv.ptrs_to.add(this);
44                 return ret_hu_conv;
45         }
46
47         /**
48          * The actual content of the announcement
49          */
50         public void set_contents(UnsignedNodeAnnouncement val) {
51                 bindings.NodeAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr & ~1);
52                 this.ptrs_to.add(val);
53         }
54
55         /**
56          * Constructs a new NodeAnnouncement given each field
57          */
58         public static NodeAnnouncement of(byte[] signature_arg, UnsignedNodeAnnouncement contents_arg) {
59                 long ret = bindings.NodeAnnouncement_new(signature_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1);
60                 if (ret < 1024) { return null; }
61                 NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret);
62                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
63                 ret_hu_conv.ptrs_to.add(contents_arg);
64                 return ret_hu_conv;
65         }
66
67         /**
68          * Creates a copy of the NodeAnnouncement
69          */
70         public NodeAnnouncement clone() {
71                 long ret = bindings.NodeAnnouncement_clone(this.ptr);
72                 if (ret < 1024) { return null; }
73                 NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret);
74                 ret_hu_conv.ptrs_to.add(this);
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
80          */
81         public byte[] write() {
82                 byte[] ret = bindings.NodeAnnouncement_write(this.ptr);
83                 return ret;
84         }
85
86         /**
87          * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
88          */
89         public static Result_NodeAnnouncementDecodeErrorZ read(byte[] ser) {
90                 long ret = bindings.NodeAnnouncement_read(ser);
91                 if (ret < 1024) { return null; }
92                 Result_NodeAnnouncementDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
93                 return ret_hu_conv;
94         }
95
96 }