X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FPaymentConstraints.java;fp=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FPaymentConstraints.java;h=90953d289b5a8fe83a62c98f5adfc39577db4991;hb=07d5d868dfe064aadb28a7f7ca6002c16be9723d;hp=0000000000000000000000000000000000000000;hpb=32973ea2749f8efd05b543dd774763513013b38b;p=ldk-java diff --git a/src/main/java/org/ldk/structs/PaymentConstraints.java b/src/main/java/org/ldk/structs/PaymentConstraints.java new file mode 100644 index 00000000..90953d28 --- /dev/null +++ b/src/main/java/org/ldk/structs/PaymentConstraints.java @@ -0,0 +1,116 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import java.lang.ref.Reference; +import javax.annotation.Nullable; + + +/** + * Constraints for relaying over a given [`BlindedHop`]. + * + * [`BlindedHop`]: crate::blinded_path::BlindedHop + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class PaymentConstraints extends CommonBase { + PaymentConstraints(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.PaymentConstraints_free(ptr); } + } + + /** + * The maximum total CLTV delta that is acceptable when relaying a payment over this + * [`BlindedHop`]. + */ + public int get_max_cltv_expiry() { + int ret = bindings.PaymentConstraints_get_max_cltv_expiry(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * The maximum total CLTV delta that is acceptable when relaying a payment over this + * [`BlindedHop`]. + */ + public void set_max_cltv_expiry(int val) { + bindings.PaymentConstraints_set_max_cltv_expiry(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * The minimum value, in msat, that may be accepted by the node corresponding to this + * [`BlindedHop`]. + */ + public long get_htlc_minimum_msat() { + long ret = bindings.PaymentConstraints_get_htlc_minimum_msat(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * The minimum value, in msat, that may be accepted by the node corresponding to this + * [`BlindedHop`]. + */ + public void set_htlc_minimum_msat(long val) { + bindings.PaymentConstraints_set_htlc_minimum_msat(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * Constructs a new PaymentConstraints given each field + */ + public static PaymentConstraints of(int max_cltv_expiry_arg, long htlc_minimum_msat_arg) { + long ret = bindings.PaymentConstraints_new(max_cltv_expiry_arg, htlc_minimum_msat_arg); + Reference.reachabilityFence(max_cltv_expiry_arg); + Reference.reachabilityFence(htlc_minimum_msat_arg); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.PaymentConstraints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentConstraints(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; + return ret_hu_conv; + } + + long clone_ptr() { + long ret = bindings.PaymentConstraints_clone_ptr(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Creates a copy of the PaymentConstraints + */ + public PaymentConstraints clone() { + long ret = bindings.PaymentConstraints_clone(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.PaymentConstraints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentConstraints(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; + } + + /** + * Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read + */ + public byte[] write() { + byte[] ret = bindings.PaymentConstraints_write(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Read a PaymentConstraints from a byte array, created by PaymentConstraints_write + */ + public static Result_PaymentConstraintsDecodeErrorZ read(byte[] ser) { + long ret = bindings.PaymentConstraints_read(ser); + Reference.reachabilityFence(ser); + if (ret >= 0 && ret <= 4096) { return null; } + Result_PaymentConstraintsDecodeErrorZ ret_hu_conv = Result_PaymentConstraintsDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +}