[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / NodeInfo.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  * Details about a node in the network, known from the network announcement.
11  */
12 public class NodeInfo : CommonBase {
13         internal NodeInfo(object _dummy, long ptr) : base(ptr) { }
14         ~NodeInfo() {
15                 if (ptr != 0) { bindings.NodeInfo_free(ptr); }
16         }
17
18         /**
19          * All valid channels a node has announced
20          * 
21          * Returns a copy of the field.
22          */
23         public long[] get_channels() {
24                 long ret = bindings.NodeInfo_get_channels(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 long[] ret_conv = InternalUtils.decodeUint64Array(ret);
28                 return ret_conv;
29         }
30
31         /**
32          * All valid channels a node has announced
33          */
34         public void set_channels(long[] val) {
35                 bindings.NodeInfo_set_channels(this.ptr, InternalUtils.encodeUint64Array(val));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * More information about a node from node_announcement.
42          * Optional because we store a Node entry after learning about it from
43          * a channel announcement, but before receiving a node announcement.
44          * 
45          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
46          */
47         public NodeAnnouncementInfo get_announcement_info() {
48                 long ret = bindings.NodeInfo_get_announcement_info(this.ptr);
49                 GC.KeepAlive(this);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
52                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
53                 return ret_hu_conv;
54         }
55
56         /**
57          * More information about a node from node_announcement.
58          * Optional because we store a Node entry after learning about it from
59          * a channel announcement, but before receiving a node announcement.
60          * 
61          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
62          */
63         public void set_announcement_info(org.ldk.structs.NodeAnnouncementInfo val) {
64                 bindings.NodeInfo_set_announcement_info(this.ptr, val == null ? 0 : val.ptr);
65                 GC.KeepAlive(this);
66                 GC.KeepAlive(val);
67                 if (this != null) { this.ptrs_to.AddLast(val); };
68         }
69
70         /**
71          * Constructs a new NodeInfo given each field
72          * 
73          * Note that announcement_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
74          */
75         public static NodeInfo of(long[] channels_arg, org.ldk.structs.NodeAnnouncementInfo announcement_info_arg) {
76                 long ret = bindings.NodeInfo_new(InternalUtils.encodeUint64Array(channels_arg), announcement_info_arg == null ? 0 : announcement_info_arg.ptr);
77                 GC.KeepAlive(channels_arg);
78                 GC.KeepAlive(announcement_info_arg);
79                 if (ret >= 0 && ret <= 4096) { return null; }
80                 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
81                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
82                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(announcement_info_arg); };
83                 return ret_hu_conv;
84         }
85
86         internal long clone_ptr() {
87                 long ret = bindings.NodeInfo_clone_ptr(this.ptr);
88                 GC.KeepAlive(this);
89                 return ret;
90         }
91
92         /**
93          * Creates a copy of the NodeInfo
94          */
95         public NodeInfo clone() {
96                 long ret = bindings.NodeInfo_clone(this.ptr);
97                 GC.KeepAlive(this);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Checks if two NodeInfos contain equal inner contents.
106          * This ignores pointers and is_owned flags and looks at the values in fields.
107          * Two objects with NULL inner values will be considered "equal" here.
108          */
109         public bool eq(org.ldk.structs.NodeInfo b) {
110                 bool ret = bindings.NodeInfo_eq(this.ptr, b == null ? 0 : b.ptr);
111                 GC.KeepAlive(this);
112                 GC.KeepAlive(b);
113                 if (this != null) { this.ptrs_to.AddLast(b); };
114                 return ret;
115         }
116
117         public override bool Equals(object o) {
118                 if (!(o is NodeInfo)) return false;
119                 return this.eq((NodeInfo)o);
120         }
121         /**
122          * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
123          */
124         public byte[] write() {
125                 long ret = bindings.NodeInfo_write(this.ptr);
126                 GC.KeepAlive(this);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
129                 return ret_conv;
130         }
131
132         /**
133          * Read a NodeInfo from a byte array, created by NodeInfo_write
134          */
135         public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
136                 long ret = bindings.NodeInfo_read(InternalUtils.encodeUint8Array(ser));
137                 GC.KeepAlive(ser);
138                 if (ret >= 0 && ret <= 4096) { return null; }
139                 Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
140                 return ret_hu_conv;
141         }
142
143 }
144 } } }