[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / RouteParameters.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  * Parameters needed to find a [`Route`].
13  * 
14  * Passed to [`find_route`] and [`build_route_from_hops`].
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class RouteParameters extends CommonBase {
18         RouteParameters(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.RouteParameters_free(ptr); }
23         }
24
25         /**
26          * The parameters of the failed payment path.
27          */
28         public PaymentParameters get_payment_params() {
29                 long ret = bindings.RouteParameters_get_payment_params(this.ptr);
30                 Reference.reachabilityFence(this);
31                 if (ret >= 0 && ret <= 4096) { return null; }
32                 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
33                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
34                 return ret_hu_conv;
35         }
36
37         /**
38          * The parameters of the failed payment path.
39          */
40         public void set_payment_params(org.ldk.structs.PaymentParameters val) {
41                 bindings.RouteParameters_set_payment_params(this.ptr, val == null ? 0 : val.ptr);
42                 Reference.reachabilityFence(this);
43                 Reference.reachabilityFence(val);
44                 if (this != null) { this.ptrs_to.add(val); };
45         }
46
47         /**
48          * The amount in msats sent on the failed payment path.
49          */
50         public long get_final_value_msat() {
51                 long ret = bindings.RouteParameters_get_final_value_msat(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * The amount in msats sent on the failed payment path.
58          */
59         public void set_final_value_msat(long val) {
60                 bindings.RouteParameters_set_final_value_msat(this.ptr, val);
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * The maximum total fees, in millisatoshi, that may accrue during route finding.
67          * 
68          * This limit also applies to the total fees that may arise while retrying failed payment
69          * paths.
70          * 
71          * Note that values below a few sats may result in some paths being spuriously ignored.
72          */
73         public Option_u64Z get_max_total_routing_fee_msat() {
74                 long ret = bindings.RouteParameters_get_max_total_routing_fee_msat(this.ptr);
75                 Reference.reachabilityFence(this);
76                 if (ret >= 0 && ret <= 4096) { return null; }
77                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
78                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
79                 return ret_hu_conv;
80         }
81
82         /**
83          * The maximum total fees, in millisatoshi, that may accrue during route finding.
84          * 
85          * This limit also applies to the total fees that may arise while retrying failed payment
86          * paths.
87          * 
88          * Note that values below a few sats may result in some paths being spuriously ignored.
89          */
90         public void set_max_total_routing_fee_msat(org.ldk.structs.Option_u64Z val) {
91                 bindings.RouteParameters_set_max_total_routing_fee_msat(this.ptr, val.ptr);
92                 Reference.reachabilityFence(this);
93                 Reference.reachabilityFence(val);
94                 if (this != null) { this.ptrs_to.add(val); };
95         }
96
97         /**
98          * Constructs a new RouteParameters given each field
99          */
100         public static RouteParameters of(org.ldk.structs.PaymentParameters payment_params_arg, long final_value_msat_arg, org.ldk.structs.Option_u64Z max_total_routing_fee_msat_arg) {
101                 long ret = bindings.RouteParameters_new(payment_params_arg == null ? 0 : payment_params_arg.ptr, final_value_msat_arg, max_total_routing_fee_msat_arg.ptr);
102                 Reference.reachabilityFence(payment_params_arg);
103                 Reference.reachabilityFence(final_value_msat_arg);
104                 Reference.reachabilityFence(max_total_routing_fee_msat_arg);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); }
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_params_arg); };
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(max_total_routing_fee_msat_arg); };
110                 return ret_hu_conv;
111         }
112
113         long clone_ptr() {
114                 long ret = bindings.RouteParameters_clone_ptr(this.ptr);
115                 Reference.reachabilityFence(this);
116                 return ret;
117         }
118
119         /**
120          * Creates a copy of the RouteParameters
121          */
122         public RouteParameters clone() {
123                 long ret = bindings.RouteParameters_clone(this.ptr);
124                 Reference.reachabilityFence(this);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); }
127                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
128                 return ret_hu_conv;
129         }
130
131         /**
132          * Generates a non-cryptographic 64-bit hash of the RouteParameters.
133          */
134         public long hash() {
135                 long ret = bindings.RouteParameters_hash(this.ptr);
136                 Reference.reachabilityFence(this);
137                 return ret;
138         }
139
140         @Override public int hashCode() {
141                 return (int)this.hash();
142         }
143         /**
144          * Checks if two RouteParameterss contain equal inner contents.
145          * This ignores pointers and is_owned flags and looks at the values in fields.
146          * Two objects with NULL inner values will be considered "equal" here.
147          */
148         public boolean eq(org.ldk.structs.RouteParameters b) {
149                 boolean ret = bindings.RouteParameters_eq(this.ptr, b == null ? 0 : b.ptr);
150                 Reference.reachabilityFence(this);
151                 Reference.reachabilityFence(b);
152                 if (this != null) { this.ptrs_to.add(b); };
153                 return ret;
154         }
155
156         @Override public boolean equals(Object o) {
157                 if (!(o instanceof RouteParameters)) return false;
158                 return this.eq((RouteParameters)o);
159         }
160         /**
161          * Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount.
162          * 
163          * [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats
164          */
165         public static RouteParameters from_payment_params_and_value(org.ldk.structs.PaymentParameters payment_params, long final_value_msat) {
166                 long ret = bindings.RouteParameters_from_payment_params_and_value(payment_params == null ? 0 : payment_params.ptr, final_value_msat);
167                 Reference.reachabilityFence(payment_params);
168                 Reference.reachabilityFence(final_value_msat);
169                 if (ret >= 0 && ret <= 4096) { return null; }
170                 org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); }
171                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
172                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_params); };
173                 return ret_hu_conv;
174         }
175
176         /**
177          * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
178          */
179         public byte[] write() {
180                 byte[] ret = bindings.RouteParameters_write(this.ptr);
181                 Reference.reachabilityFence(this);
182                 return ret;
183         }
184
185         /**
186          * Read a RouteParameters from a byte array, created by RouteParameters_write
187          */
188         public static Result_RouteParametersDecodeErrorZ read(byte[] ser) {
189                 long ret = bindings.RouteParameters_read(ser);
190                 Reference.reachabilityFence(ser);
191                 if (ret >= 0 && ret <= 4096) { return null; }
192                 Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
193                 return ret_hu_conv;
194         }
195
196 }