Update CI references to 0.0.122
[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 java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Information about an HTLC as it appears in a commitment transaction
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class HTLCOutputInCommitment extends CommonBase {
16         HTLCOutputInCommitment(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.HTLCOutputInCommitment_free(ptr); }
21         }
22
23         /**
24          * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
25          * Note that this is not the same as whether it is ountbound *from us*. To determine that you
26          * need to compare this value to whether the commitment transaction in question is that of
27          * the counterparty or our own.
28          */
29         public boolean get_offered() {
30                 boolean ret = bindings.HTLCOutputInCommitment_get_offered(this.ptr);
31                 Reference.reachabilityFence(this);
32                 return ret;
33         }
34
35         /**
36          * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
37          * Note that this is not the same as whether it is ountbound *from us*. To determine that you
38          * need to compare this value to whether the commitment transaction in question is that of
39          * the counterparty or our own.
40          */
41         public void set_offered(boolean val) {
42                 bindings.HTLCOutputInCommitment_set_offered(this.ptr, val);
43                 Reference.reachabilityFence(this);
44                 Reference.reachabilityFence(val);
45         }
46
47         /**
48          * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
49          * this divided by 1000.
50          */
51         public long get_amount_msat() {
52                 long ret = bindings.HTLCOutputInCommitment_get_amount_msat(this.ptr);
53                 Reference.reachabilityFence(this);
54                 return ret;
55         }
56
57         /**
58          * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
59          * this divided by 1000.
60          */
61         public void set_amount_msat(long val) {
62                 bindings.HTLCOutputInCommitment_set_amount_msat(this.ptr, val);
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(val);
65         }
66
67         /**
68          * The CLTV lock-time at which this HTLC expires.
69          */
70         public int get_cltv_expiry() {
71                 int ret = bindings.HTLCOutputInCommitment_get_cltv_expiry(this.ptr);
72                 Reference.reachabilityFence(this);
73                 return ret;
74         }
75
76         /**
77          * The CLTV lock-time at which this HTLC expires.
78          */
79         public void set_cltv_expiry(int val) {
80                 bindings.HTLCOutputInCommitment_set_cltv_expiry(this.ptr, val);
81                 Reference.reachabilityFence(this);
82                 Reference.reachabilityFence(val);
83         }
84
85         /**
86          * The hash of the preimage which unlocks this HTLC.
87          */
88         public byte[] get_payment_hash() {
89                 byte[] ret = bindings.HTLCOutputInCommitment_get_payment_hash(this.ptr);
90                 Reference.reachabilityFence(this);
91                 return ret;
92         }
93
94         /**
95          * The hash of the preimage which unlocks this HTLC.
96          */
97         public void set_payment_hash(byte[] val) {
98                 bindings.HTLCOutputInCommitment_set_payment_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
99                 Reference.reachabilityFence(this);
100                 Reference.reachabilityFence(val);
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 Option_u32Z get_transaction_output_index() {
109                 long ret = bindings.HTLCOutputInCommitment_get_transaction_output_index(this.ptr);
110                 Reference.reachabilityFence(this);
111                 if (ret >= 0 && ret <= 4096) { return null; }
112                 org.ldk.structs.Option_u32Z ret_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(ret);
113                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
114                 return ret_hu_conv;
115         }
116
117         /**
118          * The position within the commitment transactions' outputs. This may be None if the value is
119          * below the dust limit (in which case no output appears in the commitment transaction and the
120          * value is spent to additional transaction fees).
121          */
122         public void set_transaction_output_index(org.ldk.structs.Option_u32Z val) {
123                 bindings.HTLCOutputInCommitment_set_transaction_output_index(this.ptr, val.ptr);
124                 Reference.reachabilityFence(this);
125                 Reference.reachabilityFence(val);
126                 if (this != null) { this.ptrs_to.add(val); };
127         }
128
129         /**
130          * Constructs a new HTLCOutputInCommitment given each field
131          */
132         public static HTLCOutputInCommitment of(boolean offered_arg, long amount_msat_arg, int cltv_expiry_arg, byte[] payment_hash_arg, org.ldk.structs.Option_u32Z transaction_output_index_arg) {
133                 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);
134                 Reference.reachabilityFence(offered_arg);
135                 Reference.reachabilityFence(amount_msat_arg);
136                 Reference.reachabilityFence(cltv_expiry_arg);
137                 Reference.reachabilityFence(payment_hash_arg);
138                 Reference.reachabilityFence(transaction_output_index_arg);
139                 if (ret >= 0 && ret <= 4096) { return null; }
140                 org.ldk.structs.HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, ret); }
141                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
142                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(transaction_output_index_arg); };
143                 return ret_hu_conv;
144         }
145
146         long clone_ptr() {
147                 long ret = bindings.HTLCOutputInCommitment_clone_ptr(this.ptr);
148                 Reference.reachabilityFence(this);
149                 return ret;
150         }
151
152         /**
153          * Creates a copy of the HTLCOutputInCommitment
154          */
155         public HTLCOutputInCommitment clone() {
156                 long ret = bindings.HTLCOutputInCommitment_clone(this.ptr);
157                 Reference.reachabilityFence(this);
158                 if (ret >= 0 && ret <= 4096) { return null; }
159                 org.ldk.structs.HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, ret); }
160                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
161                 return ret_hu_conv;
162         }
163
164         /**
165          * Checks if two HTLCOutputInCommitments contain equal inner contents.
166          * This ignores pointers and is_owned flags and looks at the values in fields.
167          * Two objects with NULL inner values will be considered "equal" here.
168          */
169         public boolean eq(org.ldk.structs.HTLCOutputInCommitment b) {
170                 boolean ret = bindings.HTLCOutputInCommitment_eq(this.ptr, b == null ? 0 : b.ptr);
171                 Reference.reachabilityFence(this);
172                 Reference.reachabilityFence(b);
173                 if (this != null) { this.ptrs_to.add(b); };
174                 return ret;
175         }
176
177         @Override public boolean equals(Object o) {
178                 if (!(o instanceof HTLCOutputInCommitment)) return false;
179                 return this.eq((HTLCOutputInCommitment)o);
180         }
181         /**
182          * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read
183          */
184         public byte[] write() {
185                 byte[] ret = bindings.HTLCOutputInCommitment_write(this.ptr);
186                 Reference.reachabilityFence(this);
187                 return ret;
188         }
189
190         /**
191          * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write
192          */
193         public static Result_HTLCOutputInCommitmentDecodeErrorZ read(byte[] ser) {
194                 long ret = bindings.HTLCOutputInCommitment_read(ser);
195                 Reference.reachabilityFence(ser);
196                 if (ret >= 0 && ret <= 4096) { return null; }
197                 Result_HTLCOutputInCommitmentDecodeErrorZ ret_hu_conv = Result_HTLCOutputInCommitmentDecodeErrorZ.constr_from_ptr(ret);
198                 return ret_hu_conv;
199         }
200
201 }