[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / FinalOnionHopData.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  * Information communicated in the onion to the recipient for multi-part tracking and proof that
13  * the payment is associated with an invoice.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class FinalOnionHopData extends CommonBase {
17         FinalOnionHopData(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.FinalOnionHopData_free(ptr); }
22         }
23
24         /**
25          * When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
26          * Because it is generated by the recipient and included in the invoice, it also provides
27          * proof to the recipient that the payment was sent by someone with the generated invoice.
28          */
29         public byte[] get_payment_secret() {
30                 byte[] ret = bindings.FinalOnionHopData_get_payment_secret(this.ptr);
31                 Reference.reachabilityFence(this);
32                 return ret;
33         }
34
35         /**
36          * When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
37          * Because it is generated by the recipient and included in the invoice, it also provides
38          * proof to the recipient that the payment was sent by someone with the generated invoice.
39          */
40         public void set_payment_secret(byte[] val) {
41                 bindings.FinalOnionHopData_set_payment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
42                 Reference.reachabilityFence(this);
43                 Reference.reachabilityFence(val);
44         }
45
46         /**
47          * The intended total amount that this payment is for.
48          * 
49          * Message serialization may panic if this value is more than 21 million Bitcoin.
50          */
51         public long get_total_msat() {
52                 long ret = bindings.FinalOnionHopData_get_total_msat(this.ptr);
53                 Reference.reachabilityFence(this);
54                 return ret;
55         }
56
57         /**
58          * The intended total amount that this payment is for.
59          * 
60          * Message serialization may panic if this value is more than 21 million Bitcoin.
61          */
62         public void set_total_msat(long val) {
63                 bindings.FinalOnionHopData_set_total_msat(this.ptr, val);
64                 Reference.reachabilityFence(this);
65                 Reference.reachabilityFence(val);
66         }
67
68         /**
69          * Constructs a new FinalOnionHopData given each field
70          */
71         public static FinalOnionHopData of(byte[] payment_secret_arg, long total_msat_arg) {
72                 long ret = bindings.FinalOnionHopData_new(InternalUtils.check_arr_len(payment_secret_arg, 32), total_msat_arg);
73                 Reference.reachabilityFence(payment_secret_arg);
74                 Reference.reachabilityFence(total_msat_arg);
75                 if (ret >= 0 && ret <= 4096) { return null; }
76                 org.ldk.structs.FinalOnionHopData ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FinalOnionHopData(null, ret); }
77                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
78                 return ret_hu_conv;
79         }
80
81         long clone_ptr() {
82                 long ret = bindings.FinalOnionHopData_clone_ptr(this.ptr);
83                 Reference.reachabilityFence(this);
84                 return ret;
85         }
86
87         /**
88          * Creates a copy of the FinalOnionHopData
89          */
90         public FinalOnionHopData clone() {
91                 long ret = bindings.FinalOnionHopData_clone(this.ptr);
92                 Reference.reachabilityFence(this);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.FinalOnionHopData ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FinalOnionHopData(null, ret); }
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96                 return ret_hu_conv;
97         }
98
99         /**
100          * Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read
101          */
102         public byte[] write() {
103                 byte[] ret = bindings.FinalOnionHopData_write(this.ptr);
104                 Reference.reachabilityFence(this);
105                 return ret;
106         }
107
108         /**
109          * Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write
110          */
111         public static Result_FinalOnionHopDataDecodeErrorZ read(byte[] ser) {
112                 long ret = bindings.FinalOnionHopData_read(ser);
113                 Reference.reachabilityFence(ser);
114                 if (ret >= 0 && ret <= 4096) { return null; }
115                 Result_FinalOnionHopDataDecodeErrorZ ret_hu_conv = Result_FinalOnionHopDataDecodeErrorZ.constr_from_ptr(ret);
116                 return ret_hu_conv;
117         }
118
119 }