1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A path for sending an [`OnionMessage`].
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class OnionMessagePath extends CommonBase {
16 OnionMessagePath(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.OnionMessagePath_free(ptr); }
24 * Nodes on the path between the sender and the destination.
26 * Returns a copy of the field.
28 public byte[][] get_intermediate_nodes() {
29 byte[][] ret = bindings.OnionMessagePath_get_intermediate_nodes(this.ptr);
30 Reference.reachabilityFence(this);
35 * Nodes on the path between the sender and the destination.
37 public void set_intermediate_nodes(byte[][] val) {
38 bindings.OnionMessagePath_set_intermediate_nodes(this.ptr, val != null ? Arrays.stream(val).map(val_conv_8 -> InternalUtils.check_arr_len(val_conv_8, 33)).toArray(byte[][]::new) : null);
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * The recipient of the message.
46 public Destination get_destination() {
47 long ret = bindings.OnionMessagePath_get_destination(this.ptr);
48 Reference.reachabilityFence(this);
49 if (ret >= 0 && ret <= 4096) { return null; }
50 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
51 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
56 * The recipient of the message.
58 public void set_destination(org.ldk.structs.Destination val) {
59 bindings.OnionMessagePath_set_destination(this.ptr, val.ptr);
60 Reference.reachabilityFence(this);
61 Reference.reachabilityFence(val);
62 if (this != null) { this.ptrs_to.add(val); };
66 * Addresses that may be used to connect to [`OnionMessagePath::first_node`].
68 * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use
69 * this to initiate such a connection.
71 * Returns a copy of the field.
73 public Option_CVec_SocketAddressZZ get_first_node_addresses() {
74 long ret = bindings.OnionMessagePath_get_first_node_addresses(this.ptr);
75 Reference.reachabilityFence(this);
76 if (ret >= 0 && ret <= 4096) { return null; }
77 org.ldk.structs.Option_CVec_SocketAddressZZ ret_hu_conv = org.ldk.structs.Option_CVec_SocketAddressZZ.constr_from_ptr(ret);
78 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
83 * Addresses that may be used to connect to [`OnionMessagePath::first_node`].
85 * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use
86 * this to initiate such a connection.
88 public void set_first_node_addresses(org.ldk.structs.Option_CVec_SocketAddressZZ val) {
89 bindings.OnionMessagePath_set_first_node_addresses(this.ptr, val.ptr);
90 Reference.reachabilityFence(this);
91 Reference.reachabilityFence(val);
92 if (this != null) { this.ptrs_to.add(val); };
96 * Constructs a new OnionMessagePath given each field
98 public static OnionMessagePath of(byte[][] intermediate_nodes_arg, org.ldk.structs.Destination destination_arg, org.ldk.structs.Option_CVec_SocketAddressZZ first_node_addresses_arg) {
99 long ret = bindings.OnionMessagePath_new(intermediate_nodes_arg != null ? Arrays.stream(intermediate_nodes_arg).map(intermediate_nodes_arg_conv_8 -> InternalUtils.check_arr_len(intermediate_nodes_arg_conv_8, 33)).toArray(byte[][]::new) : null, destination_arg.ptr, first_node_addresses_arg.ptr);
100 Reference.reachabilityFence(intermediate_nodes_arg);
101 Reference.reachabilityFence(destination_arg);
102 Reference.reachabilityFence(first_node_addresses_arg);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); }
105 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
106 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(destination_arg); };
107 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(first_node_addresses_arg); };
112 long ret = bindings.OnionMessagePath_clone_ptr(this.ptr);
113 Reference.reachabilityFence(this);
118 * Creates a copy of the OnionMessagePath
120 public OnionMessagePath clone() {
121 long ret = bindings.OnionMessagePath_clone(this.ptr);
122 Reference.reachabilityFence(this);
123 if (ret >= 0 && ret <= 4096) { return null; }
124 org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); }
125 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
130 * Returns the first node in the path.
132 public byte[] first_node() {
133 byte[] ret = bindings.OnionMessagePath_first_node(this.ptr);
134 Reference.reachabilityFence(this);