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 * Data to construct a [`BlindedHop`] for receiving a payment. This payload is custom to LDK and
13 * may not be valid if received by another lightning implementation.
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class ReceiveTlvs extends CommonBase {
17 ReceiveTlvs(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.ReceiveTlvs_free(ptr); }
25 * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
27 public byte[] get_payment_secret() {
28 byte[] ret = bindings.ReceiveTlvs_get_payment_secret(this.ptr);
29 Reference.reachabilityFence(this);
34 * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
36 public void set_payment_secret(byte[] val) {
37 bindings.ReceiveTlvs_set_payment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
38 Reference.reachabilityFence(this);
39 Reference.reachabilityFence(val);
43 * Constraints for the receiver of this payment.
45 public PaymentConstraints get_payment_constraints() {
46 long ret = bindings.ReceiveTlvs_get_payment_constraints(this.ptr);
47 Reference.reachabilityFence(this);
48 if (ret >= 0 && ret <= 4096) { return null; }
49 org.ldk.structs.PaymentConstraints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentConstraints(null, ret); }
50 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
55 * Constraints for the receiver of this payment.
57 public void set_payment_constraints(org.ldk.structs.PaymentConstraints val) {
58 bindings.ReceiveTlvs_set_payment_constraints(this.ptr, val == null ? 0 : val.ptr);
59 Reference.reachabilityFence(this);
60 Reference.reachabilityFence(val);
61 if (this != null) { this.ptrs_to.add(val); };
65 * Constructs a new ReceiveTlvs given each field
67 public static ReceiveTlvs of(byte[] payment_secret_arg, org.ldk.structs.PaymentConstraints payment_constraints_arg) {
68 long ret = bindings.ReceiveTlvs_new(InternalUtils.check_arr_len(payment_secret_arg, 32), payment_constraints_arg == null ? 0 : payment_constraints_arg.ptr);
69 Reference.reachabilityFence(payment_secret_arg);
70 Reference.reachabilityFence(payment_constraints_arg);
71 if (ret >= 0 && ret <= 4096) { return null; }
72 org.ldk.structs.ReceiveTlvs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReceiveTlvs(null, ret); }
73 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
74 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_constraints_arg); };
79 long ret = bindings.ReceiveTlvs_clone_ptr(this.ptr);
80 Reference.reachabilityFence(this);
85 * Creates a copy of the ReceiveTlvs
87 public ReceiveTlvs clone() {
88 long ret = bindings.ReceiveTlvs_clone(this.ptr);
89 Reference.reachabilityFence(this);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 org.ldk.structs.ReceiveTlvs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReceiveTlvs(null, ret); }
92 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
97 * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read
99 public byte[] write() {
100 byte[] ret = bindings.ReceiveTlvs_write(this.ptr);
101 Reference.reachabilityFence(this);