87c8d14b4f8a13822f6bb07510900cfb66a700b8
[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          * Lowest fees enabling routing via any of the enabled, known channels to a node.
40          * The two fields (flat and proportional fee) are independent,
41          * meaning they don't have to refer to the same channel.
42          * 
43          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
44          */
45         public RoutingFees get_lowest_inbound_channel_fees() {
46                 long ret = bindings.NodeInfo_get_lowest_inbound_channel_fees(this.ptr);
47                 GC.KeepAlive(this);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 org.ldk.structs.RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RoutingFees(null, ret); }
50                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
51                 return ret_hu_conv;
52         }
53
54         /**
55          * Lowest fees enabling routing via any of the enabled, known channels to a node.
56          * The two fields (flat and proportional fee) are independent,
57          * meaning they don't have to refer to the same channel.
58          * 
59          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
60          */
61         public void set_lowest_inbound_channel_fees(org.ldk.structs.RoutingFees val) {
62                 bindings.NodeInfo_set_lowest_inbound_channel_fees(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          * More information about a node from node_announcement.
70          * Optional because we store a Node entry after learning about it from
71          * a channel announcement, but before receiving a node announcement.
72          * 
73          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
74          */
75         public NodeAnnouncementInfo get_announcement_info() {
76                 long ret = bindings.NodeInfo_get_announcement_info(this.ptr);
77                 GC.KeepAlive(this);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
80                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
81                 return ret_hu_conv;
82         }
83
84         /**
85          * More information about a node from node_announcement.
86          * Optional because we store a Node entry after learning about it from
87          * a channel announcement, but before receiving a node announcement.
88          * 
89          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
90          */
91         public void set_announcement_info(org.ldk.structs.NodeAnnouncementInfo val) {
92                 bindings.NodeInfo_set_announcement_info(this.ptr, val == null ? 0 : val.ptr);
93                 GC.KeepAlive(this);
94                 GC.KeepAlive(val);
95                 if (this != null) { this.ptrs_to.AddLast(val); };
96         }
97
98         /**
99          * Constructs a new NodeInfo given each field
100          */
101         public static NodeInfo of(long[] channels_arg, org.ldk.structs.RoutingFees lowest_inbound_channel_fees_arg, org.ldk.structs.NodeAnnouncementInfo announcement_info_arg) {
102                 long ret = bindings.NodeInfo_new(channels_arg, lowest_inbound_channel_fees_arg == null ? 0 : lowest_inbound_channel_fees_arg.ptr, announcement_info_arg == null ? 0 : announcement_info_arg.ptr);
103                 GC.KeepAlive(channels_arg);
104                 GC.KeepAlive(lowest_inbound_channel_fees_arg);
105                 GC.KeepAlive(announcement_info_arg);
106                 if (ret >= 0 && ret <= 4096) { return null; }
107                 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(lowest_inbound_channel_fees_arg); };
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(announcement_info_arg); };
111                 return ret_hu_conv;
112         }
113
114         internal long clone_ptr() {
115                 long ret = bindings.NodeInfo_clone_ptr(this.ptr);
116                 GC.KeepAlive(this);
117                 return ret;
118         }
119
120         /**
121          * Creates a copy of the NodeInfo
122          */
123         public NodeInfo clone() {
124                 long ret = bindings.NodeInfo_clone(this.ptr);
125                 GC.KeepAlive(this);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
128                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
129                 return ret_hu_conv;
130         }
131
132         /**
133          * Checks if two NodeInfos contain equal inner contents.
134          * This ignores pointers and is_owned flags and looks at the values in fields.
135          * Two objects with NULL inner values will be considered "equal" here.
136          */
137         public bool eq(org.ldk.structs.NodeInfo b) {
138                 bool ret = bindings.NodeInfo_eq(this.ptr, b == null ? 0 : b.ptr);
139                 GC.KeepAlive(this);
140                 GC.KeepAlive(b);
141                 if (this != null) { this.ptrs_to.AddLast(b); };
142                 return ret;
143         }
144
145         public override bool Equals(object o) {
146                 if (!(o is NodeInfo)) return false;
147                 return this.eq((NodeInfo)o);
148         }
149         /**
150          * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
151          */
152         public byte[] write() {
153                 byte[] ret = bindings.NodeInfo_write(this.ptr);
154                 GC.KeepAlive(this);
155                 return ret;
156         }
157
158         /**
159          * Read a NodeInfo from a byte array, created by NodeInfo_write
160          */
161         public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
162                 long ret = bindings.NodeInfo_read(ser);
163                 GC.KeepAlive(ser);
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
166                 return ret_hu_conv;
167         }
168
169 }
170 } } }