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