[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / UpdateAddHTLC.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  * An [`update_add_htlc`] message to be sent to or received from a peer.
13  * 
14  * [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UpdateAddHTLC extends CommonBase {
18         UpdateAddHTLC(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.UpdateAddHTLC_free(ptr); }
23         }
24
25         /**
26          * The channel ID
27          */
28         public byte[] get_channel_id() {
29                 byte[] ret = bindings.UpdateAddHTLC_get_channel_id(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * The channel ID
36          */
37         public void set_channel_id(byte[] val) {
38                 bindings.UpdateAddHTLC_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * The HTLC ID
45          */
46         public long get_htlc_id() {
47                 long ret = bindings.UpdateAddHTLC_get_htlc_id(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * The HTLC ID
54          */
55         public void set_htlc_id(long val) {
56                 bindings.UpdateAddHTLC_set_htlc_id(this.ptr, val);
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         /**
62          * The HTLC value in milli-satoshi
63          */
64         public long get_amount_msat() {
65                 long ret = bindings.UpdateAddHTLC_get_amount_msat(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * The HTLC value in milli-satoshi
72          */
73         public void set_amount_msat(long val) {
74                 bindings.UpdateAddHTLC_set_amount_msat(this.ptr, val);
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * The payment hash, the pre-image of which controls HTLC redemption
81          */
82         public byte[] get_payment_hash() {
83                 byte[] ret = bindings.UpdateAddHTLC_get_payment_hash(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * The payment hash, the pre-image of which controls HTLC redemption
90          */
91         public void set_payment_hash(byte[] val) {
92                 bindings.UpdateAddHTLC_set_payment_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
93                 Reference.reachabilityFence(this);
94                 Reference.reachabilityFence(val);
95         }
96
97         /**
98          * The expiry height of the HTLC
99          */
100         public int get_cltv_expiry() {
101                 int ret = bindings.UpdateAddHTLC_get_cltv_expiry(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         /**
107          * The expiry height of the HTLC
108          */
109         public void set_cltv_expiry(int val) {
110                 bindings.UpdateAddHTLC_set_cltv_expiry(this.ptr, val);
111                 Reference.reachabilityFence(this);
112                 Reference.reachabilityFence(val);
113         }
114
115         /**
116          * The extra fee skimmed by the sender of this message. See
117          * [`ChannelConfig::accept_underpaying_htlcs`].
118          * 
119          * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
120          */
121         public Option_u64Z get_skimmed_fee_msat() {
122                 long ret = bindings.UpdateAddHTLC_get_skimmed_fee_msat(this.ptr);
123                 Reference.reachabilityFence(this);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
126                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
127                 return ret_hu_conv;
128         }
129
130         /**
131          * The extra fee skimmed by the sender of this message. See
132          * [`ChannelConfig::accept_underpaying_htlcs`].
133          * 
134          * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
135          */
136         public void set_skimmed_fee_msat(org.ldk.structs.Option_u64Z val) {
137                 bindings.UpdateAddHTLC_set_skimmed_fee_msat(this.ptr, val.ptr);
138                 Reference.reachabilityFence(this);
139                 Reference.reachabilityFence(val);
140                 if (this != null) { this.ptrs_to.add(val); };
141         }
142
143         /**
144          * The onion routing packet with encrypted data for the next hop.
145          */
146         public OnionPacket get_onion_routing_packet() {
147                 long ret = bindings.UpdateAddHTLC_get_onion_routing_packet(this.ptr);
148                 Reference.reachabilityFence(this);
149                 if (ret >= 0 && ret <= 4096) { return null; }
150                 org.ldk.structs.OnionPacket ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionPacket(null, ret); }
151                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
152                 return ret_hu_conv;
153         }
154
155         /**
156          * The onion routing packet with encrypted data for the next hop.
157          */
158         public void set_onion_routing_packet(org.ldk.structs.OnionPacket val) {
159                 bindings.UpdateAddHTLC_set_onion_routing_packet(this.ptr, val == null ? 0 : val.ptr);
160                 Reference.reachabilityFence(this);
161                 Reference.reachabilityFence(val);
162                 if (this != null) { this.ptrs_to.add(val); };
163         }
164
165         /**
166          * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
167          * routing packet and the recipient-provided encrypted payload within.
168          * 
169          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
170          */
171         @Nullable
172         public byte[] get_blinding_point() {
173                 byte[] ret = bindings.UpdateAddHTLC_get_blinding_point(this.ptr);
174                 Reference.reachabilityFence(this);
175                 return ret;
176         }
177
178         /**
179          * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
180          * routing packet and the recipient-provided encrypted payload within.
181          * 
182          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
183          */
184         public void set_blinding_point(@Nullable byte[] val) {
185                 bindings.UpdateAddHTLC_set_blinding_point(this.ptr, InternalUtils.check_arr_len(val, 33));
186                 Reference.reachabilityFence(this);
187                 Reference.reachabilityFence(val);
188         }
189
190         /**
191          * Constructs a new UpdateAddHTLC given each field
192          * 
193          * Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
194          */
195         public static UpdateAddHTLC of(byte[] channel_id_arg, long htlc_id_arg, long amount_msat_arg, byte[] payment_hash_arg, int cltv_expiry_arg, org.ldk.structs.Option_u64Z skimmed_fee_msat_arg, org.ldk.structs.OnionPacket onion_routing_packet_arg, @Nullable byte[] blinding_point_arg) {
196                 long ret = bindings.UpdateAddHTLC_new(InternalUtils.check_arr_len(channel_id_arg, 32), htlc_id_arg, amount_msat_arg, InternalUtils.check_arr_len(payment_hash_arg, 32), cltv_expiry_arg, skimmed_fee_msat_arg.ptr, onion_routing_packet_arg == null ? 0 : onion_routing_packet_arg.ptr, InternalUtils.check_arr_len(blinding_point_arg, 33));
197                 Reference.reachabilityFence(channel_id_arg);
198                 Reference.reachabilityFence(htlc_id_arg);
199                 Reference.reachabilityFence(amount_msat_arg);
200                 Reference.reachabilityFence(payment_hash_arg);
201                 Reference.reachabilityFence(cltv_expiry_arg);
202                 Reference.reachabilityFence(skimmed_fee_msat_arg);
203                 Reference.reachabilityFence(onion_routing_packet_arg);
204                 Reference.reachabilityFence(blinding_point_arg);
205                 if (ret >= 0 && ret <= 4096) { return null; }
206                 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
207                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
208                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(skimmed_fee_msat_arg); };
209                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(onion_routing_packet_arg); };
210                 return ret_hu_conv;
211         }
212
213         long clone_ptr() {
214                 long ret = bindings.UpdateAddHTLC_clone_ptr(this.ptr);
215                 Reference.reachabilityFence(this);
216                 return ret;
217         }
218
219         /**
220          * Creates a copy of the UpdateAddHTLC
221          */
222         public UpdateAddHTLC clone() {
223                 long ret = bindings.UpdateAddHTLC_clone(this.ptr);
224                 Reference.reachabilityFence(this);
225                 if (ret >= 0 && ret <= 4096) { return null; }
226                 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
227                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
228                 return ret_hu_conv;
229         }
230
231         /**
232          * Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC.
233          */
234         public long hash() {
235                 long ret = bindings.UpdateAddHTLC_hash(this.ptr);
236                 Reference.reachabilityFence(this);
237                 return ret;
238         }
239
240         @Override public int hashCode() {
241                 return (int)this.hash();
242         }
243         /**
244          * Checks if two UpdateAddHTLCs contain equal inner contents.
245          * This ignores pointers and is_owned flags and looks at the values in fields.
246          * Two objects with NULL inner values will be considered "equal" here.
247          */
248         public boolean eq(org.ldk.structs.UpdateAddHTLC b) {
249                 boolean ret = bindings.UpdateAddHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
250                 Reference.reachabilityFence(this);
251                 Reference.reachabilityFence(b);
252                 if (this != null) { this.ptrs_to.add(b); };
253                 return ret;
254         }
255
256         @Override public boolean equals(Object o) {
257                 if (!(o instanceof UpdateAddHTLC)) return false;
258                 return this.eq((UpdateAddHTLC)o);
259         }
260         /**
261          * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
262          */
263         public byte[] write() {
264                 byte[] ret = bindings.UpdateAddHTLC_write(this.ptr);
265                 Reference.reachabilityFence(this);
266                 return ret;
267         }
268
269         /**
270          * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
271          */
272         public static Result_UpdateAddHTLCDecodeErrorZ read(byte[] ser) {
273                 long ret = bindings.UpdateAddHTLC_read(ser);
274                 Reference.reachabilityFence(ser);
275                 if (ret >= 0 && ret <= 4096) { return null; }
276                 Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);
277                 return ret_hu_conv;
278         }
279
280 }