1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A node_announcement message to be sent or received from a peer
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 {
20 if (ptr != 0) { bindings.NodeAnnouncement_free(ptr); }
24 * The signature by the node key
26 public byte[] get_signature() {
27 byte[] ret = bindings.NodeAnnouncement_get_signature(this.ptr);
28 Reference.reachabilityFence(this);
33 * The signature by the node key
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);
42 * The actual content of the announcement
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 org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
49 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
54 * The actual content of the announcement
56 public void set_contents(UnsignedNodeAnnouncement val) {
57 bindings.NodeAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr);
58 Reference.reachabilityFence(this);
59 Reference.reachabilityFence(val);
60 if (this != null) { this.ptrs_to.add(val); };
64 * Constructs a new NodeAnnouncement given each field
66 public static NodeAnnouncement of(byte[] signature_arg, UnsignedNodeAnnouncement contents_arg) {
67 long ret = bindings.NodeAnnouncement_new(InternalUtils.check_arr_len(signature_arg, 64), contents_arg == null ? 0 : contents_arg.ptr);
68 Reference.reachabilityFence(signature_arg);
69 Reference.reachabilityFence(contents_arg);
70 if (ret >= 0 && ret <= 4096) { return null; }
71 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
72 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
73 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(contents_arg); };
78 long ret = bindings.NodeAnnouncement_clone_ptr(this.ptr);
79 Reference.reachabilityFence(this);
84 * Creates a copy of the NodeAnnouncement
86 public NodeAnnouncement clone() {
87 long ret = bindings.NodeAnnouncement_clone(this.ptr);
88 Reference.reachabilityFence(this);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96 * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
98 public byte[] write() {
99 byte[] ret = bindings.NodeAnnouncement_write(this.ptr);
100 Reference.reachabilityFence(this);
105 * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
107 public static Result_NodeAnnouncementDecodeErrorZ read(byte[] ser) {
108 long ret = bindings.NodeAnnouncement_read(ser);
109 Reference.reachabilityFence(ser);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 Result_NodeAnnouncementDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);