[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / NodeAnnouncement.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A [`node_announcement`] message to be sent to or received from a peer.
11  * 
12  * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
13  */
14 public class NodeAnnouncement : CommonBase {
15         internal NodeAnnouncement(object _dummy, long ptr) : base(ptr) { }
16         ~NodeAnnouncement() {
17                 if (ptr != 0) { bindings.NodeAnnouncement_free(ptr); }
18         }
19
20         /**
21          * The signature by the node key
22          */
23         public byte[] get_signature() {
24                 long ret = bindings.NodeAnnouncement_get_signature(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
28                 return ret_conv;
29         }
30
31         /**
32          * The signature by the node key
33          */
34         public void set_signature(byte[] val) {
35                 bindings.NodeAnnouncement_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * The actual content of the announcement
42          */
43         public UnsignedNodeAnnouncement get_contents() {
44                 long ret = bindings.NodeAnnouncement_get_contents(this.ptr);
45                 GC.KeepAlive(this);
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); };
49                 return ret_hu_conv;
50         }
51
52         /**
53          * The actual content of the announcement
54          */
55         public void set_contents(org.ldk.structs.UnsignedNodeAnnouncement val) {
56                 bindings.NodeAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr);
57                 GC.KeepAlive(this);
58                 GC.KeepAlive(val);
59                 if (this != null) { this.ptrs_to.AddLast(val); };
60         }
61
62         /**
63          * Constructs a new NodeAnnouncement given each field
64          */
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 == null ? 0 : 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); };
73                 return ret_hu_conv;
74         }
75
76         internal long clone_ptr() {
77                 long ret = bindings.NodeAnnouncement_clone_ptr(this.ptr);
78                 GC.KeepAlive(this);
79                 return ret;
80         }
81
82         /**
83          * Creates a copy of the NodeAnnouncement
84          */
85         public NodeAnnouncement clone() {
86                 long ret = bindings.NodeAnnouncement_clone(this.ptr);
87                 GC.KeepAlive(this);
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); };
91                 return ret_hu_conv;
92         }
93
94         /**
95          * Checks if two NodeAnnouncements contain equal inner contents.
96          * This ignores pointers and is_owned flags and looks at the values in fields.
97          * Two objects with NULL inner values will be considered "equal" here.
98          */
99         public bool eq(org.ldk.structs.NodeAnnouncement b) {
100                 bool ret = bindings.NodeAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
101                 GC.KeepAlive(this);
102                 GC.KeepAlive(b);
103                 if (this != null) { this.ptrs_to.AddLast(b); };
104                 return ret;
105         }
106
107         public override bool Equals(object o) {
108                 if (!(o is NodeAnnouncement)) return false;
109                 return this.eq((NodeAnnouncement)o);
110         }
111         /**
112          * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
113          */
114         public byte[] write() {
115                 long ret = bindings.NodeAnnouncement_write(this.ptr);
116                 GC.KeepAlive(this);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
119                 return ret_conv;
120         }
121
122         /**
123          * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
124          */
125         public static Result_NodeAnnouncementDecodeErrorZ read(byte[] ser) {
126                 long ret = bindings.NodeAnnouncement_read(InternalUtils.encodeUint8Array(ser));
127                 GC.KeepAlive(ser);
128                 if (ret >= 0 && ret <= 4096) { return null; }
129                 Result_NodeAnnouncementDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
130                 return ret_hu_conv;
131         }
132
133 }
134 } } }