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 * Constructs a new OnionMessagePath given each field
68 public static OnionMessagePath of(byte[][] intermediate_nodes_arg, org.ldk.structs.Destination destination_arg) {
69 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);
70 Reference.reachabilityFence(intermediate_nodes_arg);
71 Reference.reachabilityFence(destination_arg);
72 if (ret >= 0 && ret <= 4096) { return null; }
73 org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); }
74 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
75 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(destination_arg); };
80 long ret = bindings.OnionMessagePath_clone_ptr(this.ptr);
81 Reference.reachabilityFence(this);
86 * Creates a copy of the OnionMessagePath
88 public OnionMessagePath clone() {
89 long ret = bindings.OnionMessagePath_clone(this.ptr);
90 Reference.reachabilityFence(this);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); }
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };