[Java] Update auto-generated bindings to 0.0.117
[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 == null ? 0 : val.ptr);
59                 Reference.reachabilityFence(this);
60                 Reference.reachabilityFence(val);
61                 if (this != null) { this.ptrs_to.add(val); };
62         }
63
64         /**
65          * Constructs a new ReceiveTlvs given each field
66          */
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); };
75                 return ret_hu_conv;
76         }
77
78         long clone_ptr() {
79                 long ret = bindings.ReceiveTlvs_clone_ptr(this.ptr);
80                 Reference.reachabilityFence(this);
81                 return ret;
82         }
83
84         /**
85          * Creates a copy of the ReceiveTlvs
86          */
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); };
93                 return ret_hu_conv;
94         }
95
96         /**
97          * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read
98          */
99         public byte[] write() {
100                 byte[] ret = bindings.ReceiveTlvs_write(this.ptr);
101                 Reference.reachabilityFence(this);
102                 return ret;
103         }
104
105         /**
106          * Read a ReceiveTlvs from a byte array, created by ReceiveTlvs_write
107          */
108         public static Result_ReceiveTlvsDecodeErrorZ read(byte[] ser) {
109                 long ret = bindings.ReceiveTlvs_read(ser);
110                 Reference.reachabilityFence(ser);
111                 if (ret >= 0 && ret <= 4096) { return null; }
112                 Result_ReceiveTlvsDecodeErrorZ ret_hu_conv = Result_ReceiveTlvsDecodeErrorZ.constr_from_ptr(ret);
113                 return ret_hu_conv;
114         }
115
116 }