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 that is acceptable when relaying a payment over this [`BlindedHop`].
28 public int get_max_cltv_expiry() {
29 int ret = bindings.PaymentConstraints_get_max_cltv_expiry(this.ptr);
30 Reference.reachabilityFence(this);
35 * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`].
37 public void set_max_cltv_expiry(int val) {
38 bindings.PaymentConstraints_set_max_cltv_expiry(this.ptr, val);
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * The minimum value, in msat, that may be accepted by the node corresponding to this
47 public long get_htlc_minimum_msat() {
48 long ret = bindings.PaymentConstraints_get_htlc_minimum_msat(this.ptr);
49 Reference.reachabilityFence(this);
54 * The minimum value, in msat, that may be accepted by the node corresponding to this
57 public void set_htlc_minimum_msat(long val) {
58 bindings.PaymentConstraints_set_htlc_minimum_msat(this.ptr, val);
59 Reference.reachabilityFence(this);
60 Reference.reachabilityFence(val);
64 * Constructs a new PaymentConstraints given each field
66 public static PaymentConstraints of(int max_cltv_expiry_arg, long htlc_minimum_msat_arg) {
67 long ret = bindings.PaymentConstraints_new(max_cltv_expiry_arg, htlc_minimum_msat_arg);
68 Reference.reachabilityFence(max_cltv_expiry_arg);
69 Reference.reachabilityFence(htlc_minimum_msat_arg);
70 if (ret >= 0 && ret <= 4096) { return null; }
71 org.ldk.structs.PaymentConstraints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentConstraints(null, ret); }
72 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
77 long ret = bindings.PaymentConstraints_clone_ptr(this.ptr);
78 Reference.reachabilityFence(this);
83 * Creates a copy of the PaymentConstraints
85 public PaymentConstraints clone() {
86 long ret = bindings.PaymentConstraints_clone(this.ptr);
87 Reference.reachabilityFence(this);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.PaymentConstraints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentConstraints(null, ret); }
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
95 * Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read
97 public byte[] write() {
98 byte[] ret = bindings.PaymentConstraints_write(this.ptr);
99 Reference.reachabilityFence(this);
104 * Read a PaymentConstraints from a byte array, created by PaymentConstraints_write
106 public static Result_PaymentConstraintsDecodeErrorZ read(byte[] ser) {
107 long ret = bindings.PaymentConstraints_read(ser);
108 Reference.reachabilityFence(ser);
109 if (ret >= 0 && ret <= 4096) { return null; }
110 Result_PaymentConstraintsDecodeErrorZ ret_hu_conv = Result_PaymentConstraintsDecodeErrorZ.constr_from_ptr(ret);