[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / OnionMessagePath.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A path for sending an [`OnionMessage`].
11  */
12 public class OnionMessagePath : CommonBase {
13         internal OnionMessagePath(object _dummy, long ptr) : base(ptr) { }
14         ~OnionMessagePath() {
15                 if (ptr != 0) { bindings.OnionMessagePath_free(ptr); }
16         }
17
18         /**
19          * Nodes on the path between the sender and the destination.
20          * 
21          * Returns a copy of the field.
22          */
23         public byte[][] get_intermediate_nodes() {
24                 long ret = bindings.OnionMessagePath_get_intermediate_nodes(this.ptr);
25                 GC.KeepAlive(this);
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;
33                 }
34                 bindings.free_buffer(ret);
35                 return ret_conv_8_arr;
36         }
37
38         /**
39          * Nodes on the path between the sender and the destination.
40          */
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)))));
43                 GC.KeepAlive(this);
44                 GC.KeepAlive(val);
45         }
46
47         /**
48          * The recipient of the message.
49          */
50         public Destination get_destination() {
51                 long ret = bindings.OnionMessagePath_get_destination(this.ptr);
52                 GC.KeepAlive(this);
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); };
56                 return ret_hu_conv;
57         }
58
59         /**
60          * The recipient of the message.
61          */
62         public void set_destination(org.ldk.structs.Destination val) {
63                 bindings.OnionMessagePath_set_destination(this.ptr, val.ptr);
64                 GC.KeepAlive(this);
65                 GC.KeepAlive(val);
66                 if (this != null) { this.ptrs_to.AddLast(val); };
67         }
68
69         /**
70          * Addresses that may be used to connect to [`OnionMessagePath::first_node`].
71          * 
72          * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use
73          * this to initiate such a connection.
74          * 
75          * Returns a copy of the field.
76          */
77         public Option_CVec_SocketAddressZZ get_first_node_addresses() {
78                 long ret = bindings.OnionMessagePath_get_first_node_addresses(this.ptr);
79                 GC.KeepAlive(this);
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); };
83                 return ret_hu_conv;
84         }
85
86         /**
87          * Addresses that may be used to connect to [`OnionMessagePath::first_node`].
88          * 
89          * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use
90          * this to initiate such a connection.
91          */
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);
94                 GC.KeepAlive(this);
95                 GC.KeepAlive(val);
96                 if (this != null) { this.ptrs_to.AddLast(val); };
97         }
98
99         /**
100          * Constructs a new OnionMessagePath given each field
101          */
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); };
112                 return ret_hu_conv;
113         }
114
115         internal long clone_ptr() {
116                 long ret = bindings.OnionMessagePath_clone_ptr(this.ptr);
117                 GC.KeepAlive(this);
118                 return ret;
119         }
120
121         /**
122          * Creates a copy of the OnionMessagePath
123          */
124         public OnionMessagePath clone() {
125                 long ret = bindings.OnionMessagePath_clone(this.ptr);
126                 GC.KeepAlive(this);
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); };
130                 return ret_hu_conv;
131         }
132
133         /**
134          * Returns the first node in the path.
135          */
136         public byte[] first_node() {
137                 long ret = bindings.OnionMessagePath_first_node(this.ptr);
138                 GC.KeepAlive(this);
139                 if (ret >= 0 && ret <= 4096) { return null; }
140                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
141                 return ret_conv;
142         }
143
144 }
145 } } }