[C#] Check in initial auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / PaymentParameters.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  * The recipient of a payment.
11  */
12 public class PaymentParameters : CommonBase {
13         internal PaymentParameters(object _dummy, long ptr) : base(ptr) { }
14         ~PaymentParameters() {
15                 if (ptr != 0) { bindings.PaymentParameters_free(ptr); }
16         }
17
18         /**
19          * The node id of the payee.
20          */
21         public byte[] get_payee_pubkey() {
22                 byte[] ret = bindings.PaymentParameters_get_payee_pubkey(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * The node id of the payee.
29          */
30         public void set_payee_pubkey(byte[] val) {
31                 bindings.PaymentParameters_set_payee_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         /**
37          * Features supported by the payee.
38          * 
39          * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
40          * does not contain any features.
41          * 
42          * [`for_keysend`]: Self::for_keysend
43          * 
44          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
45          */
46         public InvoiceFeatures get_features() {
47                 long ret = bindings.PaymentParameters_get_features(this.ptr);
48                 GC.KeepAlive(this);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 org.ldk.structs.InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceFeatures(null, ret); }
51                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
52                 return ret_hu_conv;
53         }
54
55         /**
56          * Features supported by the payee.
57          * 
58          * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
59          * does not contain any features.
60          * 
61          * [`for_keysend`]: Self::for_keysend
62          * 
63          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
64          */
65         public void set_features(org.ldk.structs.InvoiceFeatures val) {
66                 bindings.PaymentParameters_set_features(this.ptr, val == null ? 0 : val.ptr);
67                 GC.KeepAlive(this);
68                 GC.KeepAlive(val);
69                 if (this != null) { this.ptrs_to.AddLast(val); };
70         }
71
72         /**
73          * Hints for routing to the payee, containing channels connecting the payee to public nodes.
74          */
75         public RouteHint[] get_route_hints() {
76                 long[] ret = bindings.PaymentParameters_get_route_hints(this.ptr);
77                 GC.KeepAlive(this);
78                 int ret_conv_11_len = ret.Length;
79                 RouteHint[] ret_conv_11_arr = new RouteHint[ret_conv_11_len];
80                 for (int l = 0; l < ret_conv_11_len; l++) {
81                         long ret_conv_11 = ret[l];
82                         org.ldk.structs.RouteHint ret_conv_11_hu_conv = null; if (ret_conv_11 < 0 || ret_conv_11 > 4096) { ret_conv_11_hu_conv = new org.ldk.structs.RouteHint(null, ret_conv_11); }
83                         if (ret_conv_11_hu_conv != null) { ret_conv_11_hu_conv.ptrs_to.AddLast(this); };
84                         ret_conv_11_arr[l] = ret_conv_11_hu_conv;
85                 }
86                 return ret_conv_11_arr;
87         }
88
89         /**
90          * Hints for routing to the payee, containing channels connecting the payee to public nodes.
91          */
92         public void set_route_hints(RouteHint[] val) {
93                 bindings.PaymentParameters_set_route_hints(this.ptr, val != null ? InternalUtils.mapArray(val, val_conv_11 => val_conv_11 == null ? 0 : val_conv_11.ptr) : null);
94                 GC.KeepAlive(this);
95                 GC.KeepAlive(val);
96                 foreach (RouteHint val_conv_11 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_11); }; };
97         }
98
99         /**
100          * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
101          */
102         public Option_u64Z get_expiry_time() {
103                 long ret = bindings.PaymentParameters_get_expiry_time(this.ptr);
104                 GC.KeepAlive(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
108                 return ret_hu_conv;
109         }
110
111         /**
112          * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
113          */
114         public void set_expiry_time(org.ldk.structs.Option_u64Z val) {
115                 bindings.PaymentParameters_set_expiry_time(this.ptr, val.ptr);
116                 GC.KeepAlive(this);
117                 GC.KeepAlive(val);
118         }
119
120         /**
121          * The maximum total CLTV delta we accept for the route.
122          * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
123          */
124         public int get_max_total_cltv_expiry_delta() {
125                 int ret = bindings.PaymentParameters_get_max_total_cltv_expiry_delta(this.ptr);
126                 GC.KeepAlive(this);
127                 return ret;
128         }
129
130         /**
131          * The maximum total CLTV delta we accept for the route.
132          * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
133          */
134         public void set_max_total_cltv_expiry_delta(int val) {
135                 bindings.PaymentParameters_set_max_total_cltv_expiry_delta(this.ptr, val);
136                 GC.KeepAlive(this);
137                 GC.KeepAlive(val);
138         }
139
140         /**
141          * The maximum number of paths that may be used by (MPP) payments.
142          * Defaults to [`DEFAULT_MAX_PATH_COUNT`].
143          */
144         public byte get_max_path_count() {
145                 byte ret = bindings.PaymentParameters_get_max_path_count(this.ptr);
146                 GC.KeepAlive(this);
147                 return ret;
148         }
149
150         /**
151          * The maximum number of paths that may be used by (MPP) payments.
152          * Defaults to [`DEFAULT_MAX_PATH_COUNT`].
153          */
154         public void set_max_path_count(byte val) {
155                 bindings.PaymentParameters_set_max_path_count(this.ptr, val);
156                 GC.KeepAlive(this);
157                 GC.KeepAlive(val);
158         }
159
160         /**
161          * Selects the maximum share of a channel's total capacity which will be sent over a channel,
162          * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
163          * a lower value prefers to send larger MPP parts, potentially saturating channels and
164          * increasing failure probability for those paths.
165          * 
166          * Note that this restriction will be relaxed during pathfinding after paths which meet this
167          * restriction have been found. While paths which meet this criteria will be searched for, it
168          * is ultimately up to the scorer to select them over other paths.
169          * 
170          * A value of 0 will allow payments up to and including a channel's total announced usable
171          * capacity, a value of one will only use up to half its capacity, two 1/4, etc.
172          * 
173          * Default value: 2
174          */
175         public byte get_max_channel_saturation_power_of_half() {
176                 byte ret = bindings.PaymentParameters_get_max_channel_saturation_power_of_half(this.ptr);
177                 GC.KeepAlive(this);
178                 return ret;
179         }
180
181         /**
182          * Selects the maximum share of a channel's total capacity which will be sent over a channel,
183          * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
184          * a lower value prefers to send larger MPP parts, potentially saturating channels and
185          * increasing failure probability for those paths.
186          * 
187          * Note that this restriction will be relaxed during pathfinding after paths which meet this
188          * restriction have been found. While paths which meet this criteria will be searched for, it
189          * is ultimately up to the scorer to select them over other paths.
190          * 
191          * A value of 0 will allow payments up to and including a channel's total announced usable
192          * capacity, a value of one will only use up to half its capacity, two 1/4, etc.
193          * 
194          * Default value: 2
195          */
196         public void set_max_channel_saturation_power_of_half(byte val) {
197                 bindings.PaymentParameters_set_max_channel_saturation_power_of_half(this.ptr, val);
198                 GC.KeepAlive(this);
199                 GC.KeepAlive(val);
200         }
201
202         /**
203          * A list of SCIDs which this payment was previously attempted over and which caused the
204          * payment to fail. Future attempts for the same payment shouldn't be relayed through any of
205          * these SCIDs.
206          * 
207          * Returns a copy of the field.
208          */
209         public long[] get_previously_failed_channels() {
210                 long[] ret = bindings.PaymentParameters_get_previously_failed_channels(this.ptr);
211                 GC.KeepAlive(this);
212                 return ret;
213         }
214
215         /**
216          * A list of SCIDs which this payment was previously attempted over and which caused the
217          * payment to fail. Future attempts for the same payment shouldn't be relayed through any of
218          * these SCIDs.
219          */
220         public void set_previously_failed_channels(long[] val) {
221                 bindings.PaymentParameters_set_previously_failed_channels(this.ptr, val);
222                 GC.KeepAlive(this);
223                 GC.KeepAlive(val);
224         }
225
226         /**
227          * Constructs a new PaymentParameters given each field
228          */
229         public static PaymentParameters of(byte[] payee_pubkey_arg, org.ldk.structs.InvoiceFeatures features_arg, RouteHint[] route_hints_arg, org.ldk.structs.Option_u64Z expiry_time_arg, int max_total_cltv_expiry_delta_arg, byte max_path_count_arg, byte max_channel_saturation_power_of_half_arg, long[] previously_failed_channels_arg) {
230                 long ret = bindings.PaymentParameters_new(InternalUtils.check_arr_len(payee_pubkey_arg, 33), features_arg == null ? 0 : features_arg.ptr, route_hints_arg != null ? InternalUtils.mapArray(route_hints_arg, route_hints_arg_conv_11 => route_hints_arg_conv_11 == null ? 0 : route_hints_arg_conv_11.ptr) : null, expiry_time_arg.ptr, max_total_cltv_expiry_delta_arg, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg);
231                 GC.KeepAlive(payee_pubkey_arg);
232                 GC.KeepAlive(features_arg);
233                 GC.KeepAlive(route_hints_arg);
234                 GC.KeepAlive(expiry_time_arg);
235                 GC.KeepAlive(max_total_cltv_expiry_delta_arg);
236                 GC.KeepAlive(max_path_count_arg);
237                 GC.KeepAlive(max_channel_saturation_power_of_half_arg);
238                 GC.KeepAlive(previously_failed_channels_arg);
239                 if (ret >= 0 && ret <= 4096) { return null; }
240                 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
241                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
242                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
243                 foreach (RouteHint route_hints_arg_conv_11 in route_hints_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_hints_arg_conv_11); }; };
244                 return ret_hu_conv;
245         }
246
247         internal long clone_ptr() {
248                 long ret = bindings.PaymentParameters_clone_ptr(this.ptr);
249                 GC.KeepAlive(this);
250                 return ret;
251         }
252
253         /**
254          * Creates a copy of the PaymentParameters
255          */
256         public PaymentParameters clone() {
257                 long ret = bindings.PaymentParameters_clone(this.ptr);
258                 GC.KeepAlive(this);
259                 if (ret >= 0 && ret <= 4096) { return null; }
260                 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
261                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
262                 return ret_hu_conv;
263         }
264
265         /**
266          * Checks if two PaymentParameterss contain equal inner contents.
267          */
268         public long hash() {
269                 long ret = bindings.PaymentParameters_hash(this.ptr);
270                 GC.KeepAlive(this);
271                 return ret;
272         }
273
274         public override int GetHashCode() {
275                 return (int)this.hash();
276         }
277         /**
278          * Checks if two PaymentParameterss contain equal inner contents.
279          * This ignores pointers and is_owned flags and looks at the values in fields.
280          * Two objects with NULL inner values will be considered "equal" here.
281          */
282         public bool eq(org.ldk.structs.PaymentParameters b) {
283                 bool ret = bindings.PaymentParameters_eq(this.ptr, b == null ? 0 : b.ptr);
284                 GC.KeepAlive(this);
285                 GC.KeepAlive(b);
286                 if (this != null) { this.ptrs_to.AddLast(b); };
287                 return ret;
288         }
289
290         public override bool Equals(object o) {
291                 if (!(o is PaymentParameters)) return false;
292                 return this.eq((PaymentParameters)o);
293         }
294         /**
295          * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read
296          */
297         public byte[] write() {
298                 byte[] ret = bindings.PaymentParameters_write(this.ptr);
299                 GC.KeepAlive(this);
300                 return ret;
301         }
302
303         /**
304          * Read a PaymentParameters from a byte array, created by PaymentParameters_write
305          */
306         public static Result_PaymentParametersDecodeErrorZ read(byte[] ser) {
307                 long ret = bindings.PaymentParameters_read(ser);
308                 GC.KeepAlive(ser);
309                 if (ret >= 0 && ret <= 4096) { return null; }
310                 Result_PaymentParametersDecodeErrorZ ret_hu_conv = Result_PaymentParametersDecodeErrorZ.constr_from_ptr(ret);
311                 return ret_hu_conv;
312         }
313
314         /**
315          * Creates a payee with the node id of the given `pubkey`.
316          */
317         public static PaymentParameters from_node_id(byte[] payee_pubkey) {
318                 long ret = bindings.PaymentParameters_from_node_id(InternalUtils.check_arr_len(payee_pubkey, 33));
319                 GC.KeepAlive(payee_pubkey);
320                 if (ret >= 0 && ret <= 4096) { return null; }
321                 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
322                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
323                 return ret_hu_conv;
324         }
325
326         /**
327          * Creates a payee with the node id of the given `pubkey` to use for keysend payments.
328          */
329         public static PaymentParameters for_keysend(byte[] payee_pubkey) {
330                 long ret = bindings.PaymentParameters_for_keysend(InternalUtils.check_arr_len(payee_pubkey, 33));
331                 GC.KeepAlive(payee_pubkey);
332                 if (ret >= 0 && ret <= 4096) { return null; }
333                 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
334                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
335                 return ret_hu_conv;
336         }
337
338 }
339 } } }