[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / src / main / java / org / ldk / structs / ReceiveTlvs.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
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.
14  */
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 {
20                 super.finalize();
21                 if (ptr != 0) { bindings.ReceiveTlvs_free(ptr); }
22         }
23
24         /**
25          * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
26          */
27         public byte[] get_payment_secret() {
28                 byte[] ret = bindings.ReceiveTlvs_get_payment_secret(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         /**
34          * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
35          */
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);
40         }
41
42         /**
43          * Constraints for the receiver of this payment.
44          */
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); };
51                 return ret_hu_conv;
52         }
53
54         /**
55          * Constraints for the receiver of this payment.
56          */
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); };
62         }
63
64         /**
65          * Context for the receiver of this payment.
66          */
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); };
73                 return ret_hu_conv;
74         }
75
76         /**
77          * Context for the receiver of this payment.
78          */
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); };
84         }
85
86         /**
87          * Constructs a new ReceiveTlvs given each field
88          */
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); };
99                 return ret_hu_conv;
100         }
101
102         long clone_ptr() {
103                 long ret = bindings.ReceiveTlvs_clone_ptr(this.ptr);
104                 Reference.reachabilityFence(this);
105                 return ret;
106         }
107
108         /**
109          * Creates a copy of the ReceiveTlvs
110          */
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); };
117                 return ret_hu_conv;
118         }
119
120         /**
121          * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read
122          */
123         public byte[] write() {
124                 byte[] ret = bindings.ReceiveTlvs_write(this.ptr);
125                 Reference.reachabilityFence(this);
126                 return ret;
127         }
128
129 }