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