6 namespace org { namespace ldk { namespace structs {
10 * Parameters needed to find a [`Route`].
12 * Passed to [`find_route`] and [`build_route_from_hops`].
14 public class RouteParameters : CommonBase {
15 internal RouteParameters(object _dummy, long ptr) : base(ptr) { }
17 if (ptr != 0) { bindings.RouteParameters_free(ptr); }
21 * The parameters of the failed payment path.
23 public PaymentParameters get_payment_params() {
24 long ret = bindings.RouteParameters_get_payment_params(this.ptr);
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); };
33 * The parameters of the failed payment path.
35 public void set_payment_params(org.ldk.structs.PaymentParameters val) {
36 bindings.RouteParameters_set_payment_params(this.ptr, val.ptr);
39 if (this != null) { this.ptrs_to.AddLast(val); };
43 * The amount in msats sent on the failed payment path.
45 public long get_final_value_msat() {
46 long ret = bindings.RouteParameters_get_final_value_msat(this.ptr);
52 * The amount in msats sent on the failed payment path.
54 public void set_final_value_msat(long val) {
55 bindings.RouteParameters_set_final_value_msat(this.ptr, val);
61 * The maximum total fees, in millisatoshi, that may accrue during route finding.
63 * This limit also applies to the total fees that may arise while retrying failed payment
66 * Note that values below a few sats may result in some paths being spuriously ignored.
68 public Option_u64Z get_max_total_routing_fee_msat() {
69 long ret = bindings.RouteParameters_get_max_total_routing_fee_msat(this.ptr);
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); };
78 * The maximum total fees, in millisatoshi, that may accrue during route finding.
80 * This limit also applies to the total fees that may arise while retrying failed payment
83 * Note that values below a few sats may result in some paths being spuriously ignored.
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);
89 if (this != null) { this.ptrs_to.AddLast(val); };
93 * Constructs a new RouteParameters given each field
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.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); };
108 internal long clone_ptr() {
109 long ret = bindings.RouteParameters_clone_ptr(this.ptr);
115 * Creates a copy of the RouteParameters
117 public RouteParameters clone() {
118 long ret = bindings.RouteParameters_clone(this.ptr);
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); };
127 * Generates a non-cryptographic 64-bit hash of the RouteParameters.
130 long ret = bindings.RouteParameters_hash(this.ptr);
135 public override int GetHashCode() {
136 return (int)this.hash();
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.
143 public bool eq(org.ldk.structs.RouteParameters b) {
144 bool ret = bindings.RouteParameters_eq(this.ptr, b.ptr);
147 if (this != null) { this.ptrs_to.AddLast(b); };
151 public override bool Equals(object o) {
152 if (!(o is RouteParameters)) return false;
153 return this.eq((RouteParameters)o);
156 * Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount.
158 * [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats
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.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); };
172 * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
174 public byte[] write() {
175 long ret = bindings.RouteParameters_write(this.ptr);
177 if (ret >= 0 && ret <= 4096) { return null; }
178 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
183 * Read a RouteParameters from a byte array, created by RouteParameters_write
185 public static Result_RouteParametersDecodeErrorZ read(byte[] ser) {
186 long ret = bindings.RouteParameters_read(InternalUtils.encodeUint8Array(ser));
188 if (ret >= 0 && ret <= 4096) { return null; }
189 Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);