[Java] Update auto-generated Java bindings for 0.0.108
[ldk-java] / src / main / java / org / ldk / structs / Event.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 Event which you should probably take some action in response to.
13  * 
14  * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
15  * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
16  * written as it makes no sense to respond to it after reconnecting to peers).
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class Event extends CommonBase {
20         private Event(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.Event_free(ptr); }
25         }
26         static Event constr_from_ptr(long ptr) {
27                 bindings.LDKEvent raw_val = bindings.LDKEvent_ref_from_ptr(ptr);
28                 if (raw_val.getClass() == bindings.LDKEvent.FundingGenerationReady.class) {
29                         return new FundingGenerationReady(ptr, (bindings.LDKEvent.FundingGenerationReady)raw_val);
30                 }
31                 if (raw_val.getClass() == bindings.LDKEvent.PaymentReceived.class) {
32                         return new PaymentReceived(ptr, (bindings.LDKEvent.PaymentReceived)raw_val);
33                 }
34                 if (raw_val.getClass() == bindings.LDKEvent.PaymentClaimed.class) {
35                         return new PaymentClaimed(ptr, (bindings.LDKEvent.PaymentClaimed)raw_val);
36                 }
37                 if (raw_val.getClass() == bindings.LDKEvent.PaymentSent.class) {
38                         return new PaymentSent(ptr, (bindings.LDKEvent.PaymentSent)raw_val);
39                 }
40                 if (raw_val.getClass() == bindings.LDKEvent.PaymentFailed.class) {
41                         return new PaymentFailed(ptr, (bindings.LDKEvent.PaymentFailed)raw_val);
42                 }
43                 if (raw_val.getClass() == bindings.LDKEvent.PaymentPathSuccessful.class) {
44                         return new PaymentPathSuccessful(ptr, (bindings.LDKEvent.PaymentPathSuccessful)raw_val);
45                 }
46                 if (raw_val.getClass() == bindings.LDKEvent.PaymentPathFailed.class) {
47                         return new PaymentPathFailed(ptr, (bindings.LDKEvent.PaymentPathFailed)raw_val);
48                 }
49                 if (raw_val.getClass() == bindings.LDKEvent.PendingHTLCsForwardable.class) {
50                         return new PendingHTLCsForwardable(ptr, (bindings.LDKEvent.PendingHTLCsForwardable)raw_val);
51                 }
52                 if (raw_val.getClass() == bindings.LDKEvent.SpendableOutputs.class) {
53                         return new SpendableOutputs(ptr, (bindings.LDKEvent.SpendableOutputs)raw_val);
54                 }
55                 if (raw_val.getClass() == bindings.LDKEvent.PaymentForwarded.class) {
56                         return new PaymentForwarded(ptr, (bindings.LDKEvent.PaymentForwarded)raw_val);
57                 }
58                 if (raw_val.getClass() == bindings.LDKEvent.ChannelClosed.class) {
59                         return new ChannelClosed(ptr, (bindings.LDKEvent.ChannelClosed)raw_val);
60                 }
61                 if (raw_val.getClass() == bindings.LDKEvent.DiscardFunding.class) {
62                         return new DiscardFunding(ptr, (bindings.LDKEvent.DiscardFunding)raw_val);
63                 }
64                 if (raw_val.getClass() == bindings.LDKEvent.OpenChannelRequest.class) {
65                         return new OpenChannelRequest(ptr, (bindings.LDKEvent.OpenChannelRequest)raw_val);
66                 }
67                 assert false; return null; // Unreachable without extending the (internal) bindings interface
68         }
69
70         /**
71          * Used to indicate that the client should generate a funding transaction with the given
72          * parameters and then call [`ChannelManager::funding_transaction_generated`].
73          * Generated in [`ChannelManager`] message handling.
74          * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
75          * counterparty can steal your funds!
76          * 
77          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
78          * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
79          */
80         public final static class FundingGenerationReady extends Event {
81                 /**
82                  * The random channel_id we picked which you'll need to pass into
83                  * [`ChannelManager::funding_transaction_generated`].
84                  * 
85                  * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
86                 */
87                 public final byte[] temporary_channel_id;
88                 /**
89                  * The counterparty's node_id, which you'll need to pass back into
90                  * [`ChannelManager::funding_transaction_generated`].
91                  * 
92                  * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
93                 */
94                 public final byte[] counterparty_node_id;
95                 /**
96                  * The value, in satoshis, that the output should have.
97                 */
98                 public final long channel_value_satoshis;
99                 /**
100                  * The script which should be used in the transaction output.
101                 */
102                 public final byte[] output_script;
103                 /**
104                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
105                  * an inbound channel.
106                  * 
107                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
108                 */
109                 public final long user_channel_id;
110                 private FundingGenerationReady(long ptr, bindings.LDKEvent.FundingGenerationReady obj) {
111                         super(null, ptr);
112                         this.temporary_channel_id = obj.temporary_channel_id;
113                         this.counterparty_node_id = obj.counterparty_node_id;
114                         this.channel_value_satoshis = obj.channel_value_satoshis;
115                         this.output_script = obj.output_script;
116                         this.user_channel_id = obj.user_channel_id;
117                 }
118         }
119         /**
120          * Indicates we've received (an offer of) money! Just gotta dig out that payment preimage and
121          * feed it to [`ChannelManager::claim_funds`] to get it....
122          * 
123          * Note that if the preimage is not known, you should call
124          * [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid
125          * network congestion.
126          * If you fail to call either [`ChannelManager::claim_funds`] or
127          * [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be
128          * automatically failed.
129          * 
130          * # Note
131          * LDK will not stop an inbound payment from being paid multiple times, so multiple
132          * `PaymentReceived` events may be generated for the same payment.
133          * 
134          * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
135          * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
136          */
137         public final static class PaymentReceived extends Event {
138                 /**
139                  * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
140                  * not stop you from registering duplicate payment hashes for inbound payments.
141                 */
142                 public final byte[] payment_hash;
143                 /**
144                  * The value, in thousandths of a satoshi, that this payment is for.
145                 */
146                 public final long amount_msat;
147                 /**
148                  * Information for claiming this received payment, based on whether the purpose of the
149                  * payment is to pay an invoice or to send a spontaneous payment.
150                 */
151                 public final org.ldk.structs.PaymentPurpose purpose;
152                 private PaymentReceived(long ptr, bindings.LDKEvent.PaymentReceived obj) {
153                         super(null, ptr);
154                         this.payment_hash = obj.payment_hash;
155                         this.amount_msat = obj.amount_msat;
156                         long purpose = obj.purpose;
157                         org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
158                         purpose_hu_conv.ptrs_to.add(this);
159                         this.purpose = purpose_hu_conv;
160                 }
161         }
162         /**
163          * Indicates a payment has been claimed and we've received money!
164          * 
165          * This most likely occurs when [`ChannelManager::claim_funds`] has been called in response
166          * to an [`Event::PaymentReceived`]. However, if we previously crashed during a
167          * [`ChannelManager::claim_funds`] call you may see this event without a corresponding
168          * [`Event::PaymentReceived`] event.
169          * 
170          * # Note
171          * LDK will not stop an inbound payment from being paid multiple times, so multiple
172          * `PaymentReceived` events may be generated for the same payment. If you then call
173          * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentReceived`] you may get
174          * multiple `PaymentClaimed` events.
175          * 
176          * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
177          */
178         public final static class PaymentClaimed extends Event {
179                 /**
180                  * The payment hash of the claimed payment. Note that LDK will not stop you from
181                  * registering duplicate payment hashes for inbound payments.
182                 */
183                 public final byte[] payment_hash;
184                 /**
185                  * The value, in thousandths of a satoshi, that this payment is for.
186                 */
187                 public final long amount_msat;
188                 /**
189                  * The purpose of this claimed payment, i.e. whether the payment was for an invoice or a
190                  * spontaneous payment.
191                 */
192                 public final org.ldk.structs.PaymentPurpose purpose;
193                 private PaymentClaimed(long ptr, bindings.LDKEvent.PaymentClaimed obj) {
194                         super(null, ptr);
195                         this.payment_hash = obj.payment_hash;
196                         this.amount_msat = obj.amount_msat;
197                         long purpose = obj.purpose;
198                         org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
199                         purpose_hu_conv.ptrs_to.add(this);
200                         this.purpose = purpose_hu_conv;
201                 }
202         }
203         /**
204          * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
205          * and we got back the payment preimage for it).
206          * 
207          * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
208          * event. In this situation, you SHOULD treat this payment as having succeeded.
209          */
210         public final static class PaymentSent extends Event {
211                 /**
212                  * The id returned by [`ChannelManager::send_payment`] and used with
213                  * [`ChannelManager::retry_payment`].
214                  * 
215                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
216                  * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
217                  * 
218                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
219                 */
220                 @Nullable public final byte[] payment_id;
221                 /**
222                  * The preimage to the hash given to ChannelManager::send_payment.
223                  * Note that this serves as a payment receipt, if you wish to have such a thing, you must
224                  * store it somehow!
225                 */
226                 public final byte[] payment_preimage;
227                 /**
228                  * The hash that was given to [`ChannelManager::send_payment`].
229                  * 
230                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
231                 */
232                 public final byte[] payment_hash;
233                 /**
234                  * The total fee which was spent at intermediate hops in this payment, across all paths.
235                  * 
236                  * Note that, like [`Route::get_total_fees`] this does *not* include any potential
237                  * overpayment to the recipient node.
238                  * 
239                  * If the recipient or an intermediate node misbehaves and gives us free money, this may
240                  * overstate the amount paid, though this is unlikely.
241                  * 
242                  * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
243                 */
244                 public final org.ldk.structs.Option_u64Z fee_paid_msat;
245                 private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
246                         super(null, ptr);
247                         this.payment_id = obj.payment_id;
248                         this.payment_preimage = obj.payment_preimage;
249                         this.payment_hash = obj.payment_hash;
250                         long fee_paid_msat = obj.fee_paid_msat;
251                         org.ldk.structs.Option_u64Z fee_paid_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_paid_msat);
252                         fee_paid_msat_hu_conv.ptrs_to.add(this);
253                         this.fee_paid_msat = fee_paid_msat_hu_conv;
254                 }
255         }
256         /**
257          * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
258          * provide failure information for each MPP part in the payment.
259          * 
260          * This event is provided once there are no further pending HTLCs for the payment and the
261          * payment is no longer retryable, either due to a several-block timeout or because
262          * [`ChannelManager::abandon_payment`] was previously called for the corresponding payment.
263          * 
264          * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
265          */
266         public final static class PaymentFailed extends Event {
267                 /**
268                  * The id returned by [`ChannelManager::send_payment`] and used with
269                  * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
270                  * 
271                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
272                  * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
273                  * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
274                 */
275                 public final byte[] payment_id;
276                 /**
277                  * The hash that was given to [`ChannelManager::send_payment`].
278                  * 
279                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
280                 */
281                 public final byte[] payment_hash;
282                 private PaymentFailed(long ptr, bindings.LDKEvent.PaymentFailed obj) {
283                         super(null, ptr);
284                         this.payment_id = obj.payment_id;
285                         this.payment_hash = obj.payment_hash;
286                 }
287         }
288         /**
289          * Indicates that a path for an outbound payment was successful.
290          * 
291          * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
292          * [`Event::PaymentSent`] for obtaining the payment preimage.
293          */
294         public final static class PaymentPathSuccessful extends Event {
295                 /**
296                  * The id returned by [`ChannelManager::send_payment`] and used with
297                  * [`ChannelManager::retry_payment`].
298                  * 
299                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
300                  * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
301                 */
302                 public final byte[] payment_id;
303                 /**
304                  * The hash that was given to [`ChannelManager::send_payment`].
305                  * 
306                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
307                  * 
308                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
309                 */
310                 @Nullable public final byte[] payment_hash;
311                 /**
312                  * The payment path that was successful.
313                  * 
314                  * May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
315                 */
316                 public final RouteHop[] path;
317                 private PaymentPathSuccessful(long ptr, bindings.LDKEvent.PaymentPathSuccessful obj) {
318                         super(null, ptr);
319                         this.payment_id = obj.payment_id;
320                         this.payment_hash = obj.payment_hash;
321                         long[] path = obj.path;
322                         int path_conv_10_len = path.length;
323                         RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
324                         for (int k = 0; k < path_conv_10_len; k++) {
325                                 long path_conv_10 = path[k];
326                                 org.ldk.structs.RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, path_conv_10); }
327                                 path_conv_10_hu_conv.ptrs_to.add(this);
328                                 path_conv_10_arr[k] = path_conv_10_hu_conv;
329                         }
330                         this.path = path_conv_10_arr;
331                 }
332         }
333         /**
334          * Indicates an outbound HTLC we sent failed. Probably some intermediary node dropped
335          * something. You may wish to retry with a different route.
336          * 
337          * Note that this does *not* indicate that all paths for an MPP payment have failed, see
338          * [`Event::PaymentFailed`] and [`all_paths_failed`].
339          * 
340          * [`all_paths_failed`]: Self::PaymentPathFailed::all_paths_failed
341          */
342         public final static class PaymentPathFailed extends Event {
343                 /**
344                  * The id returned by [`ChannelManager::send_payment`] and used with
345                  * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
346                  * 
347                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
348                  * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
349                  * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
350                  * 
351                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
352                 */
353                 @Nullable public final byte[] payment_id;
354                 /**
355                  * The hash that was given to [`ChannelManager::send_payment`].
356                  * 
357                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
358                 */
359                 public final byte[] payment_hash;
360                 /**
361                  * Indicates the payment was rejected for some reason by the recipient. This implies that
362                  * the payment has failed, not just the route in question. If this is not set, you may
363                  * retry the payment via a different route.
364                 */
365                 public final boolean rejected_by_dest;
366                 /**
367                  * Any failure information conveyed via the Onion return packet by a node along the failed
368                  * payment route.
369                  * 
370                  * Should be applied to the [`NetworkGraph`] so that routing decisions can take into
371                  * account the update.
372                  * 
373                  * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
374                 */
375                 public final org.ldk.structs.Option_NetworkUpdateZ network_update;
376                 /**
377                  * For both single-path and multi-path payments, this is set if all paths of the payment have
378                  * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
379                  * larger MPP payment were still in flight when this event was generated.
380                  * 
381                  * Note that if you are retrying individual MPP parts, using this value to determine if a
382                  * payment has fully failed is race-y. Because multiple failures can happen prior to events
383                  * being processed, you may retry in response to a first failure, with a second failure
384                  * (with `all_paths_failed` set) still pending. Then, when the second failure is processed
385                  * you will see `all_paths_failed` set even though the retry of the first failure still
386                  * has an associated in-flight HTLC. See (1) for an example of such a failure.
387                  * 
388                  * If you wish to retry individual MPP parts and learn when a payment has failed, you must
389                  * call [`ChannelManager::abandon_payment`] and wait for a [`Event::PaymentFailed`] event.
390                  * 
391                  * (1) <https://github.com/lightningdevkit/rust-lightning/issues/1164>
392                  * 
393                  * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
394                 */
395                 public final boolean all_paths_failed;
396                 /**
397                  * The payment path that failed.
398                 */
399                 public final RouteHop[] path;
400                 /**
401                  * The channel responsible for the failed payment path.
402                  * 
403                  * Note that for route hints or for the first hop in a path this may be an SCID alias and
404                  * may not refer to a channel in the public network graph. These aliases may also collide
405                  * with channels in the public network graph.
406                  * 
407                  * If this is `Some`, then the corresponding channel should be avoided when the payment is
408                  * retried. May be `None` for older [`Event`] serializations.
409                 */
410                 public final org.ldk.structs.Option_u64Z short_channel_id;
411                 /**
412                  * Parameters needed to compute a new [`Route`] when retrying the failed payment path.
413                  * 
414                  * See [`find_route`] for details.
415                  * 
416                  * [`Route`]: crate::routing::router::Route
417                  * [`find_route`]: crate::routing::router::find_route
418                  * 
419                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
420                 */
421                 @Nullable public final org.ldk.structs.RouteParameters retry;
422                 private PaymentPathFailed(long ptr, bindings.LDKEvent.PaymentPathFailed obj) {
423                         super(null, ptr);
424                         this.payment_id = obj.payment_id;
425                         this.payment_hash = obj.payment_hash;
426                         this.rejected_by_dest = obj.rejected_by_dest;
427                         long network_update = obj.network_update;
428                         org.ldk.structs.Option_NetworkUpdateZ network_update_hu_conv = org.ldk.structs.Option_NetworkUpdateZ.constr_from_ptr(network_update);
429                         network_update_hu_conv.ptrs_to.add(this);
430                         this.network_update = network_update_hu_conv;
431                         this.all_paths_failed = obj.all_paths_failed;
432                         long[] path = obj.path;
433                         int path_conv_10_len = path.length;
434                         RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
435                         for (int k = 0; k < path_conv_10_len; k++) {
436                                 long path_conv_10 = path[k];
437                                 org.ldk.structs.RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, path_conv_10); }
438                                 path_conv_10_hu_conv.ptrs_to.add(this);
439                                 path_conv_10_arr[k] = path_conv_10_hu_conv;
440                         }
441                         this.path = path_conv_10_arr;
442                         long short_channel_id = obj.short_channel_id;
443                         org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id);
444                         short_channel_id_hu_conv.ptrs_to.add(this);
445                         this.short_channel_id = short_channel_id_hu_conv;
446                         long retry = obj.retry;
447                         org.ldk.structs.RouteParameters retry_hu_conv = null; if (retry < 0 || retry > 4096) { retry_hu_conv = new org.ldk.structs.RouteParameters(null, retry); }
448                         retry_hu_conv.ptrs_to.add(this);
449                         this.retry = retry_hu_conv;
450                 }
451         }
452         /**
453          * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
454          * a time in the future.
455          * 
456          * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
457          */
458         public final static class PendingHTLCsForwardable extends Event {
459                 /**
460                  * The minimum amount of time that should be waited prior to calling
461                  * process_pending_htlc_forwards. To increase the effort required to correlate payments,
462                  * you should wait a random amount of time in roughly the range (now + time_forwardable,
463                  * now + 5*time_forwardable).
464                 */
465                 public final long time_forwardable;
466                 private PendingHTLCsForwardable(long ptr, bindings.LDKEvent.PendingHTLCsForwardable obj) {
467                         super(null, ptr);
468                         this.time_forwardable = obj.time_forwardable;
469                 }
470         }
471         /**
472          * Used to indicate that an output which you should know how to spend was confirmed on chain
473          * and is now spendable.
474          * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
475          * counterparty spending them due to some kind of timeout. Thus, you need to store them
476          * somewhere and spend them when you create on-chain transactions.
477          */
478         public final static class SpendableOutputs extends Event {
479                 /**
480                  * The outputs which you should store as spendable by you.
481                 */
482                 public final SpendableOutputDescriptor[] outputs;
483                 private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
484                         super(null, ptr);
485                         long[] outputs = obj.outputs;
486                         int outputs_conv_27_len = outputs.length;
487                         SpendableOutputDescriptor[] outputs_conv_27_arr = new SpendableOutputDescriptor[outputs_conv_27_len];
488                         for (int b = 0; b < outputs_conv_27_len; b++) {
489                                 long outputs_conv_27 = outputs[b];
490                                 org.ldk.structs.SpendableOutputDescriptor outputs_conv_27_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(outputs_conv_27);
491                                 outputs_conv_27_hu_conv.ptrs_to.add(this);
492                                 outputs_conv_27_arr[b] = outputs_conv_27_hu_conv;
493                         }
494                         this.outputs = outputs_conv_27_arr;
495                 }
496         }
497         /**
498          * This event is generated when a payment has been successfully forwarded through us and a
499          * forwarding fee earned.
500          */
501         public final static class PaymentForwarded extends Event {
502                 /**
503                  * The incoming channel between the previous node and us. This is only `None` for events
504                  * generated or serialized by versions prior to 0.0.107.
505                  * 
506                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
507                 */
508                 @Nullable public final byte[] prev_channel_id;
509                 /**
510                  * The outgoing channel between the next node and us. This is only `None` for events
511                  * generated or serialized by versions prior to 0.0.107.
512                  * 
513                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
514                 */
515                 @Nullable public final byte[] next_channel_id;
516                 /**
517                  * The fee, in milli-satoshis, which was earned as a result of the payment.
518                  * 
519                  * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
520                  * was pending, the amount the next hop claimed will have been rounded down to the nearest
521                  * whole satoshi. Thus, the fee calculated here may be higher than expected as we still
522                  * claimed the full value in millisatoshis from the source. In this case,
523                  * `claim_from_onchain_tx` will be set.
524                  * 
525                  * If the channel which sent us the payment has been force-closed, we will claim the funds
526                  * via an on-chain transaction. In that case we do not yet know the on-chain transaction
527                  * fees which we will spend and will instead set this to `None`. It is possible duplicate
528                  * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
529                  * `None`.
530                 */
531                 public final org.ldk.structs.Option_u64Z fee_earned_msat;
532                 /**
533                  * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
534                  * transaction.
535                 */
536                 public final boolean claim_from_onchain_tx;
537                 private PaymentForwarded(long ptr, bindings.LDKEvent.PaymentForwarded obj) {
538                         super(null, ptr);
539                         this.prev_channel_id = obj.prev_channel_id;
540                         this.next_channel_id = obj.next_channel_id;
541                         long fee_earned_msat = obj.fee_earned_msat;
542                         org.ldk.structs.Option_u64Z fee_earned_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_earned_msat);
543                         fee_earned_msat_hu_conv.ptrs_to.add(this);
544                         this.fee_earned_msat = fee_earned_msat_hu_conv;
545                         this.claim_from_onchain_tx = obj.claim_from_onchain_tx;
546                 }
547         }
548         /**
549          * Used to indicate that a previously opened channel with the given `channel_id` is in the
550          * process of closure.
551          */
552         public final static class ChannelClosed extends Event {
553                 /**
554                  * The channel_id of the channel which has been closed. Note that on-chain transactions
555                  * resolving the channel are likely still awaiting confirmation.
556                 */
557                 public final byte[] channel_id;
558                 /**
559                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
560                  * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
561                  * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
562                  * `user_channel_id` will be 0 for an inbound channel.
563                  * This will always be zero for objects serialized with LDK versions prior to 0.0.102.
564                  * 
565                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
566                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
567                  * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
568                 */
569                 public final long user_channel_id;
570                 /**
571                  * The reason the channel was closed.
572                 */
573                 public final org.ldk.structs.ClosureReason reason;
574                 private ChannelClosed(long ptr, bindings.LDKEvent.ChannelClosed obj) {
575                         super(null, ptr);
576                         this.channel_id = obj.channel_id;
577                         this.user_channel_id = obj.user_channel_id;
578                         long reason = obj.reason;
579                         org.ldk.structs.ClosureReason reason_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(reason);
580                         reason_hu_conv.ptrs_to.add(this);
581                         this.reason = reason_hu_conv;
582                 }
583         }
584         /**
585          * Used to indicate to the user that they can abandon the funding transaction and recycle the
586          * inputs for another purpose.
587          */
588         public final static class DiscardFunding extends Event {
589                 /**
590                  * The channel_id of the channel which has been closed.
591                 */
592                 public final byte[] channel_id;
593                 /**
594                  * The full transaction received from the user
595                 */
596                 public final byte[] transaction;
597                 private DiscardFunding(long ptr, bindings.LDKEvent.DiscardFunding obj) {
598                         super(null, ptr);
599                         this.channel_id = obj.channel_id;
600                         this.transaction = obj.transaction;
601                 }
602         }
603         /**
604          * Indicates a request to open a new channel by a peer.
605          * 
606          * To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the
607          * request, call [`ChannelManager::force_close_channel`].
608          * 
609          * The event is only triggered when a new open channel request is received and the
610          * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
611          * 
612          * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
613          * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
614          * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
615          */
616         public final static class OpenChannelRequest extends Event {
617                 /**
618                  * The temporary channel ID of the channel requested to be opened.
619                  * 
620                  * When responding to the request, the `temporary_channel_id` should be passed
621                  * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
622                  * or through [`ChannelManager::force_close_channel`] to reject.
623                  * 
624                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
625                  * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
626                 */
627                 public final byte[] temporary_channel_id;
628                 /**
629                  * The node_id of the counterparty requesting to open the channel.
630                  * 
631                  * When responding to the request, the `counterparty_node_id` should be passed
632                  * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
633                  * accept the request, or through [`ChannelManager::force_close_channel`] to reject the
634                  * request.
635                  * 
636                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
637                  * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
638                 */
639                 public final byte[] counterparty_node_id;
640                 /**
641                  * The channel value of the requested channel.
642                 */
643                 public final long funding_satoshis;
644                 /**
645                  * Our starting balance in the channel if the request is accepted, in milli-satoshi.
646                 */
647                 public final long push_msat;
648                 /**
649                  * The features that this channel will operate with. If you reject the channel, a
650                  * well-behaved counterparty may automatically re-attempt the channel with a new set of
651                  * feature flags.
652                  * 
653                  * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
654                  * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
655                  * 0.0.106.
656                  * 
657                  * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
658                  * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
659                  * 0.0.107. Channels setting this type also need to get manually accepted via
660                  * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`],
661                  * or will be rejected otherwise.
662                  * 
663                  * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
664                 */
665                 public final org.ldk.structs.ChannelTypeFeatures channel_type;
666                 private OpenChannelRequest(long ptr, bindings.LDKEvent.OpenChannelRequest obj) {
667                         super(null, ptr);
668                         this.temporary_channel_id = obj.temporary_channel_id;
669                         this.counterparty_node_id = obj.counterparty_node_id;
670                         this.funding_satoshis = obj.funding_satoshis;
671                         this.push_msat = obj.push_msat;
672                         long channel_type = obj.channel_type;
673                         org.ldk.structs.ChannelTypeFeatures channel_type_hu_conv = null; if (channel_type < 0 || channel_type > 4096) { channel_type_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, channel_type); }
674                         channel_type_hu_conv.ptrs_to.add(this);
675                         this.channel_type = channel_type_hu_conv;
676                 }
677         }
678         long clone_ptr() {
679                 long ret = bindings.Event_clone_ptr(this.ptr);
680                 Reference.reachabilityFence(this);
681                 return ret;
682         }
683
684         /**
685          * Creates a copy of the Event
686          */
687         public Event clone() {
688                 long ret = bindings.Event_clone(this.ptr);
689                 Reference.reachabilityFence(this);
690                 if (ret >= 0 && ret <= 4096) { return null; }
691                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
692                 ret_hu_conv.ptrs_to.add(this);
693                 return ret_hu_conv;
694         }
695
696         /**
697          * Utility method to constructs a new FundingGenerationReady-variant Event
698          */
699         public static Event funding_generation_ready(byte[] temporary_channel_id, byte[] counterparty_node_id, long channel_value_satoshis, byte[] output_script, long user_channel_id) {
700                 long ret = bindings.Event_funding_generation_ready(InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), channel_value_satoshis, output_script, user_channel_id);
701                 Reference.reachabilityFence(temporary_channel_id);
702                 Reference.reachabilityFence(counterparty_node_id);
703                 Reference.reachabilityFence(channel_value_satoshis);
704                 Reference.reachabilityFence(output_script);
705                 Reference.reachabilityFence(user_channel_id);
706                 if (ret >= 0 && ret <= 4096) { return null; }
707                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
708                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
709                 return ret_hu_conv;
710         }
711
712         /**
713          * Utility method to constructs a new PaymentReceived-variant Event
714          */
715         public static Event payment_received(byte[] payment_hash, long amount_msat, PaymentPurpose purpose) {
716                 long ret = bindings.Event_payment_received(InternalUtils.check_arr_len(payment_hash, 32), amount_msat, purpose.ptr);
717                 Reference.reachabilityFence(payment_hash);
718                 Reference.reachabilityFence(amount_msat);
719                 Reference.reachabilityFence(purpose);
720                 if (ret >= 0 && ret <= 4096) { return null; }
721                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
722                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
723                 return ret_hu_conv;
724         }
725
726         /**
727          * Utility method to constructs a new PaymentClaimed-variant Event
728          */
729         public static Event payment_claimed(byte[] payment_hash, long amount_msat, PaymentPurpose purpose) {
730                 long ret = bindings.Event_payment_claimed(InternalUtils.check_arr_len(payment_hash, 32), amount_msat, purpose.ptr);
731                 Reference.reachabilityFence(payment_hash);
732                 Reference.reachabilityFence(amount_msat);
733                 Reference.reachabilityFence(purpose);
734                 if (ret >= 0 && ret <= 4096) { return null; }
735                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
736                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
737                 return ret_hu_conv;
738         }
739
740         /**
741          * Utility method to constructs a new PaymentSent-variant Event
742          */
743         public static Event payment_sent(byte[] payment_id, byte[] payment_preimage, byte[] payment_hash, Option_u64Z fee_paid_msat) {
744                 long ret = bindings.Event_payment_sent(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_preimage, 32), InternalUtils.check_arr_len(payment_hash, 32), fee_paid_msat.ptr);
745                 Reference.reachabilityFence(payment_id);
746                 Reference.reachabilityFence(payment_preimage);
747                 Reference.reachabilityFence(payment_hash);
748                 Reference.reachabilityFence(fee_paid_msat);
749                 if (ret >= 0 && ret <= 4096) { return null; }
750                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
751                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
752                 return ret_hu_conv;
753         }
754
755         /**
756          * Utility method to constructs a new PaymentFailed-variant Event
757          */
758         public static Event payment_failed(byte[] payment_id, byte[] payment_hash) {
759                 long ret = bindings.Event_payment_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32));
760                 Reference.reachabilityFence(payment_id);
761                 Reference.reachabilityFence(payment_hash);
762                 if (ret >= 0 && ret <= 4096) { return null; }
763                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
764                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
765                 return ret_hu_conv;
766         }
767
768         /**
769          * Utility method to constructs a new PaymentPathSuccessful-variant Event
770          */
771         public static Event payment_path_successful(byte[] payment_id, byte[] payment_hash, RouteHop[] path) {
772                 long ret = bindings.Event_payment_path_successful(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray() : null);
773                 Reference.reachabilityFence(payment_id);
774                 Reference.reachabilityFence(payment_hash);
775                 Reference.reachabilityFence(path);
776                 if (ret >= 0 && ret <= 4096) { return null; }
777                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
778                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
779                 return ret_hu_conv;
780         }
781
782         /**
783          * Utility method to constructs a new PaymentPathFailed-variant Event
784          */
785         public static Event payment_path_failed(byte[] payment_id, byte[] payment_hash, boolean rejected_by_dest, Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path, Option_u64Z short_channel_id, RouteParameters retry) {
786                 long ret = bindings.Event_payment_path_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), rejected_by_dest, network_update.ptr, all_paths_failed, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray() : null, short_channel_id.ptr, retry == null ? 0 : retry.ptr & ~1);
787                 Reference.reachabilityFence(payment_id);
788                 Reference.reachabilityFence(payment_hash);
789                 Reference.reachabilityFence(rejected_by_dest);
790                 Reference.reachabilityFence(network_update);
791                 Reference.reachabilityFence(all_paths_failed);
792                 Reference.reachabilityFence(path);
793                 Reference.reachabilityFence(short_channel_id);
794                 Reference.reachabilityFence(retry);
795                 if (ret >= 0 && ret <= 4096) { return null; }
796                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
797                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
798                 return ret_hu_conv;
799         }
800
801         /**
802          * Utility method to constructs a new PendingHTLCsForwardable-variant Event
803          */
804         public static Event pending_htlcs_forwardable(long time_forwardable) {
805                 long ret = bindings.Event_pending_htlcs_forwardable(time_forwardable);
806                 Reference.reachabilityFence(time_forwardable);
807                 if (ret >= 0 && ret <= 4096) { return null; }
808                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
809                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
810                 return ret_hu_conv;
811         }
812
813         /**
814          * Utility method to constructs a new SpendableOutputs-variant Event
815          */
816         public static Event spendable_outputs(SpendableOutputDescriptor[] outputs) {
817                 long ret = bindings.Event_spendable_outputs(outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_27 -> outputs_conv_27.ptr).toArray() : null);
818                 Reference.reachabilityFence(outputs);
819                 if (ret >= 0 && ret <= 4096) { return null; }
820                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
821                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
822                 return ret_hu_conv;
823         }
824
825         /**
826          * Utility method to constructs a new PaymentForwarded-variant Event
827          */
828         public static Event payment_forwarded(byte[] prev_channel_id, byte[] next_channel_id, Option_u64Z fee_earned_msat, boolean claim_from_onchain_tx) {
829                 long ret = bindings.Event_payment_forwarded(InternalUtils.check_arr_len(prev_channel_id, 32), InternalUtils.check_arr_len(next_channel_id, 32), fee_earned_msat.ptr, claim_from_onchain_tx);
830                 Reference.reachabilityFence(prev_channel_id);
831                 Reference.reachabilityFence(next_channel_id);
832                 Reference.reachabilityFence(fee_earned_msat);
833                 Reference.reachabilityFence(claim_from_onchain_tx);
834                 if (ret >= 0 && ret <= 4096) { return null; }
835                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
836                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
837                 return ret_hu_conv;
838         }
839
840         /**
841          * Utility method to constructs a new ChannelClosed-variant Event
842          */
843         public static Event channel_closed(byte[] channel_id, long user_channel_id, ClosureReason reason) {
844                 long ret = bindings.Event_channel_closed(InternalUtils.check_arr_len(channel_id, 32), user_channel_id, reason.ptr);
845                 Reference.reachabilityFence(channel_id);
846                 Reference.reachabilityFence(user_channel_id);
847                 Reference.reachabilityFence(reason);
848                 if (ret >= 0 && ret <= 4096) { return null; }
849                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
850                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
851                 return ret_hu_conv;
852         }
853
854         /**
855          * Utility method to constructs a new DiscardFunding-variant Event
856          */
857         public static Event discard_funding(byte[] channel_id, byte[] transaction) {
858                 long ret = bindings.Event_discard_funding(InternalUtils.check_arr_len(channel_id, 32), transaction);
859                 Reference.reachabilityFence(channel_id);
860                 Reference.reachabilityFence(transaction);
861                 if (ret >= 0 && ret <= 4096) { return null; }
862                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
863                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
864                 return ret_hu_conv;
865         }
866
867         /**
868          * Utility method to constructs a new OpenChannelRequest-variant Event
869          */
870         public static Event open_channel_request(byte[] temporary_channel_id, byte[] counterparty_node_id, long funding_satoshis, long push_msat, ChannelTypeFeatures channel_type) {
871                 long ret = bindings.Event_open_channel_request(InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), funding_satoshis, push_msat, channel_type == null ? 0 : channel_type.ptr & ~1);
872                 Reference.reachabilityFence(temporary_channel_id);
873                 Reference.reachabilityFence(counterparty_node_id);
874                 Reference.reachabilityFence(funding_satoshis);
875                 Reference.reachabilityFence(push_msat);
876                 Reference.reachabilityFence(channel_type);
877                 if (ret >= 0 && ret <= 4096) { return null; }
878                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
879                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
880                 return ret_hu_conv;
881         }
882
883         /**
884          * Serialize the Event object into a byte array which can be read by Event_read
885          */
886         public byte[] write() {
887                 byte[] ret = bindings.Event_write(this.ptr);
888                 Reference.reachabilityFence(this);
889                 return ret;
890         }
891
892 }