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