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