6 namespace org { namespace ldk { namespace structs {
10 * A [`node_announcement`] message to be sent to or received from a peer.
12 * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
14 public class NodeAnnouncement : CommonBase {
15 internal NodeAnnouncement(object _dummy, long ptr) : base(ptr) { }
17 if (ptr != 0) { bindings.NodeAnnouncement_free(ptr); }
21 * The signature by the node key
23 public byte[] get_signature() {
24 long ret = bindings.NodeAnnouncement_get_signature(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
32 * The signature by the node key
34 public void set_signature(byte[] val) {
35 bindings.NodeAnnouncement_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
41 * The actual content of the announcement
43 public UnsignedNodeAnnouncement get_contents() {
44 long ret = bindings.NodeAnnouncement_get_contents(this.ptr);
46 if (ret >= 0 && ret <= 4096) { return null; }
47 org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
48 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
53 * The actual content of the announcement
55 public void set_contents(org.ldk.structs.UnsignedNodeAnnouncement val) {
56 bindings.NodeAnnouncement_set_contents(this.ptr, val.ptr);
59 if (this != null) { this.ptrs_to.AddLast(val); };
63 * Constructs a new NodeAnnouncement given each field
65 public static NodeAnnouncement of(byte[] signature_arg, org.ldk.structs.UnsignedNodeAnnouncement contents_arg) {
66 long ret = bindings.NodeAnnouncement_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature_arg, 64)), contents_arg.ptr);
67 GC.KeepAlive(signature_arg);
68 GC.KeepAlive(contents_arg);
69 if (ret >= 0 && ret <= 4096) { return null; }
70 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
71 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
72 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(contents_arg); };
76 internal long clone_ptr() {
77 long ret = bindings.NodeAnnouncement_clone_ptr(this.ptr);
83 * Creates a copy of the NodeAnnouncement
85 public NodeAnnouncement clone() {
86 long ret = bindings.NodeAnnouncement_clone(this.ptr);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
95 * Generates a non-cryptographic 64-bit hash of the NodeAnnouncement.
98 long ret = bindings.NodeAnnouncement_hash(this.ptr);
103 public override int GetHashCode() {
104 return (int)this.hash();
107 * Checks if two NodeAnnouncements contain equal inner contents.
108 * This ignores pointers and is_owned flags and looks at the values in fields.
109 * Two objects with NULL inner values will be considered "equal" here.
111 public bool eq(org.ldk.structs.NodeAnnouncement b) {
112 bool ret = bindings.NodeAnnouncement_eq(this.ptr, b.ptr);
115 if (this != null) { this.ptrs_to.AddLast(b); };
119 public override bool Equals(object o) {
120 if (!(o is NodeAnnouncement)) return false;
121 return this.eq((NodeAnnouncement)o);
124 * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
126 public byte[] write() {
127 long ret = bindings.NodeAnnouncement_write(this.ptr);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
135 * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
137 public static Result_NodeAnnouncementDecodeErrorZ read(byte[] ser) {
138 long ret = bindings.NodeAnnouncement_read(InternalUtils.encodeUint8Array(ser));
140 if (ret >= 0 && ret <= 4096) { return null; }
141 Result_NodeAnnouncementDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);