[C#] Check in initial auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / ReadOnlyNetworkGraph.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 read-only view of [`NetworkGraph`].
11  */
12 public class ReadOnlyNetworkGraph : CommonBase, IDisposable {
13         internal ReadOnlyNetworkGraph(object _dummy, long ptr) : base(ptr) { }
14         public void Dispose() {
15                 if (ptr != 0) { bindings.ReadOnlyNetworkGraph_free(ptr); }
16         }
17
18         /**
19          * Returns information on a channel with the given id.
20          * 
21          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
22          */
23         public ChannelInfo channel(long short_channel_id) {
24                 long ret = bindings.ReadOnlyNetworkGraph_channel(this.ptr, short_channel_id);
25                 GC.KeepAlive(this);
26                 GC.KeepAlive(short_channel_id);
27                 if (ret >= 0 && ret <= 4096) { return null; }
28                 org.ldk.structs.ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelInfo(null, ret); }
29                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
30                 return ret_hu_conv;
31         }
32
33         /**
34          * Returns the list of channels in the graph
35          */
36         public long[] list_channels() {
37                 long[] ret = bindings.ReadOnlyNetworkGraph_list_channels(this.ptr);
38                 GC.KeepAlive(this);
39                 return ret;
40         }
41
42         /**
43          * Returns information on a node with the given id.
44          * 
45          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
46          */
47         public NodeInfo node(org.ldk.structs.NodeId node_id) {
48                 long ret = bindings.ReadOnlyNetworkGraph_node(this.ptr, node_id == null ? 0 : node_id.ptr);
49                 GC.KeepAlive(this);
50                 GC.KeepAlive(node_id);
51                 if (ret >= 0 && ret <= 4096) { return null; }
52                 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
53                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
54                 if (this != null) { this.ptrs_to.AddLast(node_id); };
55                 return ret_hu_conv;
56         }
57
58         /**
59          * Returns the list of nodes in the graph
60          */
61         public NodeId[] list_nodes() {
62                 long[] ret = bindings.ReadOnlyNetworkGraph_list_nodes(this.ptr);
63                 GC.KeepAlive(this);
64                 int ret_conv_8_len = ret.Length;
65                 NodeId[] ret_conv_8_arr = new NodeId[ret_conv_8_len];
66                 for (int i = 0; i < ret_conv_8_len; i++) {
67                         long ret_conv_8 = ret[i];
68                         org.ldk.structs.NodeId ret_conv_8_hu_conv = null; if (ret_conv_8 < 0 || ret_conv_8 > 4096) { ret_conv_8_hu_conv = new org.ldk.structs.NodeId(null, ret_conv_8); }
69                         if (ret_conv_8_hu_conv != null) { ret_conv_8_hu_conv.ptrs_to.AddLast(this); };
70                         ret_conv_8_arr[i] = ret_conv_8_hu_conv;
71                 }
72                 return ret_conv_8_arr;
73         }
74
75         /**
76          * Get network addresses by node id.
77          * Returns None if the requested node is completely unknown,
78          * or if node announcement for the node was never received.
79          */
80         public Option_CVec_NetAddressZZ get_addresses(byte[] pubkey) {
81                 long ret = bindings.ReadOnlyNetworkGraph_get_addresses(this.ptr, InternalUtils.check_arr_len(pubkey, 33));
82                 GC.KeepAlive(this);
83                 GC.KeepAlive(pubkey);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.Option_CVec_NetAddressZZ ret_hu_conv = org.ldk.structs.Option_CVec_NetAddressZZ.constr_from_ptr(ret);
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
87                 return ret_hu_conv;
88         }
89
90 }
91 } } }