6 namespace org { namespace ldk { namespace structs {
10 * The recipient of 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 * The node id of the payee.
21 public byte[] get_payee_pubkey() {
22 byte[] ret = bindings.PaymentParameters_get_payee_pubkey(this.ptr);
28 * The node id of the payee.
30 public void set_payee_pubkey(byte[] val) {
31 bindings.PaymentParameters_set_payee_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
37 * Features supported by the payee.
39 * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
40 * does not contain any features.
42 * [`for_keysend`]: Self::for_keysend
44 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
46 public InvoiceFeatures get_features() {
47 long ret = bindings.PaymentParameters_get_features(this.ptr);
49 if (ret >= 0 && ret <= 4096) { return null; }
50 org.ldk.structs.InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceFeatures(null, ret); }
51 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
56 * Features supported by the payee.
58 * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
59 * does not contain any features.
61 * [`for_keysend`]: Self::for_keysend
63 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
65 public void set_features(org.ldk.structs.InvoiceFeatures val) {
66 bindings.PaymentParameters_set_features(this.ptr, val == null ? 0 : val.ptr);
69 if (this != null) { this.ptrs_to.AddLast(val); };
73 * Hints for routing to the payee, containing channels connecting the payee to public nodes.
75 public RouteHint[] get_route_hints() {
76 long[] ret = bindings.PaymentParameters_get_route_hints(this.ptr);
78 int ret_conv_11_len = ret.Length;
79 RouteHint[] ret_conv_11_arr = new RouteHint[ret_conv_11_len];
80 for (int l = 0; l < ret_conv_11_len; l++) {
81 long ret_conv_11 = ret[l];
82 org.ldk.structs.RouteHint ret_conv_11_hu_conv = null; if (ret_conv_11 < 0 || ret_conv_11 > 4096) { ret_conv_11_hu_conv = new org.ldk.structs.RouteHint(null, ret_conv_11); }
83 if (ret_conv_11_hu_conv != null) { ret_conv_11_hu_conv.ptrs_to.AddLast(this); };
84 ret_conv_11_arr[l] = ret_conv_11_hu_conv;
86 return ret_conv_11_arr;
90 * Hints for routing to the payee, containing channels connecting the payee to public nodes.
92 public void set_route_hints(RouteHint[] val) {
93 bindings.PaymentParameters_set_route_hints(this.ptr, val != null ? InternalUtils.mapArray(val, val_conv_11 => val_conv_11 == null ? 0 : val_conv_11.ptr) : null);
96 foreach (RouteHint val_conv_11 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_11); }; };
100 * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
102 public Option_u64Z get_expiry_time() {
103 long ret = bindings.PaymentParameters_get_expiry_time(this.ptr);
105 if (ret >= 0 && ret <= 4096) { return null; }
106 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
107 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
112 * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
114 public void set_expiry_time(org.ldk.structs.Option_u64Z val) {
115 bindings.PaymentParameters_set_expiry_time(this.ptr, val.ptr);
121 * The maximum total CLTV delta we accept for the route.
122 * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
124 public int get_max_total_cltv_expiry_delta() {
125 int ret = bindings.PaymentParameters_get_max_total_cltv_expiry_delta(this.ptr);
131 * The maximum total CLTV delta we accept for the route.
132 * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
134 public void set_max_total_cltv_expiry_delta(int val) {
135 bindings.PaymentParameters_set_max_total_cltv_expiry_delta(this.ptr, val);
141 * The maximum number of paths that may be used by (MPP) payments.
142 * Defaults to [`DEFAULT_MAX_PATH_COUNT`].
144 public byte get_max_path_count() {
145 byte ret = bindings.PaymentParameters_get_max_path_count(this.ptr);
151 * The maximum number of paths that may be used by (MPP) payments.
152 * Defaults to [`DEFAULT_MAX_PATH_COUNT`].
154 public void set_max_path_count(byte val) {
155 bindings.PaymentParameters_set_max_path_count(this.ptr, val);
161 * Selects the maximum share of a channel's total capacity which will be sent over a channel,
162 * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
163 * a lower value prefers to send larger MPP parts, potentially saturating channels and
164 * increasing failure probability for those paths.
166 * Note that this restriction will be relaxed during pathfinding after paths which meet this
167 * restriction have been found. While paths which meet this criteria will be searched for, it
168 * is ultimately up to the scorer to select them over other paths.
170 * A value of 0 will allow payments up to and including a channel's total announced usable
171 * capacity, a value of one will only use up to half its capacity, two 1/4, etc.
175 public byte get_max_channel_saturation_power_of_half() {
176 byte ret = bindings.PaymentParameters_get_max_channel_saturation_power_of_half(this.ptr);
182 * Selects the maximum share of a channel's total capacity which will be sent over a channel,
183 * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
184 * a lower value prefers to send larger MPP parts, potentially saturating channels and
185 * increasing failure probability for those paths.
187 * Note that this restriction will be relaxed during pathfinding after paths which meet this
188 * restriction have been found. While paths which meet this criteria will be searched for, it
189 * is ultimately up to the scorer to select them over other paths.
191 * A value of 0 will allow payments up to and including a channel's total announced usable
192 * capacity, a value of one will only use up to half its capacity, two 1/4, etc.
196 public void set_max_channel_saturation_power_of_half(byte val) {
197 bindings.PaymentParameters_set_max_channel_saturation_power_of_half(this.ptr, val);
203 * A list of SCIDs which this payment was previously attempted over and which caused the
204 * payment to fail. Future attempts for the same payment shouldn't be relayed through any of
207 * Returns a copy of the field.
209 public long[] get_previously_failed_channels() {
210 long[] ret = bindings.PaymentParameters_get_previously_failed_channels(this.ptr);
216 * A list of SCIDs which this payment was previously attempted over and which caused the
217 * payment to fail. Future attempts for the same payment shouldn't be relayed through any of
220 public void set_previously_failed_channels(long[] val) {
221 bindings.PaymentParameters_set_previously_failed_channels(this.ptr, val);
227 * Constructs a new PaymentParameters given each field
229 public static PaymentParameters of(byte[] payee_pubkey_arg, org.ldk.structs.InvoiceFeatures features_arg, RouteHint[] 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) {
230 long ret = bindings.PaymentParameters_new(InternalUtils.check_arr_len(payee_pubkey_arg, 33), features_arg == null ? 0 : features_arg.ptr, route_hints_arg != null ? InternalUtils.mapArray(route_hints_arg, route_hints_arg_conv_11 => route_hints_arg_conv_11 == null ? 0 : route_hints_arg_conv_11.ptr) : null, 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);
231 GC.KeepAlive(payee_pubkey_arg);
232 GC.KeepAlive(features_arg);
233 GC.KeepAlive(route_hints_arg);
234 GC.KeepAlive(expiry_time_arg);
235 GC.KeepAlive(max_total_cltv_expiry_delta_arg);
236 GC.KeepAlive(max_path_count_arg);
237 GC.KeepAlive(max_channel_saturation_power_of_half_arg);
238 GC.KeepAlive(previously_failed_channels_arg);
239 if (ret >= 0 && ret <= 4096) { return null; }
240 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
241 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
242 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
243 foreach (RouteHint route_hints_arg_conv_11 in route_hints_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_hints_arg_conv_11); }; };
247 internal long clone_ptr() {
248 long ret = bindings.PaymentParameters_clone_ptr(this.ptr);
254 * Creates a copy of the PaymentParameters
256 public PaymentParameters clone() {
257 long ret = bindings.PaymentParameters_clone(this.ptr);
259 if (ret >= 0 && ret <= 4096) { return null; }
260 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
261 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
266 * Checks if two PaymentParameterss contain equal inner contents.
269 long ret = bindings.PaymentParameters_hash(this.ptr);
274 public override int GetHashCode() {
275 return (int)this.hash();
278 * Checks if two PaymentParameterss contain equal inner contents.
279 * This ignores pointers and is_owned flags and looks at the values in fields.
280 * Two objects with NULL inner values will be considered "equal" here.
282 public bool eq(org.ldk.structs.PaymentParameters b) {
283 bool ret = bindings.PaymentParameters_eq(this.ptr, b == null ? 0 : b.ptr);
286 if (this != null) { this.ptrs_to.AddLast(b); };
290 public override bool Equals(object o) {
291 if (!(o is PaymentParameters)) return false;
292 return this.eq((PaymentParameters)o);
295 * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read
297 public byte[] write() {
298 byte[] ret = bindings.PaymentParameters_write(this.ptr);
304 * Read a PaymentParameters from a byte array, created by PaymentParameters_write
306 public static Result_PaymentParametersDecodeErrorZ read(byte[] ser) {
307 long ret = bindings.PaymentParameters_read(ser);
309 if (ret >= 0 && ret <= 4096) { return null; }
310 Result_PaymentParametersDecodeErrorZ ret_hu_conv = Result_PaymentParametersDecodeErrorZ.constr_from_ptr(ret);
315 * Creates a payee with the node id of the given `pubkey`.
317 public static PaymentParameters from_node_id(byte[] payee_pubkey) {
318 long ret = bindings.PaymentParameters_from_node_id(InternalUtils.check_arr_len(payee_pubkey, 33));
319 GC.KeepAlive(payee_pubkey);
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 a payee with the node id of the given `pubkey` to use for keysend payments.
329 public static PaymentParameters for_keysend(byte[] payee_pubkey) {
330 long ret = bindings.PaymentParameters_for_keysend(InternalUtils.check_arr_len(payee_pubkey, 33));
331 GC.KeepAlive(payee_pubkey);
332 if (ret >= 0 && ret <= 4096) { return null; }
333 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
334 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };