[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / NodeIdLookUp.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of NodeIdLookUp */
12 public interface NodeIdLookUpInterface {
13         /**Returns the node id of the forwarding node's channel counterparty with `short_channel_id`.
14          * 
15          * Here, the forwarding node is referring to the node of the [`OnionMessenger`] parameterized
16          * by the [`NodeIdLookUp`] and the counterparty to one of that node's peers.
17          * 
18          * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
19          * 
20          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
21          */
22         byte[] next_node_id(long short_channel_id);
23 }
24
25 /**
26  * An interface for looking up the node id of a channel counterparty for the purpose of forwarding
27  * an [`OnionMessage`].
28  * 
29  * [`OnionMessage`]: crate::ln::msgs::OnionMessage
30  */
31 public class NodeIdLookUp : CommonBase {
32         internal bindings.LDKNodeIdLookUp bindings_instance;
33         internal long instance_idx;
34
35         internal NodeIdLookUp(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
36         ~NodeIdLookUp() {
37                 if (ptr != 0) { bindings.NodeIdLookUp_free(ptr); }
38         }
39
40         private class LDKNodeIdLookUpHolder { internal NodeIdLookUp held; }
41         private class LDKNodeIdLookUpImpl : bindings.LDKNodeIdLookUp {
42                 internal LDKNodeIdLookUpImpl(NodeIdLookUpInterface arg, LDKNodeIdLookUpHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
43                 private NodeIdLookUpInterface arg;
44                 private LDKNodeIdLookUpHolder impl_holder;
45                 public long next_node_id(long _short_channel_id) {
46                         byte[] ret = arg.next_node_id(_short_channel_id);
47                                 GC.KeepAlive(arg);
48                         long result = InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(ret, 33));
49                         return result;
50                 }
51         }
52
53         /** Creates a new instance of NodeIdLookUp from a given implementation */
54         public static NodeIdLookUp new_impl(NodeIdLookUpInterface arg) {
55                 LDKNodeIdLookUpHolder impl_holder = new LDKNodeIdLookUpHolder();
56                 LDKNodeIdLookUpImpl impl = new LDKNodeIdLookUpImpl(arg, impl_holder);
57                 long[] ptr_idx = bindings.LDKNodeIdLookUp_new(impl);
58
59                 impl_holder.held = new NodeIdLookUp(null, ptr_idx[0]);
60                 impl_holder.held.instance_idx = ptr_idx[1];
61                 impl_holder.held.bindings_instance = impl;
62                 return impl_holder.held;
63         }
64
65         /**
66          * Returns the node id of the forwarding node's channel counterparty with `short_channel_id`.
67          * 
68          * Here, the forwarding node is referring to the node of the [`OnionMessenger`] parameterized
69          * by the [`NodeIdLookUp`] and the counterparty to one of that node's peers.
70          * 
71          * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
72          * 
73          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
74          */
75         public byte[] next_node_id(long short_channel_id) {
76                 long ret = bindings.NodeIdLookUp_next_node_id(this.ptr, short_channel_id);
77                 GC.KeepAlive(this);
78                 GC.KeepAlive(short_channel_id);
79                 if (ret >= 0 && ret <= 4096) { return null; }
80                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
81                 return ret_conv;
82         }
83
84 }
85 } } }