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