6 namespace org { namespace ldk { namespace structs {
10 * A read-only view of [`NetworkGraph`].
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); }
19 * Returns information on a channel with the given id.
21 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
23 public ChannelInfo channel(long short_channel_id) {
24 long ret = bindings.ReadOnlyNetworkGraph_channel(this.ptr, short_channel_id);
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); };
34 * Returns the list of channels in the graph
36 public long[] list_channels() {
37 long ret = bindings.ReadOnlyNetworkGraph_list_channels(this.ptr);
39 if (ret >= 0 && ret <= 4096) { return null; }
40 long[] ret_conv = InternalUtils.decodeUint64Array(ret);
45 * Returns information on a node with the given id.
47 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
49 public NodeInfo node(org.ldk.structs.NodeId node_id) {
50 long ret = bindings.ReadOnlyNetworkGraph_node(this.ptr, node_id.ptr);
52 GC.KeepAlive(node_id);
53 if (ret >= 0 && ret <= 4096) { return null; }
54 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
55 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
56 if (this != null) { this.ptrs_to.AddLast(node_id); };
61 * Returns the list of nodes in the graph
63 public NodeId[] list_nodes() {
64 long ret = bindings.ReadOnlyNetworkGraph_list_nodes(this.ptr);
66 if (ret >= 0 && ret <= 4096) { return null; }
67 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
68 NodeId[] ret_conv_8_arr = new NodeId[ret_conv_8_len];
69 for (int i = 0; i < ret_conv_8_len; i++) {
70 long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
71 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); }
72 if (ret_conv_8_hu_conv != null) { ret_conv_8_hu_conv.ptrs_to.AddLast(this); };
73 ret_conv_8_arr[i] = ret_conv_8_hu_conv;
75 bindings.free_buffer(ret);
76 return ret_conv_8_arr;
80 * Get network addresses by node id.
81 * Returns None if the requested node is completely unknown,
82 * or if node announcement for the node was never received.
84 public Option_CVec_SocketAddressZZ get_addresses(byte[] pubkey) {
85 long ret = bindings.ReadOnlyNetworkGraph_get_addresses(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(pubkey, 33)));
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.Option_CVec_SocketAddressZZ ret_hu_conv = org.ldk.structs.Option_CVec_SocketAddressZZ.constr_from_ptr(ret);
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };