6 namespace org { namespace ldk { namespace structs {
10 * Information used to route a payment.
12 public class PaymentParameters : CommonBase {
13 internal PaymentParameters(object _dummy, long ptr) : base(ptr) { }
14 ~PaymentParameters() {
15 if (ptr != 0) { bindings.PaymentParameters_free(ptr); }
19 * Information about the payee, such as their features and route hints for their channels.
21 public Payee get_payee() {
22 long ret = bindings.PaymentParameters_get_payee(this.ptr);
24 if (ret >= 0 && ret <= 4096) { return null; }
25 org.ldk.structs.Payee ret_hu_conv = org.ldk.structs.Payee.constr_from_ptr(ret);
26 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
31 * Information about the payee, such as their features and route hints for their channels.
33 public void set_payee(org.ldk.structs.Payee val) {
34 bindings.PaymentParameters_set_payee(this.ptr, val.ptr);
37 if (this != null) { this.ptrs_to.AddLast(val); };
41 * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
43 public Option_u64Z get_expiry_time() {
44 long ret = bindings.PaymentParameters_get_expiry_time(this.ptr);
46 if (ret >= 0 && ret <= 4096) { return null; }
47 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
48 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
53 * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
55 public void set_expiry_time(org.ldk.structs.Option_u64Z val) {
56 bindings.PaymentParameters_set_expiry_time(this.ptr, val.ptr);
59 if (this != null) { this.ptrs_to.AddLast(val); };
63 * The maximum total CLTV delta we accept for the route.
64 * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
66 public int get_max_total_cltv_expiry_delta() {
67 int ret = bindings.PaymentParameters_get_max_total_cltv_expiry_delta(this.ptr);
73 * The maximum total CLTV delta we accept for the route.
74 * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
76 public void set_max_total_cltv_expiry_delta(int val) {
77 bindings.PaymentParameters_set_max_total_cltv_expiry_delta(this.ptr, val);
83 * The maximum number of paths that may be used by (MPP) payments.
84 * Defaults to [`DEFAULT_MAX_PATH_COUNT`].
86 public byte get_max_path_count() {
87 byte ret = bindings.PaymentParameters_get_max_path_count(this.ptr);
93 * The maximum number of paths that may be used by (MPP) payments.
94 * Defaults to [`DEFAULT_MAX_PATH_COUNT`].
96 public void set_max_path_count(byte val) {
97 bindings.PaymentParameters_set_max_path_count(this.ptr, val);
103 * Selects the maximum share of a channel's total capacity which will be sent over a channel,
104 * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
105 * a lower value prefers to send larger MPP parts, potentially saturating channels and
106 * increasing failure probability for those paths.
108 * Note that this restriction will be relaxed during pathfinding after paths which meet this
109 * restriction have been found. While paths which meet this criteria will be searched for, it
110 * is ultimately up to the scorer to select them over other paths.
112 * A value of 0 will allow payments up to and including a channel's total announced usable
113 * capacity, a value of one will only use up to half its capacity, two 1/4, etc.
117 public byte get_max_channel_saturation_power_of_half() {
118 byte ret = bindings.PaymentParameters_get_max_channel_saturation_power_of_half(this.ptr);
124 * Selects the maximum share of a channel's total capacity which will be sent over a channel,
125 * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
126 * a lower value prefers to send larger MPP parts, potentially saturating channels and
127 * increasing failure probability for those paths.
129 * Note that this restriction will be relaxed during pathfinding after paths which meet this
130 * restriction have been found. While paths which meet this criteria will be searched for, it
131 * is ultimately up to the scorer to select them over other paths.
133 * A value of 0 will allow payments up to and including a channel's total announced usable
134 * capacity, a value of one will only use up to half its capacity, two 1/4, etc.
138 public void set_max_channel_saturation_power_of_half(byte val) {
139 bindings.PaymentParameters_set_max_channel_saturation_power_of_half(this.ptr, val);
145 * A list of SCIDs which this payment was previously attempted over and which caused the
146 * payment to fail. Future attempts for the same payment shouldn't be relayed through any of
149 * Returns a copy of the field.
151 public long[] get_previously_failed_channels() {
152 long ret = bindings.PaymentParameters_get_previously_failed_channels(this.ptr);
154 if (ret >= 0 && ret <= 4096) { return null; }
155 long[] ret_conv = InternalUtils.decodeUint64Array(ret);
160 * A list of SCIDs which this payment was previously attempted over and which caused the
161 * payment to fail. Future attempts for the same payment shouldn't be relayed through any of
164 public void set_previously_failed_channels(long[] val) {
165 bindings.PaymentParameters_set_previously_failed_channels(this.ptr, InternalUtils.encodeUint64Array(val));
171 * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this
172 * payment was previously attempted over and which caused the payment to fail. Future attempts
173 * for the same payment shouldn't be relayed through any of these blinded paths.
175 * Returns a copy of the field.
177 public long[] get_previously_failed_blinded_path_idxs() {
178 long ret = bindings.PaymentParameters_get_previously_failed_blinded_path_idxs(this.ptr);
180 if (ret >= 0 && ret <= 4096) { return null; }
181 long[] ret_conv = InternalUtils.decodeUint64Array(ret);
186 * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this
187 * payment was previously attempted over and which caused the payment to fail. Future attempts
188 * for the same payment shouldn't be relayed through any of these blinded paths.
190 public void set_previously_failed_blinded_path_idxs(long[] val) {
191 bindings.PaymentParameters_set_previously_failed_blinded_path_idxs(this.ptr, InternalUtils.encodeUint64Array(val));
197 * Constructs a new PaymentParameters given each field
199 public static PaymentParameters of(org.ldk.structs.Payee payee_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, long[] previously_failed_blinded_path_idxs_arg) {
200 long ret = bindings.PaymentParameters_new(payee_arg.ptr, expiry_time_arg.ptr, max_total_cltv_expiry_delta_arg, max_path_count_arg, max_channel_saturation_power_of_half_arg, InternalUtils.encodeUint64Array(previously_failed_channels_arg), InternalUtils.encodeUint64Array(previously_failed_blinded_path_idxs_arg));
201 GC.KeepAlive(payee_arg);
202 GC.KeepAlive(expiry_time_arg);
203 GC.KeepAlive(max_total_cltv_expiry_delta_arg);
204 GC.KeepAlive(max_path_count_arg);
205 GC.KeepAlive(max_channel_saturation_power_of_half_arg);
206 GC.KeepAlive(previously_failed_channels_arg);
207 GC.KeepAlive(previously_failed_blinded_path_idxs_arg);
208 if (ret >= 0 && ret <= 4096) { return null; }
209 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
210 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
211 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payee_arg); };
212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(expiry_time_arg); };
216 internal long clone_ptr() {
217 long ret = bindings.PaymentParameters_clone_ptr(this.ptr);
223 * Creates a copy of the PaymentParameters
225 public PaymentParameters clone() {
226 long ret = bindings.PaymentParameters_clone(this.ptr);
228 if (ret >= 0 && ret <= 4096) { return null; }
229 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
230 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
235 * Generates a non-cryptographic 64-bit hash of the PaymentParameters.
238 long ret = bindings.PaymentParameters_hash(this.ptr);
243 public override int GetHashCode() {
244 return (int)this.hash();
247 * Checks if two PaymentParameterss contain equal inner contents.
248 * This ignores pointers and is_owned flags and looks at the values in fields.
249 * Two objects with NULL inner values will be considered "equal" here.
251 public bool eq(org.ldk.structs.PaymentParameters b) {
252 bool ret = bindings.PaymentParameters_eq(this.ptr, b.ptr);
255 if (this != null) { this.ptrs_to.AddLast(b); };
259 public override bool Equals(object o) {
260 if (!(o is PaymentParameters)) return false;
261 return this.eq((PaymentParameters)o);
264 * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read
266 public byte[] write() {
267 long ret = bindings.PaymentParameters_write(this.ptr);
269 if (ret >= 0 && ret <= 4096) { return null; }
270 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
275 * Read a PaymentParameters from a byte array, created by PaymentParameters_write
277 public static Result_PaymentParametersDecodeErrorZ read(byte[] ser, int arg) {
278 long ret = bindings.PaymentParameters_read(InternalUtils.encodeUint8Array(ser), arg);
281 if (ret >= 0 && ret <= 4096) { return null; }
282 Result_PaymentParametersDecodeErrorZ ret_hu_conv = Result_PaymentParametersDecodeErrorZ.constr_from_ptr(ret);
287 * Creates a payee with the node id of the given `pubkey`.
289 * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has
292 public static PaymentParameters from_node_id(byte[] payee_pubkey, int final_cltv_expiry_delta) {
293 long ret = bindings.PaymentParameters_from_node_id(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payee_pubkey, 33)), final_cltv_expiry_delta);
294 GC.KeepAlive(payee_pubkey);
295 GC.KeepAlive(final_cltv_expiry_delta);
296 if (ret >= 0 && ret <= 4096) { return null; }
297 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
298 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
303 * Creates a payee with the node id of the given `pubkey` to use for keysend payments.
305 * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has
308 * Note that MPP keysend is not widely supported yet. The `allow_mpp` lets you choose
309 * whether your router will be allowed to find a multi-part route for this payment. If you
310 * set `allow_mpp` to true, you should ensure a payment secret is set on send, likely via
311 * [`RecipientOnionFields::secret_only`].
313 * [`RecipientOnionFields::secret_only`]: crate::ln::channelmanager::RecipientOnionFields::secret_only
315 public static PaymentParameters for_keysend(byte[] payee_pubkey, int final_cltv_expiry_delta, bool allow_mpp) {
316 long ret = bindings.PaymentParameters_for_keysend(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payee_pubkey, 33)), final_cltv_expiry_delta, allow_mpp);
317 GC.KeepAlive(payee_pubkey);
318 GC.KeepAlive(final_cltv_expiry_delta);
319 GC.KeepAlive(allow_mpp);
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); };
327 * Creates parameters for paying to a blinded payee from the provided invoice. Sets
328 * [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and
329 * [`PaymentParameters::expiry_time`].
331 public static PaymentParameters from_bolt12_invoice(org.ldk.structs.Bolt12Invoice invoice) {
332 long ret = bindings.PaymentParameters_from_bolt12_invoice(invoice.ptr);
333 GC.KeepAlive(invoice);
334 if (ret >= 0 && ret <= 4096) { return null; }
335 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
336 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
337 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
342 * Creates parameters for paying to a blinded payee from the provided blinded route hints.
344 public static PaymentParameters blinded(TwoTuple_BlindedPayInfoBlindedPathZ[] blinded_route_hints) {
345 long ret = bindings.PaymentParameters_blinded(InternalUtils.encodeUint64Array(InternalUtils.mapArray(blinded_route_hints, blinded_route_hints_conv_37 => blinded_route_hints_conv_37.ptr)));
346 GC.KeepAlive(blinded_route_hints);
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.AddLast(ret_hu_conv); };