Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / HTLCOutputInCommitment.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 javax.annotation.Nullable;
8
9
10 /**
11  * Information about an HTLC as it appears in a commitment transaction
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class HTLCOutputInCommitment extends CommonBase {
15         HTLCOutputInCommitment(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.HTLCOutputInCommitment_free(ptr); }
20         }
21
22         /**
23          * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
24          * Note that this is not the same as whether it is ountbound *from us*. To determine that you
25          * need to compare this value to whether the commitment transaction in question is that of
26          * the counterparty or our own.
27          */
28         public boolean get_offered() {
29                 boolean ret = bindings.HTLCOutputInCommitment_get_offered(this.ptr);
30                 return ret;
31         }
32
33         /**
34          * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
35          * Note that this is not the same as whether it is ountbound *from us*. To determine that you
36          * need to compare this value to whether the commitment transaction in question is that of
37          * the counterparty or our own.
38          */
39         public void set_offered(boolean val) {
40                 bindings.HTLCOutputInCommitment_set_offered(this.ptr, val);
41         }
42
43         /**
44          * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
45          * this divided by 1000.
46          */
47         public long get_amount_msat() {
48                 long ret = bindings.HTLCOutputInCommitment_get_amount_msat(this.ptr);
49                 return ret;
50         }
51
52         /**
53          * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
54          * this divided by 1000.
55          */
56         public void set_amount_msat(long val) {
57                 bindings.HTLCOutputInCommitment_set_amount_msat(this.ptr, val);
58         }
59
60         /**
61          * The CLTV lock-time at which this HTLC expires.
62          */
63         public int get_cltv_expiry() {
64                 int ret = bindings.HTLCOutputInCommitment_get_cltv_expiry(this.ptr);
65                 return ret;
66         }
67
68         /**
69          * The CLTV lock-time at which this HTLC expires.
70          */
71         public void set_cltv_expiry(int val) {
72                 bindings.HTLCOutputInCommitment_set_cltv_expiry(this.ptr, val);
73         }
74
75         /**
76          * The hash of the preimage which unlocks this HTLC.
77          */
78         public byte[] get_payment_hash() {
79                 byte[] ret = bindings.HTLCOutputInCommitment_get_payment_hash(this.ptr);
80                 return ret;
81         }
82
83         /**
84          * The hash of the preimage which unlocks this HTLC.
85          */
86         public void set_payment_hash(byte[] val) {
87                 bindings.HTLCOutputInCommitment_set_payment_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
88         }
89
90         /**
91          * The position within the commitment transactions' outputs. This may be None if the value is
92          * below the dust limit (in which case no output appears in the commitment transaction and the
93          * value is spent to additional transaction fees).
94          */
95         public Option_u32Z get_transaction_output_index() {
96                 long ret = bindings.HTLCOutputInCommitment_get_transaction_output_index(this.ptr);
97                 if (ret >= 0 && ret <= 4096) { return null; }
98                 Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret);
99                 ret_hu_conv.ptrs_to.add(this);
100                 return ret_hu_conv;
101         }
102
103         /**
104          * The position within the commitment transactions' outputs. This may be None if the value is
105          * below the dust limit (in which case no output appears in the commitment transaction and the
106          * value is spent to additional transaction fees).
107          */
108         public void set_transaction_output_index(Option_u32Z val) {
109                 bindings.HTLCOutputInCommitment_set_transaction_output_index(this.ptr, val.ptr);
110         }
111
112         /**
113          * Constructs a new HTLCOutputInCommitment given each field
114          */
115         public static HTLCOutputInCommitment of(boolean offered_arg, long amount_msat_arg, int cltv_expiry_arg, byte[] payment_hash_arg, Option_u32Z transaction_output_index_arg) {
116                 long ret = bindings.HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, InternalUtils.check_arr_len(payment_hash_arg, 32), transaction_output_index_arg.ptr);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HTLCOutputInCommitment(null, ret); }
119                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
120                 return ret_hu_conv;
121         }
122
123         long clone_ptr() {
124                 long ret = bindings.HTLCOutputInCommitment_clone_ptr(this.ptr);
125                 return ret;
126         }
127
128         /**
129          * Creates a copy of the HTLCOutputInCommitment
130          */
131         public HTLCOutputInCommitment clone() {
132                 long ret = bindings.HTLCOutputInCommitment_clone(this.ptr);
133                 if (ret >= 0 && ret <= 4096) { return null; }
134                 HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HTLCOutputInCommitment(null, ret); }
135                 ret_hu_conv.ptrs_to.add(this);
136                 return ret_hu_conv;
137         }
138
139         /**
140          * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read
141          */
142         public byte[] write() {
143                 byte[] ret = bindings.HTLCOutputInCommitment_write(this.ptr);
144                 return ret;
145         }
146
147         /**
148          * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write
149          */
150         public static Result_HTLCOutputInCommitmentDecodeErrorZ read(byte[] ser) {
151                 long ret = bindings.HTLCOutputInCommitment_read(ser);
152                 if (ret >= 0 && ret <= 4096) { return null; }
153                 Result_HTLCOutputInCommitmentDecodeErrorZ ret_hu_conv = Result_HTLCOutputInCommitmentDecodeErrorZ.constr_from_ptr(ret);
154                 return ret_hu_conv;
155         }
156
157 }