[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / NodeIdLookUp.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10 /**
11  * An interface for looking up the node id of a channel counterparty for the purpose of forwarding
12  * an [`OnionMessage`].
13  * 
14  * [`OnionMessage`]: crate::ln::msgs::OnionMessage
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class NodeIdLookUp extends CommonBase {
18         final bindings.LDKNodeIdLookUp bindings_instance;
19         NodeIdLookUp(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
20         private NodeIdLookUp(bindings.LDKNodeIdLookUp arg) {
21                 super(bindings.LDKNodeIdLookUp_new(arg));
22                 this.ptrs_to.add(arg);
23                 this.bindings_instance = arg;
24         }
25         @Override @SuppressWarnings("deprecation")
26         protected void finalize() throws Throwable {
27                 if (ptr != 0) { bindings.NodeIdLookUp_free(ptr); } super.finalize();
28         }
29         /**
30          * Destroys the object, freeing associated resources. After this call, any access
31          * to this object may result in a SEGFAULT or worse.
32          *
33          * You should generally NEVER call this method. You should let the garbage collector
34          * do this for you when it finalizes objects. However, it may be useful for types
35          * which represent locks and should be closed immediately to avoid holding locks
36          * until the GC runs.
37          */
38         public void destroy() {
39                 if (ptr != 0) { bindings.NodeIdLookUp_free(ptr); }
40                 ptr = 0;
41         }
42         public static interface NodeIdLookUpInterface {
43                 /**
44                  * Returns the node id of the forwarding node's channel counterparty with `short_channel_id`.
45                  * 
46                  * Here, the forwarding node is referring to the node of the [`OnionMessenger`] parameterized
47                  * by the [`NodeIdLookUp`] and the counterparty to one of that node's peers.
48                  * 
49                  * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
50                  * 
51                  * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
52                  */
53                 byte[] next_node_id(long short_channel_id);
54         }
55         private static class LDKNodeIdLookUpHolder { NodeIdLookUp held; }
56         public static NodeIdLookUp new_impl(NodeIdLookUpInterface arg) {
57                 final LDKNodeIdLookUpHolder impl_holder = new LDKNodeIdLookUpHolder();
58                 impl_holder.held = new NodeIdLookUp(new bindings.LDKNodeIdLookUp() {
59                         @Override public byte[] next_node_id(long short_channel_id) {
60                                 byte[] ret = arg.next_node_id(short_channel_id);
61                                 Reference.reachabilityFence(arg);
62                                 byte[] result = InternalUtils.check_arr_len(ret, 33);
63                                 return result;
64                         }
65                 });
66                 return impl_holder.held;
67         }
68         /**
69          * Returns the node id of the forwarding node's channel counterparty with `short_channel_id`.
70          * 
71          * Here, the forwarding node is referring to the node of the [`OnionMessenger`] parameterized
72          * by the [`NodeIdLookUp`] and the counterparty to one of that node's peers.
73          * 
74          * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
75          * 
76          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
77          */
78         @Nullable
79         public byte[] next_node_id(long short_channel_id) {
80                 byte[] ret = bindings.NodeIdLookUp_next_node_id(this.ptr, short_channel_id);
81                 Reference.reachabilityFence(this);
82                 Reference.reachabilityFence(short_channel_id);
83                 return ret;
84         }
85
86 }