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.ptr);
59 Reference.reachabilityFence(this);
60 Reference.reachabilityFence(val);
61 if (this != null) { this.ptrs_to.add(val); };
65 * Context for the receiver of this payment.
67 public PaymentContext get_payment_context() {
68 long ret = bindings.ReceiveTlvs_get_payment_context(this.ptr);
69 Reference.reachabilityFence(this);
70 if (ret >= 0 && ret <= 4096) { return null; }
71 org.ldk.structs.PaymentContext ret_hu_conv = org.ldk.structs.PaymentContext.constr_from_ptr(ret);
72 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
77 * Context for the receiver of this payment.
79 public void set_payment_context(org.ldk.structs.PaymentContext val) {
80 bindings.ReceiveTlvs_set_payment_context(this.ptr, val.ptr);
81 Reference.reachabilityFence(this);
82 Reference.reachabilityFence(val);
83 if (this != null) { this.ptrs_to.add(val); };
87 * Constructs a new ReceiveTlvs given each field
89 public static ReceiveTlvs of(byte[] payment_secret_arg, org.ldk.structs.PaymentConstraints payment_constraints_arg, org.ldk.structs.PaymentContext payment_context_arg) {
90 long ret = bindings.ReceiveTlvs_new(InternalUtils.check_arr_len(payment_secret_arg, 32), payment_constraints_arg.ptr, payment_context_arg.ptr);
91 Reference.reachabilityFence(payment_secret_arg);
92 Reference.reachabilityFence(payment_constraints_arg);
93 Reference.reachabilityFence(payment_context_arg);
94 if (ret >= 0 && ret <= 4096) { return null; }
95 org.ldk.structs.ReceiveTlvs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReceiveTlvs(null, ret); }
96 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
97 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_constraints_arg); };
98 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_context_arg); };
103 long ret = bindings.ReceiveTlvs_clone_ptr(this.ptr);
104 Reference.reachabilityFence(this);
109 * Creates a copy of the ReceiveTlvs
111 public ReceiveTlvs clone() {
112 long ret = bindings.ReceiveTlvs_clone(this.ptr);
113 Reference.reachabilityFence(this);
114 if (ret >= 0 && ret <= 4096) { return null; }
115 org.ldk.structs.ReceiveTlvs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReceiveTlvs(null, ret); }
116 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
121 * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read
123 public byte[] write() {
124 byte[] ret = bindings.ReceiveTlvs_write(this.ptr);
125 Reference.reachabilityFence(this);