1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * A node_announcement message to be sent or received from a peer
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 {
19 if (ptr != 0) { bindings.NodeAnnouncement_free(ptr); }
23 * The signature by the node key
25 public byte[] get_signature() {
26 byte[] ret = bindings.NodeAnnouncement_get_signature(this.ptr);
31 * The signature by the node key
33 public void set_signature(byte[] val) {
34 bindings.NodeAnnouncement_set_signature(this.ptr, val);
38 * The actual content of the announcement
40 public UnsignedNodeAnnouncement get_contents() {
41 long ret = bindings.NodeAnnouncement_get_contents(this.ptr);
42 if (ret < 1024) { return null; }
43 UnsignedNodeAnnouncement ret_hu_conv = new UnsignedNodeAnnouncement(null, ret);
44 ret_hu_conv.ptrs_to.add(this);
49 * The actual content of the announcement
51 public void set_contents(UnsignedNodeAnnouncement val) {
52 bindings.NodeAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr & ~1);
53 this.ptrs_to.add(val);
57 * Constructs a new NodeAnnouncement given each field
59 public static NodeAnnouncement of(byte[] signature_arg, UnsignedNodeAnnouncement contents_arg) {
60 long ret = bindings.NodeAnnouncement_new(signature_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1);
61 if (ret < 1024) { return null; }
62 NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret);
63 ret_hu_conv.ptrs_to.add(ret_hu_conv);
64 ret_hu_conv.ptrs_to.add(contents_arg);
69 * Creates a copy of the NodeAnnouncement
71 public NodeAnnouncement clone() {
72 long ret = bindings.NodeAnnouncement_clone(this.ptr);
73 if (ret < 1024) { return null; }
74 NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret);
75 ret_hu_conv.ptrs_to.add(this);
80 * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
82 public byte[] write() {
83 byte[] ret = bindings.NodeAnnouncement_write(this.ptr);
88 * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
90 public static Result_NodeAnnouncementDecodeErrorZ read(byte[] ser) {
91 long ret = bindings.NodeAnnouncement_read(ser);
92 if (ret < 1024) { return null; }
93 Result_NodeAnnouncementDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);