1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Constraints for relaying over a given [`BlindedHop`].
14 * [`BlindedHop`]: crate::blinded_path::BlindedHop
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class PaymentConstraints extends CommonBase {
18 PaymentConstraints(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.PaymentConstraints_free(ptr); }
26 * The maximum total CLTV delta that is acceptable when relaying a payment over this
29 public int get_max_cltv_expiry() {
30 int ret = bindings.PaymentConstraints_get_max_cltv_expiry(this.ptr);
31 Reference.reachabilityFence(this);
36 * The maximum total CLTV delta that is acceptable when relaying a payment over this
39 public void set_max_cltv_expiry(int val) {
40 bindings.PaymentConstraints_set_max_cltv_expiry(this.ptr, val);
41 Reference.reachabilityFence(this);
42 Reference.reachabilityFence(val);
46 * The minimum value, in msat, that may be accepted by the node corresponding to this
49 public long get_htlc_minimum_msat() {
50 long ret = bindings.PaymentConstraints_get_htlc_minimum_msat(this.ptr);
51 Reference.reachabilityFence(this);
56 * The minimum value, in msat, that may be accepted by the node corresponding to this
59 public void set_htlc_minimum_msat(long val) {
60 bindings.PaymentConstraints_set_htlc_minimum_msat(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * Constructs a new PaymentConstraints given each field
68 public static PaymentConstraints of(int max_cltv_expiry_arg, long htlc_minimum_msat_arg) {
69 long ret = bindings.PaymentConstraints_new(max_cltv_expiry_arg, htlc_minimum_msat_arg);
70 Reference.reachabilityFence(max_cltv_expiry_arg);
71 Reference.reachabilityFence(htlc_minimum_msat_arg);
72 if (ret >= 0 && ret <= 4096) { return null; }
73 org.ldk.structs.PaymentConstraints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentConstraints(null, ret); }
74 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
79 long ret = bindings.PaymentConstraints_clone_ptr(this.ptr);
80 Reference.reachabilityFence(this);
85 * Creates a copy of the PaymentConstraints
87 public PaymentConstraints clone() {
88 long ret = bindings.PaymentConstraints_clone(this.ptr);
89 Reference.reachabilityFence(this);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 org.ldk.structs.PaymentConstraints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentConstraints(null, ret); }
92 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
97 * Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read
99 public byte[] write() {
100 byte[] ret = bindings.PaymentConstraints_write(this.ptr);
101 Reference.reachabilityFence(this);
106 * Read a PaymentConstraints from a byte array, created by PaymentConstraints_write
108 public static Result_PaymentConstraintsDecodeErrorZ read(byte[] ser) {
109 long ret = bindings.PaymentConstraints_read(ser);
110 Reference.reachabilityFence(ser);
111 if (ret >= 0 && ret <= 4096) { return null; }
112 Result_PaymentConstraintsDecodeErrorZ ret_hu_conv = Result_PaymentConstraintsDecodeErrorZ.constr_from_ptr(ret);