df53a51150bddd493bc816974f32af70924a7f29
[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.PaymentSent.class) {
35                         return new PaymentSent(ptr, (bindings.LDKEvent.PaymentSent)raw_val);
36                 }
37                 if (raw_val.getClass() == bindings.LDKEvent.PaymentPathFailed.class) {
38                         return new PaymentPathFailed(ptr, (bindings.LDKEvent.PaymentPathFailed)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.PendingHTLCsForwardable.class) {
44                         return new PendingHTLCsForwardable(ptr, (bindings.LDKEvent.PendingHTLCsForwardable)raw_val);
45                 }
46                 if (raw_val.getClass() == bindings.LDKEvent.SpendableOutputs.class) {
47                         return new SpendableOutputs(ptr, (bindings.LDKEvent.SpendableOutputs)raw_val);
48                 }
49                 if (raw_val.getClass() == bindings.LDKEvent.PaymentForwarded.class) {
50                         return new PaymentForwarded(ptr, (bindings.LDKEvent.PaymentForwarded)raw_val);
51                 }
52                 if (raw_val.getClass() == bindings.LDKEvent.ChannelClosed.class) {
53                         return new ChannelClosed(ptr, (bindings.LDKEvent.ChannelClosed)raw_val);
54                 }
55                 if (raw_val.getClass() == bindings.LDKEvent.DiscardFunding.class) {
56                         return new DiscardFunding(ptr, (bindings.LDKEvent.DiscardFunding)raw_val);
57                 }
58                 if (raw_val.getClass() == bindings.LDKEvent.PaymentPathSuccessful.class) {
59                         return new PaymentPathSuccessful(ptr, (bindings.LDKEvent.PaymentPathSuccessful)raw_val);
60                 }
61                 assert false; return null; // Unreachable without extending the (internal) bindings interface
62         }
63
64         /**
65          * Used to indicate that the client should generate a funding transaction with the given
66          * parameters and then call [`ChannelManager::funding_transaction_generated`].
67          * Generated in [`ChannelManager`] message handling.
68          * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
69          * counterparty can steal your funds!
70          * 
71          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
72          * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
73          */
74         public final static class FundingGenerationReady extends Event {
75                 /**
76                  * The random channel_id we picked which you'll need to pass into
77                  * ChannelManager::funding_transaction_generated.
78                 */
79                 public final byte[] temporary_channel_id;
80                 /**
81                  * The value, in satoshis, that the output should have.
82                 */
83                 public final long channel_value_satoshis;
84                 /**
85                  * The script which should be used in the transaction output.
86                 */
87                 public final byte[] output_script;
88                 /**
89                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
90                  * an inbound channel.
91                  * 
92                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
93                 */
94                 public final long user_channel_id;
95                 private FundingGenerationReady(long ptr, bindings.LDKEvent.FundingGenerationReady obj) {
96                         super(null, ptr);
97                         this.temporary_channel_id = obj.temporary_channel_id;
98                         this.channel_value_satoshis = obj.channel_value_satoshis;
99                         this.output_script = obj.output_script;
100                         this.user_channel_id = obj.user_channel_id;
101                 }
102         }
103         /**
104          * Indicates we've received money! Just gotta dig out that payment preimage and feed it to
105          * [`ChannelManager::claim_funds`] to get it....
106          * Note that if the preimage is not known, you should call
107          * [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid
108          * network congestion.
109          * If you fail to call either [`ChannelManager::claim_funds`] or
110          * [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be
111          * automatically failed.
112          * 
113          * # Note
114          * LDK will not stop an inbound payment from being paid multiple times, so multiple
115          * `PaymentReceived` events may be generated for the same payment.
116          * 
117          * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
118          * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
119          */
120         public final static class PaymentReceived extends Event {
121                 /**
122                  * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
123                  * not stop you from registering duplicate payment hashes for inbound payments.
124                 */
125                 public final byte[] payment_hash;
126                 /**
127                  * The value, in thousandths of a satoshi, that this payment is for.
128                 */
129                 public final long amt;
130                 /**
131                  * Information for claiming this received payment, based on whether the purpose of the
132                  * payment is to pay an invoice or to send a spontaneous payment.
133                 */
134                 public final PaymentPurpose purpose;
135                 private PaymentReceived(long ptr, bindings.LDKEvent.PaymentReceived obj) {
136                         super(null, ptr);
137                         this.payment_hash = obj.payment_hash;
138                         this.amt = obj.amt;
139                         long purpose = obj.purpose;
140                         PaymentPurpose purpose_hu_conv = PaymentPurpose.constr_from_ptr(purpose);
141                         purpose_hu_conv.ptrs_to.add(this);
142                         this.purpose = purpose_hu_conv;
143                 }
144         }
145         /**
146          * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
147          * and we got back the payment preimage for it).
148          * 
149          * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
150          * event. In this situation, you SHOULD treat this payment as having succeeded.
151          */
152         public final static class PaymentSent extends Event {
153                 /**
154                  * The id returned by [`ChannelManager::send_payment`] and used with
155                  * [`ChannelManager::retry_payment`].
156                  * 
157                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
158                  * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
159                  * 
160                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
161                 */
162                 @Nullable public final byte[] payment_id;
163                 /**
164                  * The preimage to the hash given to ChannelManager::send_payment.
165                  * Note that this serves as a payment receipt, if you wish to have such a thing, you must
166                  * store it somehow!
167                 */
168                 public final byte[] payment_preimage;
169                 /**
170                  * The hash that was given to [`ChannelManager::send_payment`].
171                  * 
172                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
173                 */
174                 public final byte[] payment_hash;
175                 /**
176                  * The total fee which was spent at intermediate hops in this payment, across all paths.
177                  * 
178                  * Note that, like [`Route::get_total_fees`] this does *not* include any potential
179                  * overpayment to the recipient node.
180                  * 
181                  * If the recipient or an intermediate node misbehaves and gives us free money, this may
182                  * overstate the amount paid, though this is unlikely.
183                  * 
184                  * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
185                 */
186                 public final Option_u64Z fee_paid_msat;
187                 private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
188                         super(null, ptr);
189                         this.payment_id = obj.payment_id;
190                         this.payment_preimage = obj.payment_preimage;
191                         this.payment_hash = obj.payment_hash;
192                         long fee_paid_msat = obj.fee_paid_msat;
193                         Option_u64Z fee_paid_msat_hu_conv = Option_u64Z.constr_from_ptr(fee_paid_msat);
194                         fee_paid_msat_hu_conv.ptrs_to.add(this);
195                         this.fee_paid_msat = fee_paid_msat_hu_conv;
196                 }
197         }
198         /**
199          * Indicates an outbound HTLC we sent failed. Probably some intermediary node dropped
200          * something. You may wish to retry with a different route.
201          * 
202          * Note that this does *not* indicate that all paths for an MPP payment have failed, see
203          * [`Event::PaymentFailed`] and [`all_paths_failed`].
204          * 
205          * [`all_paths_failed`]: Self::all_paths_failed
206          */
207         public final static class PaymentPathFailed extends Event {
208                 /**
209                  * The id returned by [`ChannelManager::send_payment`] and used with
210                  * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
211                  * 
212                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
213                  * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
214                  * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
215                  * 
216                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
217                 */
218                 @Nullable public final byte[] payment_id;
219                 /**
220                  * The hash that was given to [`ChannelManager::send_payment`].
221                  * 
222                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
223                 */
224                 public final byte[] payment_hash;
225                 /**
226                  * Indicates the payment was rejected for some reason by the recipient. This implies that
227                  * the payment has failed, not just the route in question. If this is not set, you may
228                  * retry the payment via a different route.
229                 */
230                 public final boolean rejected_by_dest;
231                 /**
232                  * Any failure information conveyed via the Onion return packet by a node along the failed
233                  * payment route.
234                  * 
235                  * Should be applied to the [`NetworkGraph`] so that routing decisions can take into
236                  * account the update. [`NetGraphMsgHandler`] is capable of doing this.
237                  * 
238                  * [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph
239                  * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
240                 */
241                 public final Option_NetworkUpdateZ network_update;
242                 /**
243                  * For both single-path and multi-path payments, this is set if all paths of the payment have
244                  * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
245                  * larger MPP payment were still in flight when this event was generated.
246                  * 
247                  * Note that if you are retrying individual MPP parts, using this value to determine if a
248                  * payment has fully failed is race-y. Because multiple failures can happen prior to events
249                  * being processed, you may retry in response to a first failure, with a second failure
250                  * (with `all_paths_failed` set) still pending. Then, when the second failure is processed
251                  * you will see `all_paths_failed` set even though the retry of the first failure still
252                  * has an associated in-flight HTLC. See (1) for an example of such a failure.
253                  * 
254                  * If you wish to retry individual MPP parts and learn when a payment has failed, you must
255                  * call [`ChannelManager::abandon_payment`] and wait for a [`Event::PaymentFailed`] event.
256                  * 
257                  * (1) <https://github.com/lightningdevkit/rust-lightning/issues/1164>
258                  * 
259                  * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
260                 */
261                 public final boolean all_paths_failed;
262                 /**
263                  * The payment path that failed.
264                 */
265                 public final RouteHop[] path;
266                 /**
267                  * The channel responsible for the failed payment path.
268                  * 
269                  * If this is `Some`, then the corresponding channel should be avoided when the payment is
270                  * retried. May be `None` for older [`Event`] serializations.
271                 */
272                 public final Option_u64Z short_channel_id;
273                 /**
274                  * Parameters needed to compute a new [`Route`] when retrying the failed payment path.
275                  * 
276                  * See [`find_route`] for details.
277                  * 
278                  * [`Route`]: crate::routing::router::Route
279                  * [`find_route`]: crate::routing::router::find_route
280                  * 
281                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
282                 */
283                 @Nullable public final RouteParameters retry;
284                 private PaymentPathFailed(long ptr, bindings.LDKEvent.PaymentPathFailed obj) {
285                         super(null, ptr);
286                         this.payment_id = obj.payment_id;
287                         this.payment_hash = obj.payment_hash;
288                         this.rejected_by_dest = obj.rejected_by_dest;
289                         long network_update = obj.network_update;
290                         Option_NetworkUpdateZ network_update_hu_conv = Option_NetworkUpdateZ.constr_from_ptr(network_update);
291                         network_update_hu_conv.ptrs_to.add(this);
292                         this.network_update = network_update_hu_conv;
293                         this.all_paths_failed = obj.all_paths_failed;
294                         long[] path = obj.path;
295                         int path_conv_10_len = path.length;
296                         RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
297                         for (int k = 0; k < path_conv_10_len; k++) {
298                                 long path_conv_10 = path[k];
299                                 RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new RouteHop(null, path_conv_10); }
300                                 path_conv_10_hu_conv.ptrs_to.add(this);
301                                 path_conv_10_arr[k] = path_conv_10_hu_conv;
302                         }
303                         this.path = path_conv_10_arr;
304                         long short_channel_id = obj.short_channel_id;
305                         Option_u64Z short_channel_id_hu_conv = Option_u64Z.constr_from_ptr(short_channel_id);
306                         short_channel_id_hu_conv.ptrs_to.add(this);
307                         this.short_channel_id = short_channel_id_hu_conv;
308                         long retry = obj.retry;
309                         RouteParameters retry_hu_conv = null; if (retry < 0 || retry > 4096) { retry_hu_conv = new RouteParameters(null, retry); }
310                         retry_hu_conv.ptrs_to.add(this);
311                         this.retry = retry_hu_conv;
312                 }
313         }
314         /**
315          * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
316          * provide failure information for each MPP part in the payment.
317          * 
318          * This event is provided once there are no further pending HTLCs for the payment and the
319          * payment is no longer retryable, either due to a several-block timeout or because
320          * [`ChannelManager::abandon_payment`] was previously called for the corresponding payment.
321          * 
322          * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
323          */
324         public final static class PaymentFailed extends Event {
325                 /**
326                  * The id returned by [`ChannelManager::send_payment`] and used with
327                  * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
328                  * 
329                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
330                  * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
331                  * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
332                 */
333                 public final byte[] payment_id;
334                 /**
335                  * The hash that was given to [`ChannelManager::send_payment`].
336                  * 
337                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
338                 */
339                 public final byte[] payment_hash;
340                 private PaymentFailed(long ptr, bindings.LDKEvent.PaymentFailed obj) {
341                         super(null, ptr);
342                         this.payment_id = obj.payment_id;
343                         this.payment_hash = obj.payment_hash;
344                 }
345         }
346         /**
347          * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
348          * a time in the future.
349          * 
350          * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
351          */
352         public final static class PendingHTLCsForwardable extends Event {
353                 /**
354                  * The minimum amount of time that should be waited prior to calling
355                  * process_pending_htlc_forwards. To increase the effort required to correlate payments,
356                  * you should wait a random amount of time in roughly the range (now + time_forwardable,
357                  * now + 5*time_forwardable).
358                 */
359                 public final long time_forwardable;
360                 private PendingHTLCsForwardable(long ptr, bindings.LDKEvent.PendingHTLCsForwardable obj) {
361                         super(null, ptr);
362                         this.time_forwardable = obj.time_forwardable;
363                 }
364         }
365         /**
366          * Used to indicate that an output which you should know how to spend was confirmed on chain
367          * and is now spendable.
368          * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
369          * counterparty spending them due to some kind of timeout. Thus, you need to store them
370          * somewhere and spend them when you create on-chain transactions.
371          */
372         public final static class SpendableOutputs extends Event {
373                 /**
374                  * The outputs which you should store as spendable by you.
375                 */
376                 public final SpendableOutputDescriptor[] outputs;
377                 private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
378                         super(null, ptr);
379                         long[] outputs = obj.outputs;
380                         int outputs_conv_27_len = outputs.length;
381                         SpendableOutputDescriptor[] outputs_conv_27_arr = new SpendableOutputDescriptor[outputs_conv_27_len];
382                         for (int b = 0; b < outputs_conv_27_len; b++) {
383                                 long outputs_conv_27 = outputs[b];
384                                 SpendableOutputDescriptor outputs_conv_27_hu_conv = SpendableOutputDescriptor.constr_from_ptr(outputs_conv_27);
385                                 outputs_conv_27_hu_conv.ptrs_to.add(this);
386                                 outputs_conv_27_arr[b] = outputs_conv_27_hu_conv;
387                         }
388                         this.outputs = outputs_conv_27_arr;
389                 }
390         }
391         /**
392          * This event is generated when a payment has been successfully forwarded through us and a
393          * forwarding fee earned.
394          */
395         public final static class PaymentForwarded extends Event {
396                 /**
397                  * The fee, in milli-satoshis, which was earned as a result of the payment.
398                  * 
399                  * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
400                  * was pending, the amount the next hop claimed will have been rounded down to the nearest
401                  * whole satoshi. Thus, the fee calculated here may be higher than expected as we still
402                  * claimed the full value in millisatoshis from the source. In this case,
403                  * `claim_from_onchain_tx` will be set.
404                  * 
405                  * If the channel which sent us the payment has been force-closed, we will claim the funds
406                  * via an on-chain transaction. In that case we do not yet know the on-chain transaction
407                  * fees which we will spend and will instead set this to `None`. It is possible duplicate
408                  * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
409                  * `None`.
410                 */
411                 public final Option_u64Z fee_earned_msat;
412                 /**
413                  * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
414                  * transaction.
415                 */
416                 public final boolean claim_from_onchain_tx;
417                 private PaymentForwarded(long ptr, bindings.LDKEvent.PaymentForwarded obj) {
418                         super(null, ptr);
419                         long fee_earned_msat = obj.fee_earned_msat;
420                         Option_u64Z fee_earned_msat_hu_conv = Option_u64Z.constr_from_ptr(fee_earned_msat);
421                         fee_earned_msat_hu_conv.ptrs_to.add(this);
422                         this.fee_earned_msat = fee_earned_msat_hu_conv;
423                         this.claim_from_onchain_tx = obj.claim_from_onchain_tx;
424                 }
425         }
426         /**
427          * Used to indicate that a channel with the given `channel_id` is in the process of closure.
428          */
429         public final static class ChannelClosed extends Event {
430                 /**
431                  * The channel_id of the channel which has been closed. Note that on-chain transactions
432                  * resolving the channel are likely still awaiting confirmation.
433                 */
434                 public final byte[] channel_id;
435                 /**
436                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
437                  * an inbound channel. This will always be zero for objects serialized with LDK versions
438                  * prior to 0.0.102.
439                  * 
440                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
441                 */
442                 public final long user_channel_id;
443                 /**
444                  * The reason the channel was closed.
445                 */
446                 public final ClosureReason reason;
447                 private ChannelClosed(long ptr, bindings.LDKEvent.ChannelClosed obj) {
448                         super(null, ptr);
449                         this.channel_id = obj.channel_id;
450                         this.user_channel_id = obj.user_channel_id;
451                         long reason = obj.reason;
452                         ClosureReason reason_hu_conv = ClosureReason.constr_from_ptr(reason);
453                         reason_hu_conv.ptrs_to.add(this);
454                         this.reason = reason_hu_conv;
455                 }
456         }
457         /**
458          * Used to indicate to the user that they can abandon the funding transaction and recycle the
459          * inputs for another purpose.
460          */
461         public final static class DiscardFunding extends Event {
462                 /**
463                  * The channel_id of the channel which has been closed.
464                 */
465                 public final byte[] channel_id;
466                 /**
467                  * The full transaction received from the user
468                 */
469                 public final byte[] transaction;
470                 private DiscardFunding(long ptr, bindings.LDKEvent.DiscardFunding obj) {
471                         super(null, ptr);
472                         this.channel_id = obj.channel_id;
473                         this.transaction = obj.transaction;
474                 }
475         }
476         /**
477          * Indicates that a path for an outbound payment was successful.
478          * 
479          * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
480          * [`Event::PaymentSent`] for obtaining the payment preimage.
481          */
482         public final static class PaymentPathSuccessful extends Event {
483                 /**
484                  * The id returned by [`ChannelManager::send_payment`] and used with
485                  * [`ChannelManager::retry_payment`].
486                  * 
487                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
488                  * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
489                 */
490                 public final byte[] payment_id;
491                 /**
492                  * The hash that was given to [`ChannelManager::send_payment`].
493                  * 
494                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
495                  * 
496                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
497                 */
498                 @Nullable public final byte[] payment_hash;
499                 /**
500                  * The payment path that was successful.
501                  * 
502                  * May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
503                 */
504                 public final RouteHop[] path;
505                 private PaymentPathSuccessful(long ptr, bindings.LDKEvent.PaymentPathSuccessful obj) {
506                         super(null, ptr);
507                         this.payment_id = obj.payment_id;
508                         this.payment_hash = obj.payment_hash;
509                         long[] path = obj.path;
510                         int path_conv_10_len = path.length;
511                         RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
512                         for (int k = 0; k < path_conv_10_len; k++) {
513                                 long path_conv_10 = path[k];
514                                 RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new RouteHop(null, path_conv_10); }
515                                 path_conv_10_hu_conv.ptrs_to.add(this);
516                                 path_conv_10_arr[k] = path_conv_10_hu_conv;
517                         }
518                         this.path = path_conv_10_arr;
519                 }
520         }
521         long clone_ptr() {
522                 long ret = bindings.Event_clone_ptr(this.ptr);
523                 Reference.reachabilityFence(this);
524                 return ret;
525         }
526
527         /**
528          * Creates a copy of the Event
529          */
530         public Event clone() {
531                 long ret = bindings.Event_clone(this.ptr);
532                 Reference.reachabilityFence(this);
533                 if (ret >= 0 && ret <= 4096) { return null; }
534                 Event ret_hu_conv = Event.constr_from_ptr(ret);
535                 ret_hu_conv.ptrs_to.add(this);
536                 return ret_hu_conv;
537         }
538
539         /**
540          * Utility method to constructs a new FundingGenerationReady-variant Event
541          */
542         public static Event funding_generation_ready(byte[] temporary_channel_id, long channel_value_satoshis, byte[] output_script, long user_channel_id) {
543                 long ret = bindings.Event_funding_generation_ready(InternalUtils.check_arr_len(temporary_channel_id, 32), channel_value_satoshis, output_script, user_channel_id);
544                 Reference.reachabilityFence(temporary_channel_id);
545                 Reference.reachabilityFence(channel_value_satoshis);
546                 Reference.reachabilityFence(output_script);
547                 Reference.reachabilityFence(user_channel_id);
548                 if (ret >= 0 && ret <= 4096) { return null; }
549                 Event ret_hu_conv = Event.constr_from_ptr(ret);
550                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
551                 return ret_hu_conv;
552         }
553
554         /**
555          * Utility method to constructs a new PaymentReceived-variant Event
556          */
557         public static Event payment_received(byte[] payment_hash, long amt, PaymentPurpose purpose) {
558                 long ret = bindings.Event_payment_received(InternalUtils.check_arr_len(payment_hash, 32), amt, purpose.ptr);
559                 Reference.reachabilityFence(payment_hash);
560                 Reference.reachabilityFence(amt);
561                 Reference.reachabilityFence(purpose);
562                 if (ret >= 0 && ret <= 4096) { return null; }
563                 Event ret_hu_conv = Event.constr_from_ptr(ret);
564                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
565                 return ret_hu_conv;
566         }
567
568         /**
569          * Utility method to constructs a new PaymentSent-variant Event
570          */
571         public static Event payment_sent(byte[] payment_id, byte[] payment_preimage, byte[] payment_hash, Option_u64Z fee_paid_msat) {
572                 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);
573                 Reference.reachabilityFence(payment_id);
574                 Reference.reachabilityFence(payment_preimage);
575                 Reference.reachabilityFence(payment_hash);
576                 Reference.reachabilityFence(fee_paid_msat);
577                 if (ret >= 0 && ret <= 4096) { return null; }
578                 Event ret_hu_conv = Event.constr_from_ptr(ret);
579                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
580                 return ret_hu_conv;
581         }
582
583         /**
584          * Utility method to constructs a new PaymentPathFailed-variant Event
585          */
586         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) {
587                 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);
588                 Reference.reachabilityFence(payment_id);
589                 Reference.reachabilityFence(payment_hash);
590                 Reference.reachabilityFence(rejected_by_dest);
591                 Reference.reachabilityFence(network_update);
592                 Reference.reachabilityFence(all_paths_failed);
593                 Reference.reachabilityFence(path);
594                 Reference.reachabilityFence(short_channel_id);
595                 Reference.reachabilityFence(retry);
596                 if (ret >= 0 && ret <= 4096) { return null; }
597                 Event ret_hu_conv = Event.constr_from_ptr(ret);
598                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
599                 return ret_hu_conv;
600         }
601
602         /**
603          * Utility method to constructs a new PaymentFailed-variant Event
604          */
605         public static Event payment_failed(byte[] payment_id, byte[] payment_hash) {
606                 long ret = bindings.Event_payment_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32));
607                 Reference.reachabilityFence(payment_id);
608                 Reference.reachabilityFence(payment_hash);
609                 if (ret >= 0 && ret <= 4096) { return null; }
610                 Event ret_hu_conv = Event.constr_from_ptr(ret);
611                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
612                 return ret_hu_conv;
613         }
614
615         /**
616          * Utility method to constructs a new PendingHTLCsForwardable-variant Event
617          */
618         public static Event pending_htlcs_forwardable(long time_forwardable) {
619                 long ret = bindings.Event_pending_htlcs_forwardable(time_forwardable);
620                 Reference.reachabilityFence(time_forwardable);
621                 if (ret >= 0 && ret <= 4096) { return null; }
622                 Event ret_hu_conv = Event.constr_from_ptr(ret);
623                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
624                 return ret_hu_conv;
625         }
626
627         /**
628          * Utility method to constructs a new SpendableOutputs-variant Event
629          */
630         public static Event spendable_outputs(SpendableOutputDescriptor[] outputs) {
631                 long ret = bindings.Event_spendable_outputs(outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_27 -> outputs_conv_27.ptr).toArray() : null);
632                 Reference.reachabilityFence(outputs);
633                 if (ret >= 0 && ret <= 4096) { return null; }
634                 Event ret_hu_conv = Event.constr_from_ptr(ret);
635                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
636                 return ret_hu_conv;
637         }
638
639         /**
640          * Utility method to constructs a new PaymentForwarded-variant Event
641          */
642         public static Event payment_forwarded(Option_u64Z fee_earned_msat, boolean claim_from_onchain_tx) {
643                 long ret = bindings.Event_payment_forwarded(fee_earned_msat.ptr, claim_from_onchain_tx);
644                 Reference.reachabilityFence(fee_earned_msat);
645                 Reference.reachabilityFence(claim_from_onchain_tx);
646                 if (ret >= 0 && ret <= 4096) { return null; }
647                 Event ret_hu_conv = Event.constr_from_ptr(ret);
648                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
649                 return ret_hu_conv;
650         }
651
652         /**
653          * Utility method to constructs a new ChannelClosed-variant Event
654          */
655         public static Event channel_closed(byte[] channel_id, long user_channel_id, ClosureReason reason) {
656                 long ret = bindings.Event_channel_closed(InternalUtils.check_arr_len(channel_id, 32), user_channel_id, reason.ptr);
657                 Reference.reachabilityFence(channel_id);
658                 Reference.reachabilityFence(user_channel_id);
659                 Reference.reachabilityFence(reason);
660                 if (ret >= 0 && ret <= 4096) { return null; }
661                 Event ret_hu_conv = Event.constr_from_ptr(ret);
662                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
663                 return ret_hu_conv;
664         }
665
666         /**
667          * Utility method to constructs a new DiscardFunding-variant Event
668          */
669         public static Event discard_funding(byte[] channel_id, byte[] transaction) {
670                 long ret = bindings.Event_discard_funding(InternalUtils.check_arr_len(channel_id, 32), transaction);
671                 Reference.reachabilityFence(channel_id);
672                 Reference.reachabilityFence(transaction);
673                 if (ret >= 0 && ret <= 4096) { return null; }
674                 Event ret_hu_conv = Event.constr_from_ptr(ret);
675                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
676                 return ret_hu_conv;
677         }
678
679         /**
680          * Utility method to constructs a new PaymentPathSuccessful-variant Event
681          */
682         public static Event payment_path_successful(byte[] payment_id, byte[] payment_hash, RouteHop[] path) {
683                 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);
684                 Reference.reachabilityFence(payment_id);
685                 Reference.reachabilityFence(payment_hash);
686                 Reference.reachabilityFence(path);
687                 if (ret >= 0 && ret <= 4096) { return null; }
688                 Event ret_hu_conv = Event.constr_from_ptr(ret);
689                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
690                 return ret_hu_conv;
691         }
692
693         /**
694          * Serialize the Event object into a byte array which can be read by Event_read
695          */
696         public byte[] write() {
697                 byte[] ret = bindings.Event_write(this.ptr);
698                 Reference.reachabilityFence(this);
699                 return ret;
700         }
701
702 }