7 namespace org { namespace ldk { namespace structs {
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`.
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.
18 * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
20 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
22 byte[] next_node_id(long short_channel_id);
26 * An interface for looking up the node id of a channel counterparty for the purpose of forwarding
27 * an [`OnionMessage`].
29 * [`OnionMessage`]: crate::ln::msgs::OnionMessage
31 public class NodeIdLookUp : CommonBase {
32 internal bindings.LDKNodeIdLookUp bindings_instance;
33 internal long instance_idx;
35 internal NodeIdLookUp(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
37 if (ptr != 0) { bindings.NodeIdLookUp_free(ptr); }
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);
48 long result = InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(ret, 33));
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);
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;
66 * Returns the node id of the forwarding node's channel counterparty with `short_channel_id`.
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.
71 * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
73 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
75 public byte[] next_node_id(long short_channel_id) {
76 long ret = bindings.NodeIdLookUp_next_node_id(this.ptr, short_channel_id);
78 GC.KeepAlive(short_channel_id);
79 if (ret >= 0 && ret <= 4096) { return null; }
80 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);