[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / PendingHTLCInfo.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 incoming HTLC, including the [`PendingHTLCRouting`] describing where it
13  * should go next.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class PendingHTLCInfo extends CommonBase {
17         PendingHTLCInfo(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.PendingHTLCInfo_free(ptr); }
22         }
23
24         /**
25          * Further routing details based on whether the HTLC is being forwarded or received.
26          */
27         public PendingHTLCRouting get_routing() {
28                 long ret = bindings.PendingHTLCInfo_get_routing(this.ptr);
29                 Reference.reachabilityFence(this);
30                 if (ret >= 0 && ret <= 4096) { return null; }
31                 org.ldk.structs.PendingHTLCRouting ret_hu_conv = org.ldk.structs.PendingHTLCRouting.constr_from_ptr(ret);
32                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
33                 return ret_hu_conv;
34         }
35
36         /**
37          * Further routing details based on whether the HTLC is being forwarded or received.
38          */
39         public void set_routing(org.ldk.structs.PendingHTLCRouting val) {
40                 bindings.PendingHTLCInfo_set_routing(this.ptr, val.ptr);
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43                 if (this != null) { this.ptrs_to.add(val); };
44         }
45
46         /**
47          * The onion shared secret we build with the sender used to decrypt the onion.
48          * 
49          * This is later used to encrypt failure packets in the event that the HTLC is failed.
50          */
51         public byte[] get_incoming_shared_secret() {
52                 byte[] ret = bindings.PendingHTLCInfo_get_incoming_shared_secret(this.ptr);
53                 Reference.reachabilityFence(this);
54                 return ret;
55         }
56
57         /**
58          * The onion shared secret we build with the sender used to decrypt the onion.
59          * 
60          * This is later used to encrypt failure packets in the event that the HTLC is failed.
61          */
62         public void set_incoming_shared_secret(byte[] val) {
63                 bindings.PendingHTLCInfo_set_incoming_shared_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
64                 Reference.reachabilityFence(this);
65                 Reference.reachabilityFence(val);
66         }
67
68         /**
69          * Hash of the payment preimage, to lock the payment until the receiver releases the preimage.
70          */
71         public byte[] get_payment_hash() {
72                 byte[] ret = bindings.PendingHTLCInfo_get_payment_hash(this.ptr);
73                 Reference.reachabilityFence(this);
74                 return ret;
75         }
76
77         /**
78          * Hash of the payment preimage, to lock the payment until the receiver releases the preimage.
79          */
80         public void set_payment_hash(byte[] val) {
81                 bindings.PendingHTLCInfo_set_payment_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
82                 Reference.reachabilityFence(this);
83                 Reference.reachabilityFence(val);
84         }
85
86         /**
87          * Amount received in the incoming HTLC.
88          * 
89          * This field was added in LDK 0.0.113 and will be `None` for objects written by prior
90          * versions.
91          */
92         public Option_u64Z get_incoming_amt_msat() {
93                 long ret = bindings.PendingHTLCInfo_get_incoming_amt_msat(this.ptr);
94                 Reference.reachabilityFence(this);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
97                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Amount received in the incoming HTLC.
103          * 
104          * This field was added in LDK 0.0.113 and will be `None` for objects written by prior
105          * versions.
106          */
107         public void set_incoming_amt_msat(org.ldk.structs.Option_u64Z val) {
108                 bindings.PendingHTLCInfo_set_incoming_amt_msat(this.ptr, val.ptr);
109                 Reference.reachabilityFence(this);
110                 Reference.reachabilityFence(val);
111                 if (this != null) { this.ptrs_to.add(val); };
112         }
113
114         /**
115          * The amount the sender indicated should be forwarded on to the next hop or amount the sender
116          * intended for us to receive for received payments.
117          * 
118          * If the received amount is less than this for received payments, an intermediary hop has
119          * attempted to steal some of our funds and we should fail the HTLC (the sender should retry
120          * it along another path).
121          * 
122          * Because nodes can take less than their required fees, and because senders may wish to
123          * improve their own privacy, this amount may be less than [`Self::incoming_amt_msat`] for
124          * received payments. In such cases, recipients must handle this HTLC as if it had received
125          * [`Self::outgoing_amt_msat`].
126          */
127         public long get_outgoing_amt_msat() {
128                 long ret = bindings.PendingHTLCInfo_get_outgoing_amt_msat(this.ptr);
129                 Reference.reachabilityFence(this);
130                 return ret;
131         }
132
133         /**
134          * The amount the sender indicated should be forwarded on to the next hop or amount the sender
135          * intended for us to receive for received payments.
136          * 
137          * If the received amount is less than this for received payments, an intermediary hop has
138          * attempted to steal some of our funds and we should fail the HTLC (the sender should retry
139          * it along another path).
140          * 
141          * Because nodes can take less than their required fees, and because senders may wish to
142          * improve their own privacy, this amount may be less than [`Self::incoming_amt_msat`] for
143          * received payments. In such cases, recipients must handle this HTLC as if it had received
144          * [`Self::outgoing_amt_msat`].
145          */
146         public void set_outgoing_amt_msat(long val) {
147                 bindings.PendingHTLCInfo_set_outgoing_amt_msat(this.ptr, val);
148                 Reference.reachabilityFence(this);
149                 Reference.reachabilityFence(val);
150         }
151
152         /**
153          * The CLTV the sender has indicated we should set on the forwarded HTLC (or has indicated
154          * should have been set on the received HTLC for received payments).
155          */
156         public int get_outgoing_cltv_value() {
157                 int ret = bindings.PendingHTLCInfo_get_outgoing_cltv_value(this.ptr);
158                 Reference.reachabilityFence(this);
159                 return ret;
160         }
161
162         /**
163          * The CLTV the sender has indicated we should set on the forwarded HTLC (or has indicated
164          * should have been set on the received HTLC for received payments).
165          */
166         public void set_outgoing_cltv_value(int val) {
167                 bindings.PendingHTLCInfo_set_outgoing_cltv_value(this.ptr, val);
168                 Reference.reachabilityFence(this);
169                 Reference.reachabilityFence(val);
170         }
171
172         /**
173          * The fee taken for this HTLC in addition to the standard protocol HTLC fees.
174          * 
175          * If this is a payment for forwarding, this is the fee we are taking before forwarding the
176          * HTLC.
177          * 
178          * If this is a received payment, this is the fee that our counterparty took.
179          * 
180          * This is used to allow LSPs to take fees as a part of payments, without the sender having to
181          * shoulder them.
182          */
183         public Option_u64Z get_skimmed_fee_msat() {
184                 long ret = bindings.PendingHTLCInfo_get_skimmed_fee_msat(this.ptr);
185                 Reference.reachabilityFence(this);
186                 if (ret >= 0 && ret <= 4096) { return null; }
187                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
188                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
189                 return ret_hu_conv;
190         }
191
192         /**
193          * The fee taken for this HTLC in addition to the standard protocol HTLC fees.
194          * 
195          * If this is a payment for forwarding, this is the fee we are taking before forwarding the
196          * HTLC.
197          * 
198          * If this is a received payment, this is the fee that our counterparty took.
199          * 
200          * This is used to allow LSPs to take fees as a part of payments, without the sender having to
201          * shoulder them.
202          */
203         public void set_skimmed_fee_msat(org.ldk.structs.Option_u64Z val) {
204                 bindings.PendingHTLCInfo_set_skimmed_fee_msat(this.ptr, val.ptr);
205                 Reference.reachabilityFence(this);
206                 Reference.reachabilityFence(val);
207                 if (this != null) { this.ptrs_to.add(val); };
208         }
209
210         /**
211          * Constructs a new PendingHTLCInfo given each field
212          */
213         public static PendingHTLCInfo of(org.ldk.structs.PendingHTLCRouting routing_arg, byte[] incoming_shared_secret_arg, byte[] payment_hash_arg, org.ldk.structs.Option_u64Z incoming_amt_msat_arg, long outgoing_amt_msat_arg, int outgoing_cltv_value_arg, org.ldk.structs.Option_u64Z skimmed_fee_msat_arg) {
214                 long ret = bindings.PendingHTLCInfo_new(routing_arg.ptr, InternalUtils.check_arr_len(incoming_shared_secret_arg, 32), InternalUtils.check_arr_len(payment_hash_arg, 32), incoming_amt_msat_arg.ptr, outgoing_amt_msat_arg, outgoing_cltv_value_arg, skimmed_fee_msat_arg.ptr);
215                 Reference.reachabilityFence(routing_arg);
216                 Reference.reachabilityFence(incoming_shared_secret_arg);
217                 Reference.reachabilityFence(payment_hash_arg);
218                 Reference.reachabilityFence(incoming_amt_msat_arg);
219                 Reference.reachabilityFence(outgoing_amt_msat_arg);
220                 Reference.reachabilityFence(outgoing_cltv_value_arg);
221                 Reference.reachabilityFence(skimmed_fee_msat_arg);
222                 if (ret >= 0 && ret <= 4096) { return null; }
223                 org.ldk.structs.PendingHTLCInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PendingHTLCInfo(null, ret); }
224                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
225                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(routing_arg); };
226                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(incoming_amt_msat_arg); };
227                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(skimmed_fee_msat_arg); };
228                 return ret_hu_conv;
229         }
230
231         long clone_ptr() {
232                 long ret = bindings.PendingHTLCInfo_clone_ptr(this.ptr);
233                 Reference.reachabilityFence(this);
234                 return ret;
235         }
236
237         /**
238          * Creates a copy of the PendingHTLCInfo
239          */
240         public PendingHTLCInfo clone() {
241                 long ret = bindings.PendingHTLCInfo_clone(this.ptr);
242                 Reference.reachabilityFence(this);
243                 if (ret >= 0 && ret <= 4096) { return null; }
244                 org.ldk.structs.PendingHTLCInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PendingHTLCInfo(null, ret); }
245                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
246                 return ret_hu_conv;
247         }
248
249         /**
250          * Serialize the PendingHTLCInfo object into a byte array which can be read by PendingHTLCInfo_read
251          */
252         public byte[] write() {
253                 byte[] ret = bindings.PendingHTLCInfo_write(this.ptr);
254                 Reference.reachabilityFence(this);
255                 return ret;
256         }
257
258         /**
259          * Read a PendingHTLCInfo from a byte array, created by PendingHTLCInfo_write
260          */
261         public static Result_PendingHTLCInfoDecodeErrorZ read(byte[] ser) {
262                 long ret = bindings.PendingHTLCInfo_read(ser);
263                 Reference.reachabilityFence(ser);
264                 if (ret >= 0 && ret <= 4096) { return null; }
265                 Result_PendingHTLCInfoDecodeErrorZ ret_hu_conv = Result_PendingHTLCInfoDecodeErrorZ.constr_from_ptr(ret);
266                 return ret_hu_conv;
267         }
268
269 }