[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / BlindedPath.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  * Onion messages and payments can be sent and received to blinded paths, which serve to hide the
11  * identity of the recipient.
12  */
13 public class BlindedPath : CommonBase {
14         internal BlindedPath(object _dummy, long ptr) : base(ptr) { }
15         ~BlindedPath() {
16                 if (ptr != 0) { bindings.BlindedPath_free(ptr); }
17         }
18
19         /**
20          * To send to a blinded path, the sender first finds a route to the unblinded
21          * `introduction_node_id`, which can unblind its [`encrypted_payload`] to find out the onion
22          * message or payment's next hop and forward it along.
23          * 
24          * [`encrypted_payload`]: BlindedHop::encrypted_payload
25          */
26         public byte[] get_introduction_node_id() {
27                 long ret = bindings.BlindedPath_get_introduction_node_id(this.ptr);
28                 GC.KeepAlive(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
31                 return ret_conv;
32         }
33
34         /**
35          * To send to a blinded path, the sender first finds a route to the unblinded
36          * `introduction_node_id`, which can unblind its [`encrypted_payload`] to find out the onion
37          * message or payment's next hop and forward it along.
38          * 
39          * [`encrypted_payload`]: BlindedHop::encrypted_payload
40          */
41         public void set_introduction_node_id(byte[] val) {
42                 bindings.BlindedPath_set_introduction_node_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
43                 GC.KeepAlive(this);
44                 GC.KeepAlive(val);
45         }
46
47         /**
48          * Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion
49          * message or payment.
50          * 
51          * [`encrypted_payload`]: BlindedHop::encrypted_payload
52          */
53         public byte[] get_blinding_point() {
54                 long ret = bindings.BlindedPath_get_blinding_point(this.ptr);
55                 GC.KeepAlive(this);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
58                 return ret_conv;
59         }
60
61         /**
62          * Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion
63          * message or payment.
64          * 
65          * [`encrypted_payload`]: BlindedHop::encrypted_payload
66          */
67         public void set_blinding_point(byte[] val) {
68                 bindings.BlindedPath_set_blinding_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
69                 GC.KeepAlive(this);
70                 GC.KeepAlive(val);
71         }
72
73         /**
74          * The hops composing the blinded path.
75          */
76         public BlindedHop[] get_blinded_hops() {
77                 long ret = bindings.BlindedPath_get_blinded_hops(this.ptr);
78                 GC.KeepAlive(this);
79                 if (ret >= 0 && ret <= 4096) { return null; }
80                 int ret_conv_12_len = InternalUtils.getArrayLength(ret);
81                 BlindedHop[] ret_conv_12_arr = new BlindedHop[ret_conv_12_len];
82                 for (int m = 0; m < ret_conv_12_len; m++) {
83                         long ret_conv_12 = InternalUtils.getU64ArrayElem(ret, m);
84                         org.ldk.structs.BlindedHop ret_conv_12_hu_conv = null; if (ret_conv_12 < 0 || ret_conv_12 > 4096) { ret_conv_12_hu_conv = new org.ldk.structs.BlindedHop(null, ret_conv_12); }
85                         if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.AddLast(this); };
86                         ret_conv_12_arr[m] = ret_conv_12_hu_conv;
87                 }
88                 bindings.free_buffer(ret);
89                 return ret_conv_12_arr;
90         }
91
92         /**
93          * The hops composing the blinded path.
94          */
95         public void set_blinded_hops(BlindedHop[] val) {
96                 bindings.BlindedPath_set_blinded_hops(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_12 => val_conv_12 == null ? 0 : val_conv_12.ptr)));
97                 GC.KeepAlive(this);
98                 GC.KeepAlive(val);
99                 foreach (BlindedHop val_conv_12 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_12); }; };
100         }
101
102         /**
103          * Constructs a new BlindedPath given each field
104          */
105         public static BlindedPath of(byte[] introduction_node_id_arg, byte[] blinding_point_arg, BlindedHop[] blinded_hops_arg) {
106                 long ret = bindings.BlindedPath_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(introduction_node_id_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(blinding_point_arg, 33)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(blinded_hops_arg, blinded_hops_arg_conv_12 => blinded_hops_arg_conv_12 == null ? 0 : blinded_hops_arg_conv_12.ptr)));
107                 GC.KeepAlive(introduction_node_id_arg);
108                 GC.KeepAlive(blinding_point_arg);
109                 GC.KeepAlive(blinded_hops_arg);
110                 if (ret >= 0 && ret <= 4096) { return null; }
111                 org.ldk.structs.BlindedPath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedPath(null, ret); }
112                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
113                 foreach (BlindedHop blinded_hops_arg_conv_12 in blinded_hops_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(blinded_hops_arg_conv_12); }; };
114                 return ret_hu_conv;
115         }
116
117         internal long clone_ptr() {
118                 long ret = bindings.BlindedPath_clone_ptr(this.ptr);
119                 GC.KeepAlive(this);
120                 return ret;
121         }
122
123         /**
124          * Creates a copy of the BlindedPath
125          */
126         public BlindedPath clone() {
127                 long ret = bindings.BlindedPath_clone(this.ptr);
128                 GC.KeepAlive(this);
129                 if (ret >= 0 && ret <= 4096) { return null; }
130                 org.ldk.structs.BlindedPath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedPath(null, ret); }
131                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
132                 return ret_hu_conv;
133         }
134
135         /**
136          * Generates a non-cryptographic 64-bit hash of the BlindedPath.
137          */
138         public long hash() {
139                 long ret = bindings.BlindedPath_hash(this.ptr);
140                 GC.KeepAlive(this);
141                 return ret;
142         }
143
144         public override int GetHashCode() {
145                 return (int)this.hash();
146         }
147         /**
148          * Checks if two BlindedPaths contain equal inner contents.
149          * This ignores pointers and is_owned flags and looks at the values in fields.
150          * Two objects with NULL inner values will be considered "equal" here.
151          */
152         public bool eq(org.ldk.structs.BlindedPath b) {
153                 bool ret = bindings.BlindedPath_eq(this.ptr, b == null ? 0 : b.ptr);
154                 GC.KeepAlive(this);
155                 GC.KeepAlive(b);
156                 if (this != null) { this.ptrs_to.AddLast(b); };
157                 return ret;
158         }
159
160         public override bool Equals(object o) {
161                 if (!(o is BlindedPath)) return false;
162                 return this.eq((BlindedPath)o);
163         }
164         /**
165          * Create a one-hop blinded path for a message.
166          */
167         public static Result_BlindedPathNoneZ one_hop_for_message(byte[] recipient_node_id, org.ldk.structs.EntropySource entropy_source) {
168                 long ret = bindings.BlindedPath_one_hop_for_message(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(recipient_node_id, 33)), entropy_source.ptr);
169                 GC.KeepAlive(recipient_node_id);
170                 GC.KeepAlive(entropy_source);
171                 if (ret >= 0 && ret <= 4096) { return null; }
172                 Result_BlindedPathNoneZ ret_hu_conv = Result_BlindedPathNoneZ.constr_from_ptr(ret);
173                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
174                 return ret_hu_conv;
175         }
176
177         /**
178          * Create a blinded path for an onion message, to be forwarded along `node_pks`. The last node
179          * pubkey in `node_pks` will be the destination node.
180          * 
181          * Errors if no hops are provided or if `node_pk`(s) are invalid.
182          */
183         public static Result_BlindedPathNoneZ new_for_message(byte[][] node_pks, org.ldk.structs.EntropySource entropy_source) {
184                 long ret = bindings.BlindedPath_new_for_message(InternalUtils.encodeUint64Array(InternalUtils.mapArray(node_pks, node_pks_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(node_pks_conv_8, 33)))), entropy_source.ptr);
185                 GC.KeepAlive(node_pks);
186                 GC.KeepAlive(entropy_source);
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 Result_BlindedPathNoneZ ret_hu_conv = Result_BlindedPathNoneZ.constr_from_ptr(ret);
189                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
190                 return ret_hu_conv;
191         }
192
193         /**
194          * Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read
195          */
196         public byte[] write() {
197                 long ret = bindings.BlindedPath_write(this.ptr);
198                 GC.KeepAlive(this);
199                 if (ret >= 0 && ret <= 4096) { return null; }
200                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
201                 return ret_conv;
202         }
203
204         /**
205          * Read a BlindedPath from a byte array, created by BlindedPath_write
206          */
207         public static Result_BlindedPathDecodeErrorZ read(byte[] ser) {
208                 long ret = bindings.BlindedPath_read(InternalUtils.encodeUint8Array(ser));
209                 GC.KeepAlive(ser);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 Result_BlindedPathDecodeErrorZ ret_hu_conv = Result_BlindedPathDecodeErrorZ.constr_from_ptr(ret);
212                 return ret_hu_conv;
213         }
214
215 }
216 } } }