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