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