6 namespace org { namespace ldk { namespace structs {
10 * A path for sending an [`OnionMessage`].
12 public class OnionMessagePath : CommonBase {
13 internal OnionMessagePath(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.OnionMessagePath_free(ptr); }
19 * Nodes on the path between the sender and the destination.
21 * Returns a copy of the field.
23 public byte[][] get_intermediate_nodes() {
24 long ret = bindings.OnionMessagePath_get_intermediate_nodes(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
28 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
29 for (int i = 0; i < ret_conv_8_len; i++) {
30 long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
31 byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
32 ret_conv_8_arr[i] = ret_conv_8_conv;
34 bindings.free_buffer(ret);
35 return ret_conv_8_arr;
39 * Nodes on the path between the sender and the destination.
41 public void set_intermediate_nodes(byte[][] val) {
42 bindings.OnionMessagePath_set_intermediate_nodes(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val_conv_8, 33)))));
48 * The recipient of the message.
50 public Destination get_destination() {
51 long ret = bindings.OnionMessagePath_get_destination(this.ptr);
53 if (ret >= 0 && ret <= 4096) { return null; }
54 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
55 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
60 * The recipient of the message.
62 public void set_destination(org.ldk.structs.Destination val) {
63 bindings.OnionMessagePath_set_destination(this.ptr, val.ptr);
66 if (this != null) { this.ptrs_to.AddLast(val); };
70 * Addresses that may be used to connect to [`OnionMessagePath::first_node`].
72 * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use
73 * this to initiate such a connection.
75 * Returns a copy of the field.
77 public Option_CVec_SocketAddressZZ get_first_node_addresses() {
78 long ret = bindings.OnionMessagePath_get_first_node_addresses(this.ptr);
80 if (ret >= 0 && ret <= 4096) { return null; }
81 org.ldk.structs.Option_CVec_SocketAddressZZ ret_hu_conv = org.ldk.structs.Option_CVec_SocketAddressZZ.constr_from_ptr(ret);
82 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
87 * Addresses that may be used to connect to [`OnionMessagePath::first_node`].
89 * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use
90 * this to initiate such a connection.
92 public void set_first_node_addresses(org.ldk.structs.Option_CVec_SocketAddressZZ val) {
93 bindings.OnionMessagePath_set_first_node_addresses(this.ptr, val.ptr);
96 if (this != null) { this.ptrs_to.AddLast(val); };
100 * Constructs a new OnionMessagePath given each field
102 public static OnionMessagePath of(byte[][] intermediate_nodes_arg, org.ldk.structs.Destination destination_arg, org.ldk.structs.Option_CVec_SocketAddressZZ first_node_addresses_arg) {
103 long ret = bindings.OnionMessagePath_new(InternalUtils.encodeUint64Array(InternalUtils.mapArray(intermediate_nodes_arg, intermediate_nodes_arg_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(intermediate_nodes_arg_conv_8, 33)))), destination_arg.ptr, first_node_addresses_arg.ptr);
104 GC.KeepAlive(intermediate_nodes_arg);
105 GC.KeepAlive(destination_arg);
106 GC.KeepAlive(first_node_addresses_arg);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); }
109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
110 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(destination_arg); };
111 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(first_node_addresses_arg); };
115 internal long clone_ptr() {
116 long ret = bindings.OnionMessagePath_clone_ptr(this.ptr);
122 * Creates a copy of the OnionMessagePath
124 public OnionMessagePath clone() {
125 long ret = bindings.OnionMessagePath_clone(this.ptr);
127 if (ret >= 0 && ret <= 4096) { return null; }
128 org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); }
129 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
134 * Returns the first node in the path.
136 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
138 public byte[] first_node() {
139 long ret = bindings.OnionMessagePath_first_node(this.ptr);
141 if (ret >= 0 && ret <= 4096) { return null; }
142 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);