90a5fecf781b7d5d3b84c7f3f5dc636aa38f45c7
[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.PaymentClaimable.class) {
32                         return new PaymentClaimable(ptr, (bindings.LDKEvent.PaymentClaimable)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.ProbeSuccessful.class) {
50                         return new ProbeSuccessful(ptr, (bindings.LDKEvent.ProbeSuccessful)raw_val);
51                 }
52                 if (raw_val.getClass() == bindings.LDKEvent.ProbeFailed.class) {
53                         return new ProbeFailed(ptr, (bindings.LDKEvent.ProbeFailed)raw_val);
54                 }
55                 if (raw_val.getClass() == bindings.LDKEvent.PendingHTLCsForwardable.class) {
56                         return new PendingHTLCsForwardable(ptr, (bindings.LDKEvent.PendingHTLCsForwardable)raw_val);
57                 }
58                 if (raw_val.getClass() == bindings.LDKEvent.HTLCIntercepted.class) {
59                         return new HTLCIntercepted(ptr, (bindings.LDKEvent.HTLCIntercepted)raw_val);
60                 }
61                 if (raw_val.getClass() == bindings.LDKEvent.SpendableOutputs.class) {
62                         return new SpendableOutputs(ptr, (bindings.LDKEvent.SpendableOutputs)raw_val);
63                 }
64                 if (raw_val.getClass() == bindings.LDKEvent.PaymentForwarded.class) {
65                         return new PaymentForwarded(ptr, (bindings.LDKEvent.PaymentForwarded)raw_val);
66                 }
67                 if (raw_val.getClass() == bindings.LDKEvent.ChannelPending.class) {
68                         return new ChannelPending(ptr, (bindings.LDKEvent.ChannelPending)raw_val);
69                 }
70                 if (raw_val.getClass() == bindings.LDKEvent.ChannelReady.class) {
71                         return new ChannelReady(ptr, (bindings.LDKEvent.ChannelReady)raw_val);
72                 }
73                 if (raw_val.getClass() == bindings.LDKEvent.ChannelClosed.class) {
74                         return new ChannelClosed(ptr, (bindings.LDKEvent.ChannelClosed)raw_val);
75                 }
76                 if (raw_val.getClass() == bindings.LDKEvent.DiscardFunding.class) {
77                         return new DiscardFunding(ptr, (bindings.LDKEvent.DiscardFunding)raw_val);
78                 }
79                 if (raw_val.getClass() == bindings.LDKEvent.OpenChannelRequest.class) {
80                         return new OpenChannelRequest(ptr, (bindings.LDKEvent.OpenChannelRequest)raw_val);
81                 }
82                 if (raw_val.getClass() == bindings.LDKEvent.HTLCHandlingFailed.class) {
83                         return new HTLCHandlingFailed(ptr, (bindings.LDKEvent.HTLCHandlingFailed)raw_val);
84                 }
85                 if (raw_val.getClass() == bindings.LDKEvent.BumpTransaction.class) {
86                         return new BumpTransaction(ptr, (bindings.LDKEvent.BumpTransaction)raw_val);
87                 }
88                 assert false; return null; // Unreachable without extending the (internal) bindings interface
89         }
90
91         /**
92          * Used to indicate that the client should generate a funding transaction with the given
93          * parameters and then call [`ChannelManager::funding_transaction_generated`].
94          * Generated in [`ChannelManager`] message handling.
95          * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
96          * counterparty can steal your funds!
97          * 
98          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
99          * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
100          */
101         public final static class FundingGenerationReady extends Event {
102                 /**
103                  * The random channel_id we picked which you'll need to pass into
104                  * [`ChannelManager::funding_transaction_generated`].
105                  * 
106                  * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
107                 */
108                 public final byte[] temporary_channel_id;
109                 /**
110                  * The counterparty's node_id, which you'll need to pass back into
111                  * [`ChannelManager::funding_transaction_generated`].
112                  * 
113                  * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
114                 */
115                 public final byte[] counterparty_node_id;
116                 /**
117                  * The value, in satoshis, that the output should have.
118                 */
119                 public final long channel_value_satoshis;
120                 /**
121                  * The script which should be used in the transaction output.
122                 */
123                 public final byte[] output_script;
124                 /**
125                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
126                  * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
127                  * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
128                  * `user_channel_id` will be randomized for an inbound channel.  This may be zero for objects
129                  * serialized with LDK versions prior to 0.0.113.
130                  * 
131                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
132                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
133                  * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
134                 */
135                 public final org.ldk.util.UInt128 user_channel_id;
136                 private FundingGenerationReady(long ptr, bindings.LDKEvent.FundingGenerationReady obj) {
137                         super(null, ptr);
138                         this.temporary_channel_id = obj.temporary_channel_id;
139                         this.counterparty_node_id = obj.counterparty_node_id;
140                         this.channel_value_satoshis = obj.channel_value_satoshis;
141                         this.output_script = obj.output_script;
142                         byte[] user_channel_id = obj.user_channel_id;
143                         org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
144                         this.user_channel_id = user_channel_id_conv;
145                 }
146         }
147         /**
148          * Indicates that we've been offered a payment and it needs to be claimed via calling
149          * [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`].
150          * 
151          * Note that if the preimage is not known, you should call
152          * [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`]
153          * to free up resources for this HTLC and avoid network congestion.
154          * 
155          * If [`Event::PaymentClaimable::onion_fields`] is `Some`, and includes custom TLVs with even type
156          * numbers, you should use [`ChannelManager::fail_htlc_backwards_with_reason`] with
157          * [`FailureCode::InvalidOnionPayload`] if you fail to understand and handle the contents, or
158          * [`ChannelManager::claim_funds_with_known_custom_tlvs`] upon successful handling.
159          * If you don't intend to check for custom TLVs, you can simply use
160          * [`ChannelManager::claim_funds`], which will automatically fail back even custom TLVs.
161          * 
162          * If you fail to call [`ChannelManager::claim_funds`],
163          * [`ChannelManager::claim_funds_with_known_custom_tlvs`],
164          * [`ChannelManager::fail_htlc_backwards`], or
165          * [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will
166          * be automatically failed.
167          * 
168          * # Note
169          * LDK will not stop an inbound payment from being paid multiple times, so multiple
170          * `PaymentClaimable` events may be generated for the same payment. In such a case it is
171          * polite (and required in the lightning specification) to fail the payment the second time
172          * and give the sender their money back rather than accepting double payment.
173          * 
174          * # Note
175          * This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier.
176          * 
177          * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
178          * [`ChannelManager::claim_funds_with_known_custom_tlvs`]: crate::ln::channelmanager::ChannelManager::claim_funds_with_known_custom_tlvs
179          * [`FailureCode::InvalidOnionPayload`]: crate::ln::channelmanager::FailureCode::InvalidOnionPayload
180          * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
181          * [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason
182          */
183         public final static class PaymentClaimable extends Event {
184                 /**
185                  * The node that will receive the payment after it has been claimed.
186                  * This is useful to identify payments received via [phantom nodes].
187                  * This field will always be filled in when the event was generated by LDK versions
188                  * 0.0.113 and above.
189                  * 
190                  * [phantom nodes]: crate::sign::PhantomKeysManager
191                  * 
192                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
193                 */
194                 @Nullable public final byte[] receiver_node_id;
195                 /**
196                  * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
197                  * not stop you from registering duplicate payment hashes for inbound payments.
198                 */
199                 public final byte[] payment_hash;
200                 /**
201                  * The fields in the onion which were received with each HTLC. Only fields which were
202                  * identical in each HTLC involved in the payment will be included here.
203                  * 
204                  * Payments received on LDK versions prior to 0.0.115 will have this field unset.
205                  * 
206                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
207                 */
208                 @Nullable public final org.ldk.structs.RecipientOnionFields onion_fields;
209                 /**
210                  * The value, in thousandths of a satoshi, that this payment is claimable for. May be greater
211                  * than the invoice amount.
212                  * 
213                  * May be less than the invoice amount if [`ChannelConfig::accept_underpaying_htlcs`] is set
214                  * and the previous hop took an extra fee.
215                  * 
216                  * # Note
217                  * If [`ChannelConfig::accept_underpaying_htlcs`] is set and you claim without verifying this
218                  * field, you may lose money!
219                  * 
220                  * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
221                 */
222                 public final long amount_msat;
223                 /**
224                  * The value, in thousands of a satoshi, that was skimmed off of this payment as an extra fee
225                  * taken by our channel counterparty.
226                  * 
227                  * Will always be 0 unless [`ChannelConfig::accept_underpaying_htlcs`] is set.
228                  * 
229                  * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
230                 */
231                 public final long counterparty_skimmed_fee_msat;
232                 /**
233                  * Information for claiming this received payment, based on whether the purpose of the
234                  * payment is to pay an invoice or to send a spontaneous payment.
235                 */
236                 public final org.ldk.structs.PaymentPurpose purpose;
237                 /**
238                  * The `channel_id` indicating over which channel we received the payment.
239                 */
240                 public final org.ldk.structs.Option_ThirtyTwoBytesZ via_channel_id;
241                 /**
242                  * The `user_channel_id` indicating over which channel we received the payment.
243                 */
244                 public final org.ldk.structs.Option_U128Z via_user_channel_id;
245                 /**
246                  * The block height at which this payment will be failed back and will no longer be
247                  * eligible for claiming.
248                  * 
249                  * Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to
250                  * succeed, however you should wait for [`Event::PaymentClaimed`] to be sure.
251                  * 
252                  * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
253                 */
254                 public final org.ldk.structs.Option_u32Z claim_deadline;
255                 private PaymentClaimable(long ptr, bindings.LDKEvent.PaymentClaimable obj) {
256                         super(null, ptr);
257                         this.receiver_node_id = obj.receiver_node_id;
258                         this.payment_hash = obj.payment_hash;
259                         long onion_fields = obj.onion_fields;
260                         org.ldk.structs.RecipientOnionFields onion_fields_hu_conv = null; if (onion_fields < 0 || onion_fields > 4096) { onion_fields_hu_conv = new org.ldk.structs.RecipientOnionFields(null, onion_fields); }
261                         if (onion_fields_hu_conv != null) { onion_fields_hu_conv.ptrs_to.add(this); };
262                         this.onion_fields = onion_fields_hu_conv;
263                         this.amount_msat = obj.amount_msat;
264                         this.counterparty_skimmed_fee_msat = obj.counterparty_skimmed_fee_msat;
265                         long purpose = obj.purpose;
266                         org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
267                         if (purpose_hu_conv != null) { purpose_hu_conv.ptrs_to.add(this); };
268                         this.purpose = purpose_hu_conv;
269                         long via_channel_id = obj.via_channel_id;
270                         org.ldk.structs.Option_ThirtyTwoBytesZ via_channel_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(via_channel_id);
271                         if (via_channel_id_hu_conv != null) { via_channel_id_hu_conv.ptrs_to.add(this); };
272                         this.via_channel_id = via_channel_id_hu_conv;
273                         long via_user_channel_id = obj.via_user_channel_id;
274                         org.ldk.structs.Option_U128Z via_user_channel_id_hu_conv = org.ldk.structs.Option_U128Z.constr_from_ptr(via_user_channel_id);
275                         if (via_user_channel_id_hu_conv != null) { via_user_channel_id_hu_conv.ptrs_to.add(this); };
276                         this.via_user_channel_id = via_user_channel_id_hu_conv;
277                         long claim_deadline = obj.claim_deadline;
278                         org.ldk.structs.Option_u32Z claim_deadline_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(claim_deadline);
279                         if (claim_deadline_hu_conv != null) { claim_deadline_hu_conv.ptrs_to.add(this); };
280                         this.claim_deadline = claim_deadline_hu_conv;
281                 }
282         }
283         /**
284          * Indicates a payment has been claimed and we've received money!
285          * 
286          * This most likely occurs when [`ChannelManager::claim_funds`] has been called in response
287          * to an [`Event::PaymentClaimable`]. However, if we previously crashed during a
288          * [`ChannelManager::claim_funds`] call you may see this event without a corresponding
289          * [`Event::PaymentClaimable`] event.
290          * 
291          * # Note
292          * LDK will not stop an inbound payment from being paid multiple times, so multiple
293          * `PaymentClaimable` events may be generated for the same payment. If you then call
294          * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get
295          * multiple `PaymentClaimed` events.
296          * 
297          * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
298          */
299         public final static class PaymentClaimed extends Event {
300                 /**
301                  * The node that received the payment.
302                  * This is useful to identify payments which were received via [phantom nodes].
303                  * This field will always be filled in when the event was generated by LDK versions
304                  * 0.0.113 and above.
305                  * 
306                  * [phantom nodes]: crate::sign::PhantomKeysManager
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[] receiver_node_id;
311                 /**
312                  * The payment hash of the claimed payment. Note that LDK will not stop you from
313                  * registering duplicate payment hashes for inbound payments.
314                 */
315                 public final byte[] payment_hash;
316                 /**
317                  * The value, in thousandths of a satoshi, that this payment is for. May be greater than the
318                  * invoice amount.
319                 */
320                 public final long amount_msat;
321                 /**
322                  * The purpose of the claimed payment, i.e. whether the payment was for an invoice or a
323                  * spontaneous payment.
324                 */
325                 public final org.ldk.structs.PaymentPurpose purpose;
326                 /**
327                  * The HTLCs that comprise the claimed payment. This will be empty for events serialized prior
328                  * to LDK version 0.0.117.
329                 */
330                 public final ClaimedHTLC[] htlcs;
331                 /**
332                  * The sender-intended sum total of all the MPP parts. This will be `None` for events
333                  * serialized prior to LDK version 0.0.117.
334                 */
335                 public final org.ldk.structs.Option_u64Z sender_intended_total_msat;
336                 private PaymentClaimed(long ptr, bindings.LDKEvent.PaymentClaimed obj) {
337                         super(null, ptr);
338                         this.receiver_node_id = obj.receiver_node_id;
339                         this.payment_hash = obj.payment_hash;
340                         this.amount_msat = obj.amount_msat;
341                         long purpose = obj.purpose;
342                         org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
343                         if (purpose_hu_conv != null) { purpose_hu_conv.ptrs_to.add(this); };
344                         this.purpose = purpose_hu_conv;
345                         long[] htlcs = obj.htlcs;
346                         int htlcs_conv_13_len = htlcs.length;
347                         ClaimedHTLC[] htlcs_conv_13_arr = new ClaimedHTLC[htlcs_conv_13_len];
348                         for (int n = 0; n < htlcs_conv_13_len; n++) {
349                                 long htlcs_conv_13 = htlcs[n];
350                                 org.ldk.structs.ClaimedHTLC htlcs_conv_13_hu_conv = null; if (htlcs_conv_13 < 0 || htlcs_conv_13 > 4096) { htlcs_conv_13_hu_conv = new org.ldk.structs.ClaimedHTLC(null, htlcs_conv_13); }
351                                 if (htlcs_conv_13_hu_conv != null) { htlcs_conv_13_hu_conv.ptrs_to.add(this); };
352                                 htlcs_conv_13_arr[n] = htlcs_conv_13_hu_conv;
353                         }
354                         this.htlcs = htlcs_conv_13_arr;
355                         long sender_intended_total_msat = obj.sender_intended_total_msat;
356                         org.ldk.structs.Option_u64Z sender_intended_total_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(sender_intended_total_msat);
357                         if (sender_intended_total_msat_hu_conv != null) { sender_intended_total_msat_hu_conv.ptrs_to.add(this); };
358                         this.sender_intended_total_msat = sender_intended_total_msat_hu_conv;
359                 }
360         }
361         /**
362          * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
363          * and we got back the payment preimage for it).
364          * 
365          * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
366          * event. In this situation, you SHOULD treat this payment as having succeeded.
367          */
368         public final static class PaymentSent extends Event {
369                 /**
370                  * The `payment_id` passed to [`ChannelManager::send_payment`].
371                  * 
372                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
373                 */
374                 public final org.ldk.structs.Option_ThirtyTwoBytesZ payment_id;
375                 /**
376                  * The preimage to the hash given to ChannelManager::send_payment.
377                  * Note that this serves as a payment receipt, if you wish to have such a thing, you must
378                  * store it somehow!
379                 */
380                 public final byte[] payment_preimage;
381                 /**
382                  * The hash that was given to [`ChannelManager::send_payment`].
383                  * 
384                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
385                 */
386                 public final byte[] payment_hash;
387                 /**
388                  * The total fee which was spent at intermediate hops in this payment, across all paths.
389                  * 
390                  * Note that, like [`Route::get_total_fees`] this does *not* include any potential
391                  * overpayment to the recipient node.
392                  * 
393                  * If the recipient or an intermediate node misbehaves and gives us free money, this may
394                  * overstate the amount paid, though this is unlikely.
395                  * 
396                  * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
397                 */
398                 public final org.ldk.structs.Option_u64Z fee_paid_msat;
399                 private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
400                         super(null, ptr);
401                         long payment_id = obj.payment_id;
402                         org.ldk.structs.Option_ThirtyTwoBytesZ payment_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(payment_id);
403                         if (payment_id_hu_conv != null) { payment_id_hu_conv.ptrs_to.add(this); };
404                         this.payment_id = payment_id_hu_conv;
405                         this.payment_preimage = obj.payment_preimage;
406                         this.payment_hash = obj.payment_hash;
407                         long fee_paid_msat = obj.fee_paid_msat;
408                         org.ldk.structs.Option_u64Z fee_paid_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_paid_msat);
409                         if (fee_paid_msat_hu_conv != null) { fee_paid_msat_hu_conv.ptrs_to.add(this); };
410                         this.fee_paid_msat = fee_paid_msat_hu_conv;
411                 }
412         }
413         /**
414          * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
415          * provide failure information for each path attempt in the payment, including retries.
416          * 
417          * This event is provided once there are no further pending HTLCs for the payment and the
418          * payment is no longer retryable, due either to the [`Retry`] provided or
419          * [`ChannelManager::abandon_payment`] having been called for the corresponding payment.
420          * 
421          * In exceedingly rare cases, it is possible that an [`Event::PaymentFailed`] is generated for
422          * a payment after an [`Event::PaymentSent`] event for this same payment has already been
423          * received and processed. In this case, the [`Event::PaymentFailed`] event MUST be ignored,
424          * and the payment MUST be treated as having succeeded.
425          * 
426          * [`Retry`]: crate::ln::channelmanager::Retry
427          * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
428          */
429         public final static class PaymentFailed extends Event {
430                 /**
431                  * The `payment_id` passed to [`ChannelManager::send_payment`].
432                  * 
433                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
434                 */
435                 public final byte[] payment_id;
436                 /**
437                  * The hash that was given to [`ChannelManager::send_payment`].
438                  * 
439                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
440                 */
441                 public final byte[] payment_hash;
442                 /**
443                  * The reason the payment failed. This is only `None` for events generated or serialized
444                  * by versions prior to 0.0.115.
445                 */
446                 public final org.ldk.structs.Option_PaymentFailureReasonZ reason;
447                 private PaymentFailed(long ptr, bindings.LDKEvent.PaymentFailed obj) {
448                         super(null, ptr);
449                         this.payment_id = obj.payment_id;
450                         this.payment_hash = obj.payment_hash;
451                         long reason = obj.reason;
452                         org.ldk.structs.Option_PaymentFailureReasonZ reason_hu_conv = org.ldk.structs.Option_PaymentFailureReasonZ.constr_from_ptr(reason);
453                         if (reason_hu_conv != null) { reason_hu_conv.ptrs_to.add(this); };
454                         this.reason = reason_hu_conv;
455                 }
456         }
457         /**
458          * Indicates that a path for an outbound payment was successful.
459          * 
460          * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
461          * [`Event::PaymentSent`] for obtaining the payment preimage.
462          */
463         public final static class PaymentPathSuccessful extends Event {
464                 /**
465                  * The `payment_id` passed to [`ChannelManager::send_payment`].
466                  * 
467                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
468                 */
469                 public final byte[] payment_id;
470                 /**
471                  * The hash that was given to [`ChannelManager::send_payment`].
472                  * 
473                  * This will be `Some` for all payments which completed on LDK 0.0.104 or later.
474                  * 
475                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
476                 */
477                 public final org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash;
478                 /**
479                  * The payment path that was successful.
480                  * 
481                  * May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
482                 */
483                 public final org.ldk.structs.Path path;
484                 private PaymentPathSuccessful(long ptr, bindings.LDKEvent.PaymentPathSuccessful obj) {
485                         super(null, ptr);
486                         this.payment_id = obj.payment_id;
487                         long payment_hash = obj.payment_hash;
488                         org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(payment_hash);
489                         if (payment_hash_hu_conv != null) { payment_hash_hu_conv.ptrs_to.add(this); };
490                         this.payment_hash = payment_hash_hu_conv;
491                         long path = obj.path;
492                         org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
493                         if (path_hu_conv != null) { path_hu_conv.ptrs_to.add(this); };
494                         this.path = path_hu_conv;
495                 }
496         }
497         /**
498          * Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to
499          * handle the HTLC.
500          * 
501          * Note that this does *not* indicate that all paths for an MPP payment have failed, see
502          * [`Event::PaymentFailed`].
503          * 
504          * See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have
505          * been exhausted.
506          * 
507          * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
508          */
509         public final static class PaymentPathFailed extends Event {
510                 /**
511                  * The `payment_id` passed to [`ChannelManager::send_payment`].
512                  * 
513                  * This will be `Some` for all payment paths which failed on LDK 0.0.103 or later.
514                  * 
515                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
516                  * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
517                 */
518                 public final org.ldk.structs.Option_ThirtyTwoBytesZ payment_id;
519                 /**
520                  * The hash that was given to [`ChannelManager::send_payment`].
521                  * 
522                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
523                 */
524                 public final byte[] payment_hash;
525                 /**
526                  * Indicates the payment was rejected for some reason by the recipient. This implies that
527                  * the payment has failed, not just the route in question. If this is not set, the payment may
528                  * be retried via a different route.
529                 */
530                 public final boolean payment_failed_permanently;
531                 /**
532                  * Extra error details based on the failure type. May contain an update that needs to be
533                  * applied to the [`NetworkGraph`].
534                  * 
535                  * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
536                 */
537                 public final org.ldk.structs.PathFailure failure;
538                 /**
539                  * The payment path that failed.
540                 */
541                 public final org.ldk.structs.Path path;
542                 /**
543                  * The channel responsible for the failed payment path.
544                  * 
545                  * Note that for route hints or for the first hop in a path this may be an SCID alias and
546                  * may not refer to a channel in the public network graph. These aliases may also collide
547                  * with channels in the public network graph.
548                  * 
549                  * If this is `Some`, then the corresponding channel should be avoided when the payment is
550                  * retried. May be `None` for older [`Event`] serializations.
551                 */
552                 public final org.ldk.structs.Option_u64Z short_channel_id;
553                 private PaymentPathFailed(long ptr, bindings.LDKEvent.PaymentPathFailed obj) {
554                         super(null, ptr);
555                         long payment_id = obj.payment_id;
556                         org.ldk.structs.Option_ThirtyTwoBytesZ payment_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(payment_id);
557                         if (payment_id_hu_conv != null) { payment_id_hu_conv.ptrs_to.add(this); };
558                         this.payment_id = payment_id_hu_conv;
559                         this.payment_hash = obj.payment_hash;
560                         this.payment_failed_permanently = obj.payment_failed_permanently;
561                         long failure = obj.failure;
562                         org.ldk.structs.PathFailure failure_hu_conv = org.ldk.structs.PathFailure.constr_from_ptr(failure);
563                         if (failure_hu_conv != null) { failure_hu_conv.ptrs_to.add(this); };
564                         this.failure = failure_hu_conv;
565                         long path = obj.path;
566                         org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
567                         if (path_hu_conv != null) { path_hu_conv.ptrs_to.add(this); };
568                         this.path = path_hu_conv;
569                         long short_channel_id = obj.short_channel_id;
570                         org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id);
571                         if (short_channel_id_hu_conv != null) { short_channel_id_hu_conv.ptrs_to.add(this); };
572                         this.short_channel_id = short_channel_id_hu_conv;
573                 }
574         }
575         /**
576          * Indicates that a probe payment we sent returned successful, i.e., only failed at the destination.
577          */
578         public final static class ProbeSuccessful extends Event {
579                 /**
580                  * The id returned by [`ChannelManager::send_probe`].
581                  * 
582                  * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
583                 */
584                 public final byte[] payment_id;
585                 /**
586                  * The hash generated by [`ChannelManager::send_probe`].
587                  * 
588                  * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
589                 */
590                 public final byte[] payment_hash;
591                 /**
592                  * The payment path that was successful.
593                 */
594                 public final org.ldk.structs.Path path;
595                 private ProbeSuccessful(long ptr, bindings.LDKEvent.ProbeSuccessful obj) {
596                         super(null, ptr);
597                         this.payment_id = obj.payment_id;
598                         this.payment_hash = obj.payment_hash;
599                         long path = obj.path;
600                         org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
601                         if (path_hu_conv != null) { path_hu_conv.ptrs_to.add(this); };
602                         this.path = path_hu_conv;
603                 }
604         }
605         /**
606          * Indicates that a probe payment we sent failed at an intermediary node on the path.
607          */
608         public final static class ProbeFailed extends Event {
609                 /**
610                  * The id returned by [`ChannelManager::send_probe`].
611                  * 
612                  * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
613                 */
614                 public final byte[] payment_id;
615                 /**
616                  * The hash generated by [`ChannelManager::send_probe`].
617                  * 
618                  * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
619                 */
620                 public final byte[] payment_hash;
621                 /**
622                  * The payment path that failed.
623                 */
624                 public final org.ldk.structs.Path path;
625                 /**
626                  * The channel responsible for the failed probe.
627                  * 
628                  * Note that for route hints or for the first hop in a path this may be an SCID alias and
629                  * may not refer to a channel in the public network graph. These aliases may also collide
630                  * with channels in the public network graph.
631                 */
632                 public final org.ldk.structs.Option_u64Z short_channel_id;
633                 private ProbeFailed(long ptr, bindings.LDKEvent.ProbeFailed obj) {
634                         super(null, ptr);
635                         this.payment_id = obj.payment_id;
636                         this.payment_hash = obj.payment_hash;
637                         long path = obj.path;
638                         org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
639                         if (path_hu_conv != null) { path_hu_conv.ptrs_to.add(this); };
640                         this.path = path_hu_conv;
641                         long short_channel_id = obj.short_channel_id;
642                         org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id);
643                         if (short_channel_id_hu_conv != null) { short_channel_id_hu_conv.ptrs_to.add(this); };
644                         this.short_channel_id = short_channel_id_hu_conv;
645                 }
646         }
647         /**
648          * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
649          * a time in the future.
650          * 
651          * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
652          */
653         public final static class PendingHTLCsForwardable extends Event {
654                 /**
655                  * The minimum amount of time that should be waited prior to calling
656                  * process_pending_htlc_forwards. To increase the effort required to correlate payments,
657                  * you should wait a random amount of time in roughly the range (now + time_forwardable,
658                  * now + 5*time_forwardable).
659                 */
660                 public final long time_forwardable;
661                 private PendingHTLCsForwardable(long ptr, bindings.LDKEvent.PendingHTLCsForwardable obj) {
662                         super(null, ptr);
663                         this.time_forwardable = obj.time_forwardable;
664                 }
665         }
666         /**
667          * Used to indicate that we've intercepted an HTLC forward. This event will only be generated if
668          * you've encoded an intercept scid in the receiver's invoice route hints using
669          * [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`].
670          * 
671          * [`ChannelManager::forward_intercepted_htlc`] or
672          * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See
673          * their docs for more information.
674          * 
675          * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
676          * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
677          * [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
678          * [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc
679          */
680         public final static class HTLCIntercepted extends Event {
681                 /**
682                  * An id to help LDK identify which HTLC is being forwarded or failed.
683                 */
684                 public final byte[] intercept_id;
685                 /**
686                  * The fake scid that was programmed as the next hop's scid, generated using
687                  * [`ChannelManager::get_intercept_scid`].
688                  * 
689                  * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
690                 */
691                 public final long requested_next_hop_scid;
692                 /**
693                  * The payment hash used for this HTLC.
694                 */
695                 public final byte[] payment_hash;
696                 /**
697                  * How many msats were received on the inbound edge of this HTLC.
698                 */
699                 public final long inbound_amount_msat;
700                 /**
701                  * How many msats the payer intended to route to the next node. Depending on the reason you are
702                  * intercepting this payment, you might take a fee by forwarding less than this amount.
703                  * Forwarding less than this amount may break compatibility with LDK versions prior to 0.0.116.
704                  * 
705                  * Note that LDK will NOT check that expected fees were factored into this value. You MUST
706                  * check that whatever fee you want has been included here or subtract it as required. Further,
707                  * LDK will not stop you from forwarding more than you received.
708                 */
709                 public final long expected_outbound_amount_msat;
710                 private HTLCIntercepted(long ptr, bindings.LDKEvent.HTLCIntercepted obj) {
711                         super(null, ptr);
712                         this.intercept_id = obj.intercept_id;
713                         this.requested_next_hop_scid = obj.requested_next_hop_scid;
714                         this.payment_hash = obj.payment_hash;
715                         this.inbound_amount_msat = obj.inbound_amount_msat;
716                         this.expected_outbound_amount_msat = obj.expected_outbound_amount_msat;
717                 }
718         }
719         /**
720          * Used to indicate that an output which you should know how to spend was confirmed on chain
721          * and is now spendable.
722          * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
723          * counterparty spending them due to some kind of timeout. Thus, you need to store them
724          * somewhere and spend them when you create on-chain transactions.
725          */
726         public final static class SpendableOutputs extends Event {
727                 /**
728                  * The outputs which you should store as spendable by you.
729                 */
730                 public final SpendableOutputDescriptor[] outputs;
731                 /**
732                  * The `channel_id` indicating which channel the spendable outputs belong to.
733                  * 
734                  * This will always be `Some` for events generated by LDK versions 0.0.117 and above.
735                 */
736                 public final org.ldk.structs.Option_ThirtyTwoBytesZ channel_id;
737                 private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
738                         super(null, ptr);
739                         long[] outputs = obj.outputs;
740                         int outputs_conv_27_len = outputs.length;
741                         SpendableOutputDescriptor[] outputs_conv_27_arr = new SpendableOutputDescriptor[outputs_conv_27_len];
742                         for (int b = 0; b < outputs_conv_27_len; b++) {
743                                 long outputs_conv_27 = outputs[b];
744                                 org.ldk.structs.SpendableOutputDescriptor outputs_conv_27_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(outputs_conv_27);
745                                 if (outputs_conv_27_hu_conv != null) { outputs_conv_27_hu_conv.ptrs_to.add(this); };
746                                 outputs_conv_27_arr[b] = outputs_conv_27_hu_conv;
747                         }
748                         this.outputs = outputs_conv_27_arr;
749                         long channel_id = obj.channel_id;
750                         org.ldk.structs.Option_ThirtyTwoBytesZ channel_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(channel_id);
751                         if (channel_id_hu_conv != null) { channel_id_hu_conv.ptrs_to.add(this); };
752                         this.channel_id = channel_id_hu_conv;
753                 }
754         }
755         /**
756          * This event is generated when a payment has been successfully forwarded through us and a
757          * forwarding fee earned.
758          */
759         public final static class PaymentForwarded extends Event {
760                 /**
761                  * The incoming channel between the previous node and us. This is only `None` for events
762                  * generated or serialized by versions prior to 0.0.107.
763                 */
764                 public final org.ldk.structs.Option_ThirtyTwoBytesZ prev_channel_id;
765                 /**
766                  * The outgoing channel between the next node and us. This is only `None` for events
767                  * generated or serialized by versions prior to 0.0.107.
768                 */
769                 public final org.ldk.structs.Option_ThirtyTwoBytesZ next_channel_id;
770                 /**
771                  * The fee, in milli-satoshis, which was earned as a result of the payment.
772                  * 
773                  * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
774                  * was pending, the amount the next hop claimed will have been rounded down to the nearest
775                  * whole satoshi. Thus, the fee calculated here may be higher than expected as we still
776                  * claimed the full value in millisatoshis from the source. In this case,
777                  * `claim_from_onchain_tx` will be set.
778                  * 
779                  * If the channel which sent us the payment has been force-closed, we will claim the funds
780                  * via an on-chain transaction. In that case we do not yet know the on-chain transaction
781                  * fees which we will spend and will instead set this to `None`. It is possible duplicate
782                  * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
783                  * `None`.
784                 */
785                 public final org.ldk.structs.Option_u64Z fee_earned_msat;
786                 /**
787                  * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
788                  * transaction.
789                 */
790                 public final boolean claim_from_onchain_tx;
791                 /**
792                  * The final amount forwarded, in milli-satoshis, after the fee is deducted.
793                  * 
794                  * The caveat described above the `fee_earned_msat` field applies here as well.
795                 */
796                 public final org.ldk.structs.Option_u64Z outbound_amount_forwarded_msat;
797                 private PaymentForwarded(long ptr, bindings.LDKEvent.PaymentForwarded obj) {
798                         super(null, ptr);
799                         long prev_channel_id = obj.prev_channel_id;
800                         org.ldk.structs.Option_ThirtyTwoBytesZ prev_channel_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(prev_channel_id);
801                         if (prev_channel_id_hu_conv != null) { prev_channel_id_hu_conv.ptrs_to.add(this); };
802                         this.prev_channel_id = prev_channel_id_hu_conv;
803                         long next_channel_id = obj.next_channel_id;
804                         org.ldk.structs.Option_ThirtyTwoBytesZ next_channel_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(next_channel_id);
805                         if (next_channel_id_hu_conv != null) { next_channel_id_hu_conv.ptrs_to.add(this); };
806                         this.next_channel_id = next_channel_id_hu_conv;
807                         long fee_earned_msat = obj.fee_earned_msat;
808                         org.ldk.structs.Option_u64Z fee_earned_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_earned_msat);
809                         if (fee_earned_msat_hu_conv != null) { fee_earned_msat_hu_conv.ptrs_to.add(this); };
810                         this.fee_earned_msat = fee_earned_msat_hu_conv;
811                         this.claim_from_onchain_tx = obj.claim_from_onchain_tx;
812                         long outbound_amount_forwarded_msat = obj.outbound_amount_forwarded_msat;
813                         org.ldk.structs.Option_u64Z outbound_amount_forwarded_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(outbound_amount_forwarded_msat);
814                         if (outbound_amount_forwarded_msat_hu_conv != null) { outbound_amount_forwarded_msat_hu_conv.ptrs_to.add(this); };
815                         this.outbound_amount_forwarded_msat = outbound_amount_forwarded_msat_hu_conv;
816                 }
817         }
818         /**
819          * Used to indicate that a channel with the given `channel_id` is being opened and pending
820          * confirmation on-chain.
821          * 
822          * This event is emitted when the funding transaction has been signed and is broadcast to the
823          * network. For 0conf channels it will be immediately followed by the corresponding
824          * [`Event::ChannelReady`] event.
825          */
826         public final static class ChannelPending extends Event {
827                 /**
828                  * The `channel_id` of the channel that is pending confirmation.
829                 */
830                 public final byte[] channel_id;
831                 /**
832                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
833                  * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
834                  * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
835                  * `user_channel_id` will be randomized for an inbound channel.
836                  * 
837                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
838                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
839                  * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
840                 */
841                 public final org.ldk.util.UInt128 user_channel_id;
842                 /**
843                  * The `temporary_channel_id` this channel used to be known by during channel establishment.
844                  * 
845                  * Will be `None` for channels created prior to LDK version 0.0.115.
846                 */
847                 public final org.ldk.structs.Option_ThirtyTwoBytesZ former_temporary_channel_id;
848                 /**
849                  * The `node_id` of the channel counterparty.
850                 */
851                 public final byte[] counterparty_node_id;
852                 /**
853                  * The outpoint of the channel's funding transaction.
854                 */
855                 public final org.ldk.structs.OutPoint funding_txo;
856                 private ChannelPending(long ptr, bindings.LDKEvent.ChannelPending obj) {
857                         super(null, ptr);
858                         this.channel_id = obj.channel_id;
859                         byte[] user_channel_id = obj.user_channel_id;
860                         org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
861                         this.user_channel_id = user_channel_id_conv;
862                         long former_temporary_channel_id = obj.former_temporary_channel_id;
863                         org.ldk.structs.Option_ThirtyTwoBytesZ former_temporary_channel_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(former_temporary_channel_id);
864                         if (former_temporary_channel_id_hu_conv != null) { former_temporary_channel_id_hu_conv.ptrs_to.add(this); };
865                         this.former_temporary_channel_id = former_temporary_channel_id_hu_conv;
866                         this.counterparty_node_id = obj.counterparty_node_id;
867                         long funding_txo = obj.funding_txo;
868                         org.ldk.structs.OutPoint funding_txo_hu_conv = null; if (funding_txo < 0 || funding_txo > 4096) { funding_txo_hu_conv = new org.ldk.structs.OutPoint(null, funding_txo); }
869                         if (funding_txo_hu_conv != null) { funding_txo_hu_conv.ptrs_to.add(this); };
870                         this.funding_txo = funding_txo_hu_conv;
871                 }
872         }
873         /**
874          * Used to indicate that a channel with the given `channel_id` is ready to
875          * be used. This event is emitted either when the funding transaction has been confirmed
876          * on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel
877          * establishment.
878          */
879         public final static class ChannelReady extends Event {
880                 /**
881                  * The `channel_id` of the channel that is ready.
882                 */
883                 public final byte[] channel_id;
884                 /**
885                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
886                  * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
887                  * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
888                  * `user_channel_id` will be randomized for an inbound channel.
889                  * 
890                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
891                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
892                  * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
893                 */
894                 public final org.ldk.util.UInt128 user_channel_id;
895                 /**
896                  * The `node_id` of the channel counterparty.
897                 */
898                 public final byte[] counterparty_node_id;
899                 /**
900                  * The features that this channel will operate with.
901                 */
902                 public final org.ldk.structs.ChannelTypeFeatures channel_type;
903                 private ChannelReady(long ptr, bindings.LDKEvent.ChannelReady obj) {
904                         super(null, ptr);
905                         this.channel_id = obj.channel_id;
906                         byte[] user_channel_id = obj.user_channel_id;
907                         org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
908                         this.user_channel_id = user_channel_id_conv;
909                         this.counterparty_node_id = obj.counterparty_node_id;
910                         long channel_type = obj.channel_type;
911                         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); }
912                         if (channel_type_hu_conv != null) { channel_type_hu_conv.ptrs_to.add(this); };
913                         this.channel_type = channel_type_hu_conv;
914                 }
915         }
916         /**
917          * Used to indicate that a previously opened channel with the given `channel_id` is in the
918          * process of closure.
919          * 
920          * Note that this event is only triggered for accepted channels: if the
921          * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true and the channel is
922          * rejected, no `ChannelClosed` event will be sent.
923          * 
924          * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
925          * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
926          */
927         public final static class ChannelClosed extends Event {
928                 /**
929                  * The `channel_id` of the channel which has been closed. Note that on-chain transactions
930                  * resolving the channel are likely still awaiting confirmation.
931                 */
932                 public final byte[] channel_id;
933                 /**
934                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
935                  * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
936                  * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
937                  * `user_channel_id` will be randomized for inbound channels.
938                  * This may be zero for inbound channels serialized prior to 0.0.113 and will always be
939                  * zero for objects serialized with LDK versions prior to 0.0.102.
940                  * 
941                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
942                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
943                  * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
944                 */
945                 public final org.ldk.util.UInt128 user_channel_id;
946                 /**
947                  * The reason the channel was closed.
948                 */
949                 public final org.ldk.structs.ClosureReason reason;
950                 /**
951                  * Counterparty in the closed channel.
952                  * 
953                  * This field will be `None` for objects serialized prior to LDK 0.0.117.
954                  * 
955                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
956                 */
957                 @Nullable public final byte[] counterparty_node_id;
958                 /**
959                  * Channel capacity of the closing channel (sats).
960                  * 
961                  * This field will be `None` for objects serialized prior to LDK 0.0.117.
962                 */
963                 public final org.ldk.structs.Option_u64Z channel_capacity_sats;
964                 private ChannelClosed(long ptr, bindings.LDKEvent.ChannelClosed obj) {
965                         super(null, ptr);
966                         this.channel_id = obj.channel_id;
967                         byte[] user_channel_id = obj.user_channel_id;
968                         org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
969                         this.user_channel_id = user_channel_id_conv;
970                         long reason = obj.reason;
971                         org.ldk.structs.ClosureReason reason_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(reason);
972                         if (reason_hu_conv != null) { reason_hu_conv.ptrs_to.add(this); };
973                         this.reason = reason_hu_conv;
974                         this.counterparty_node_id = obj.counterparty_node_id;
975                         long channel_capacity_sats = obj.channel_capacity_sats;
976                         org.ldk.structs.Option_u64Z channel_capacity_sats_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(channel_capacity_sats);
977                         if (channel_capacity_sats_hu_conv != null) { channel_capacity_sats_hu_conv.ptrs_to.add(this); };
978                         this.channel_capacity_sats = channel_capacity_sats_hu_conv;
979                 }
980         }
981         /**
982          * Used to indicate to the user that they can abandon the funding transaction and recycle the
983          * inputs for another purpose.
984          * 
985          * This event is not guaranteed to be generated for channels that are closed due to a restart.
986          */
987         public final static class DiscardFunding extends Event {
988                 /**
989                  * The channel_id of the channel which has been closed.
990                 */
991                 public final byte[] channel_id;
992                 /**
993                  * The full transaction received from the user
994                 */
995                 public final byte[] transaction;
996                 private DiscardFunding(long ptr, bindings.LDKEvent.DiscardFunding obj) {
997                         super(null, ptr);
998                         this.channel_id = obj.channel_id;
999                         this.transaction = obj.transaction;
1000                 }
1001         }
1002         /**
1003          * Indicates a request to open a new channel by a peer.
1004          * 
1005          * To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the request,
1006          * call [`ChannelManager::force_close_without_broadcasting_txn`]. Note that a ['ChannelClosed`]
1007          * event will _not_ be triggered if the channel is rejected.
1008          * 
1009          * The event is only triggered when a new open channel request is received and the
1010          * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
1011          * 
1012          * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1013          * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
1014          * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1015          */
1016         public final static class OpenChannelRequest extends Event {
1017                 /**
1018                  * The temporary channel ID of the channel requested to be opened.
1019                  * 
1020                  * When responding to the request, the `temporary_channel_id` should be passed
1021                  * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
1022                  * or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
1023                  * 
1024                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1025                  * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
1026                 */
1027                 public final byte[] temporary_channel_id;
1028                 /**
1029                  * The node_id of the counterparty requesting to open the channel.
1030                  * 
1031                  * When responding to the request, the `counterparty_node_id` should be passed
1032                  * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
1033                  * accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
1034                  * request.
1035                  * 
1036                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1037                  * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
1038                 */
1039                 public final byte[] counterparty_node_id;
1040                 /**
1041                  * The channel value of the requested channel.
1042                 */
1043                 public final long funding_satoshis;
1044                 /**
1045                  * Our starting balance in the channel if the request is accepted, in milli-satoshi.
1046                 */
1047                 public final long push_msat;
1048                 /**
1049                  * The features that this channel will operate with. If you reject the channel, a
1050                  * well-behaved counterparty may automatically re-attempt the channel with a new set of
1051                  * feature flags.
1052                  * 
1053                  * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
1054                  * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
1055                  * 0.0.106.
1056                  * 
1057                  * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
1058                  * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
1059                  * 0.0.107. Channels setting this type also need to get manually accepted via
1060                  * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`],
1061                  * or will be rejected otherwise.
1062                  * 
1063                  * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1064                 */
1065                 public final org.ldk.structs.ChannelTypeFeatures channel_type;
1066                 private OpenChannelRequest(long ptr, bindings.LDKEvent.OpenChannelRequest obj) {
1067                         super(null, ptr);
1068                         this.temporary_channel_id = obj.temporary_channel_id;
1069                         this.counterparty_node_id = obj.counterparty_node_id;
1070                         this.funding_satoshis = obj.funding_satoshis;
1071                         this.push_msat = obj.push_msat;
1072                         long channel_type = obj.channel_type;
1073                         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); }
1074                         if (channel_type_hu_conv != null) { channel_type_hu_conv.ptrs_to.add(this); };
1075                         this.channel_type = channel_type_hu_conv;
1076                 }
1077         }
1078         /**
1079          * Indicates that the HTLC was accepted, but could not be processed when or after attempting to
1080          * forward it.
1081          * 
1082          * Some scenarios where this event may be sent include:
1083          * Insufficient capacity in the outbound channel
1084          * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes
1085          * When an unknown SCID is requested for forwarding a payment.
1086          * Expected MPP amount has already been reached
1087          * The HTLC has timed out
1088          * 
1089          * This event, however, does not get generated if an HTLC fails to meet the forwarding
1090          * requirements (i.e. insufficient fees paid, or a CLTV that is too soon).
1091          */
1092         public final static class HTLCHandlingFailed extends Event {
1093                 /**
1094                  * The channel over which the HTLC was received.
1095                 */
1096                 public final byte[] prev_channel_id;
1097                 /**
1098                  * Destination of the HTLC that failed to be processed.
1099                 */
1100                 public final org.ldk.structs.HTLCDestination failed_next_destination;
1101                 private HTLCHandlingFailed(long ptr, bindings.LDKEvent.HTLCHandlingFailed obj) {
1102                         super(null, ptr);
1103                         this.prev_channel_id = obj.prev_channel_id;
1104                         long failed_next_destination = obj.failed_next_destination;
1105                         org.ldk.structs.HTLCDestination failed_next_destination_hu_conv = org.ldk.structs.HTLCDestination.constr_from_ptr(failed_next_destination);
1106                         if (failed_next_destination_hu_conv != null) { failed_next_destination_hu_conv.ptrs_to.add(this); };
1107                         this.failed_next_destination = failed_next_destination_hu_conv;
1108                 }
1109         }
1110         /**
1111          * Indicates that a transaction originating from LDK needs to have its fee bumped. This event
1112          * requires confirmed external funds to be readily available to spend.
1113          * 
1114          * LDK does not currently generate this event unless the
1115          * [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`] config flag is set to true.
1116          * It is limited to the scope of channels with anchor outputs.
1117          * 
1118          * [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`]: crate::util::config::ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx
1119          */
1120         public final static class BumpTransaction extends Event {
1121                 public final org.ldk.structs.BumpTransactionEvent bump_transaction;
1122                 private BumpTransaction(long ptr, bindings.LDKEvent.BumpTransaction obj) {
1123                         super(null, ptr);
1124                         long bump_transaction = obj.bump_transaction;
1125                         org.ldk.structs.BumpTransactionEvent bump_transaction_hu_conv = org.ldk.structs.BumpTransactionEvent.constr_from_ptr(bump_transaction);
1126                         if (bump_transaction_hu_conv != null) { bump_transaction_hu_conv.ptrs_to.add(this); };
1127                         this.bump_transaction = bump_transaction_hu_conv;
1128                 }
1129         }
1130         long clone_ptr() {
1131                 long ret = bindings.Event_clone_ptr(this.ptr);
1132                 Reference.reachabilityFence(this);
1133                 return ret;
1134         }
1135
1136         /**
1137          * Creates a copy of the Event
1138          */
1139         public Event clone() {
1140                 long ret = bindings.Event_clone(this.ptr);
1141                 Reference.reachabilityFence(this);
1142                 if (ret >= 0 && ret <= 4096) { return null; }
1143                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1144                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1145                 return ret_hu_conv;
1146         }
1147
1148         /**
1149          * Utility method to constructs a new FundingGenerationReady-variant Event
1150          */
1151         public static Event funding_generation_ready(byte[] temporary_channel_id, byte[] counterparty_node_id, long channel_value_satoshis, byte[] output_script, org.ldk.util.UInt128 user_channel_id) {
1152                 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.getLEBytes());
1153                 Reference.reachabilityFence(temporary_channel_id);
1154                 Reference.reachabilityFence(counterparty_node_id);
1155                 Reference.reachabilityFence(channel_value_satoshis);
1156                 Reference.reachabilityFence(output_script);
1157                 Reference.reachabilityFence(user_channel_id);
1158                 if (ret >= 0 && ret <= 4096) { return null; }
1159                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1160                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1161                 return ret_hu_conv;
1162         }
1163
1164         /**
1165          * Utility method to constructs a new PaymentClaimable-variant Event
1166          */
1167         public static Event payment_claimable(byte[] receiver_node_id, byte[] payment_hash, org.ldk.structs.RecipientOnionFields onion_fields, long amount_msat, long counterparty_skimmed_fee_msat, org.ldk.structs.PaymentPurpose purpose, org.ldk.structs.Option_ThirtyTwoBytesZ via_channel_id, org.ldk.structs.Option_U128Z via_user_channel_id, org.ldk.structs.Option_u32Z claim_deadline) {
1168                 long ret = bindings.Event_payment_claimable(InternalUtils.check_arr_len(receiver_node_id, 33), InternalUtils.check_arr_len(payment_hash, 32), onion_fields == null ? 0 : onion_fields.ptr, amount_msat, counterparty_skimmed_fee_msat, purpose.ptr, via_channel_id.ptr, via_user_channel_id.ptr, claim_deadline.ptr);
1169                 Reference.reachabilityFence(receiver_node_id);
1170                 Reference.reachabilityFence(payment_hash);
1171                 Reference.reachabilityFence(onion_fields);
1172                 Reference.reachabilityFence(amount_msat);
1173                 Reference.reachabilityFence(counterparty_skimmed_fee_msat);
1174                 Reference.reachabilityFence(purpose);
1175                 Reference.reachabilityFence(via_channel_id);
1176                 Reference.reachabilityFence(via_user_channel_id);
1177                 Reference.reachabilityFence(claim_deadline);
1178                 if (ret >= 0 && ret <= 4096) { return null; }
1179                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1181                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(onion_fields); };
1182                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(purpose); };
1183                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(via_channel_id); };
1184                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(via_user_channel_id); };
1185                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(claim_deadline); };
1186                 return ret_hu_conv;
1187         }
1188
1189         /**
1190          * Utility method to constructs a new PaymentClaimed-variant Event
1191          */
1192         public static Event payment_claimed(byte[] receiver_node_id, byte[] payment_hash, long amount_msat, org.ldk.structs.PaymentPurpose purpose, ClaimedHTLC[] htlcs, org.ldk.structs.Option_u64Z sender_intended_total_msat) {
1193                 long ret = bindings.Event_payment_claimed(InternalUtils.check_arr_len(receiver_node_id, 33), InternalUtils.check_arr_len(payment_hash, 32), amount_msat, purpose.ptr, htlcs != null ? Arrays.stream(htlcs).mapToLong(htlcs_conv_13 -> htlcs_conv_13 == null ? 0 : htlcs_conv_13.ptr).toArray() : null, sender_intended_total_msat.ptr);
1194                 Reference.reachabilityFence(receiver_node_id);
1195                 Reference.reachabilityFence(payment_hash);
1196                 Reference.reachabilityFence(amount_msat);
1197                 Reference.reachabilityFence(purpose);
1198                 Reference.reachabilityFence(htlcs);
1199                 Reference.reachabilityFence(sender_intended_total_msat);
1200                 if (ret >= 0 && ret <= 4096) { return null; }
1201                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1202                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1203                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(purpose); };
1204                 for (ClaimedHTLC htlcs_conv_13: htlcs) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(htlcs_conv_13); }; };
1205                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(sender_intended_total_msat); };
1206                 return ret_hu_conv;
1207         }
1208
1209         /**
1210          * Utility method to constructs a new PaymentSent-variant Event
1211          */
1212         public static Event payment_sent(org.ldk.structs.Option_ThirtyTwoBytesZ payment_id, byte[] payment_preimage, byte[] payment_hash, org.ldk.structs.Option_u64Z fee_paid_msat) {
1213                 long ret = bindings.Event_payment_sent(payment_id.ptr, InternalUtils.check_arr_len(payment_preimage, 32), InternalUtils.check_arr_len(payment_hash, 32), fee_paid_msat.ptr);
1214                 Reference.reachabilityFence(payment_id);
1215                 Reference.reachabilityFence(payment_preimage);
1216                 Reference.reachabilityFence(payment_hash);
1217                 Reference.reachabilityFence(fee_paid_msat);
1218                 if (ret >= 0 && ret <= 4096) { return null; }
1219                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1220                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1221                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_id); };
1222                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_paid_msat); };
1223                 return ret_hu_conv;
1224         }
1225
1226         /**
1227          * Utility method to constructs a new PaymentFailed-variant Event
1228          */
1229         public static Event payment_failed(byte[] payment_id, byte[] payment_hash, org.ldk.structs.Option_PaymentFailureReasonZ reason) {
1230                 long ret = bindings.Event_payment_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), reason.ptr);
1231                 Reference.reachabilityFence(payment_id);
1232                 Reference.reachabilityFence(payment_hash);
1233                 Reference.reachabilityFence(reason);
1234                 if (ret >= 0 && ret <= 4096) { return null; }
1235                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1236                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1237                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(reason); };
1238                 return ret_hu_conv;
1239         }
1240
1241         /**
1242          * Utility method to constructs a new PaymentPathSuccessful-variant Event
1243          */
1244         public static Event payment_path_successful(byte[] payment_id, org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash, org.ldk.structs.Path path) {
1245                 long ret = bindings.Event_payment_path_successful(InternalUtils.check_arr_len(payment_id, 32), payment_hash.ptr, path == null ? 0 : path.ptr);
1246                 Reference.reachabilityFence(payment_id);
1247                 Reference.reachabilityFence(payment_hash);
1248                 Reference.reachabilityFence(path);
1249                 if (ret >= 0 && ret <= 4096) { return null; }
1250                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1251                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1252                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
1253                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); };
1254                 return ret_hu_conv;
1255         }
1256
1257         /**
1258          * Utility method to constructs a new PaymentPathFailed-variant Event
1259          */
1260         public static Event payment_path_failed(org.ldk.structs.Option_ThirtyTwoBytesZ payment_id, byte[] payment_hash, boolean payment_failed_permanently, org.ldk.structs.PathFailure failure, org.ldk.structs.Path path, org.ldk.structs.Option_u64Z short_channel_id) {
1261                 long ret = bindings.Event_payment_path_failed(payment_id.ptr, InternalUtils.check_arr_len(payment_hash, 32), payment_failed_permanently, failure.ptr, path == null ? 0 : path.ptr, short_channel_id.ptr);
1262                 Reference.reachabilityFence(payment_id);
1263                 Reference.reachabilityFence(payment_hash);
1264                 Reference.reachabilityFence(payment_failed_permanently);
1265                 Reference.reachabilityFence(failure);
1266                 Reference.reachabilityFence(path);
1267                 Reference.reachabilityFence(short_channel_id);
1268                 if (ret >= 0 && ret <= 4096) { return null; }
1269                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1270                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1271                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_id); };
1272                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(failure); };
1273                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); };
1274                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(short_channel_id); };
1275                 return ret_hu_conv;
1276         }
1277
1278         /**
1279          * Utility method to constructs a new ProbeSuccessful-variant Event
1280          */
1281         public static Event probe_successful(byte[] payment_id, byte[] payment_hash, org.ldk.structs.Path path) {
1282                 long ret = bindings.Event_probe_successful(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path == null ? 0 : path.ptr);
1283                 Reference.reachabilityFence(payment_id);
1284                 Reference.reachabilityFence(payment_hash);
1285                 Reference.reachabilityFence(path);
1286                 if (ret >= 0 && ret <= 4096) { return null; }
1287                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1288                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1289                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); };
1290                 return ret_hu_conv;
1291         }
1292
1293         /**
1294          * Utility method to constructs a new ProbeFailed-variant Event
1295          */
1296         public static Event probe_failed(byte[] payment_id, byte[] payment_hash, org.ldk.structs.Path path, org.ldk.structs.Option_u64Z short_channel_id) {
1297                 long ret = bindings.Event_probe_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path == null ? 0 : path.ptr, short_channel_id.ptr);
1298                 Reference.reachabilityFence(payment_id);
1299                 Reference.reachabilityFence(payment_hash);
1300                 Reference.reachabilityFence(path);
1301                 Reference.reachabilityFence(short_channel_id);
1302                 if (ret >= 0 && ret <= 4096) { return null; }
1303                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1304                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1305                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); };
1306                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(short_channel_id); };
1307                 return ret_hu_conv;
1308         }
1309
1310         /**
1311          * Utility method to constructs a new PendingHTLCsForwardable-variant Event
1312          */
1313         public static Event pending_htlcs_forwardable(long time_forwardable) {
1314                 long ret = bindings.Event_pending_htlcs_forwardable(time_forwardable);
1315                 Reference.reachabilityFence(time_forwardable);
1316                 if (ret >= 0 && ret <= 4096) { return null; }
1317                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1318                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1319                 return ret_hu_conv;
1320         }
1321
1322         /**
1323          * Utility method to constructs a new HTLCIntercepted-variant Event
1324          */
1325         public static Event htlcintercepted(byte[] intercept_id, long requested_next_hop_scid, byte[] payment_hash, long inbound_amount_msat, long expected_outbound_amount_msat) {
1326                 long ret = bindings.Event_htlcintercepted(InternalUtils.check_arr_len(intercept_id, 32), requested_next_hop_scid, InternalUtils.check_arr_len(payment_hash, 32), inbound_amount_msat, expected_outbound_amount_msat);
1327                 Reference.reachabilityFence(intercept_id);
1328                 Reference.reachabilityFence(requested_next_hop_scid);
1329                 Reference.reachabilityFence(payment_hash);
1330                 Reference.reachabilityFence(inbound_amount_msat);
1331                 Reference.reachabilityFence(expected_outbound_amount_msat);
1332                 if (ret >= 0 && ret <= 4096) { return null; }
1333                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1334                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1335                 return ret_hu_conv;
1336         }
1337
1338         /**
1339          * Utility method to constructs a new SpendableOutputs-variant Event
1340          */
1341         public static Event spendable_outputs(SpendableOutputDescriptor[] outputs, org.ldk.structs.Option_ThirtyTwoBytesZ channel_id) {
1342                 long ret = bindings.Event_spendable_outputs(outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_27 -> outputs_conv_27.ptr).toArray() : null, channel_id.ptr);
1343                 Reference.reachabilityFence(outputs);
1344                 Reference.reachabilityFence(channel_id);
1345                 if (ret >= 0 && ret <= 4096) { return null; }
1346                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1347                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1348                 for (SpendableOutputDescriptor outputs_conv_27: outputs) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outputs_conv_27); }; };
1349                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id); };
1350                 return ret_hu_conv;
1351         }
1352
1353         /**
1354          * Utility method to constructs a new PaymentForwarded-variant Event
1355          */
1356         public static Event payment_forwarded(org.ldk.structs.Option_ThirtyTwoBytesZ prev_channel_id, org.ldk.structs.Option_ThirtyTwoBytesZ next_channel_id, org.ldk.structs.Option_u64Z fee_earned_msat, boolean claim_from_onchain_tx, org.ldk.structs.Option_u64Z outbound_amount_forwarded_msat) {
1357                 long ret = bindings.Event_payment_forwarded(prev_channel_id.ptr, next_channel_id.ptr, fee_earned_msat.ptr, claim_from_onchain_tx, outbound_amount_forwarded_msat.ptr);
1358                 Reference.reachabilityFence(prev_channel_id);
1359                 Reference.reachabilityFence(next_channel_id);
1360                 Reference.reachabilityFence(fee_earned_msat);
1361                 Reference.reachabilityFence(claim_from_onchain_tx);
1362                 Reference.reachabilityFence(outbound_amount_forwarded_msat);
1363                 if (ret >= 0 && ret <= 4096) { return null; }
1364                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1365                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1366                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(prev_channel_id); };
1367                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(next_channel_id); };
1368                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_earned_msat); };
1369                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outbound_amount_forwarded_msat); };
1370                 return ret_hu_conv;
1371         }
1372
1373         /**
1374          * Utility method to constructs a new ChannelPending-variant Event
1375          */
1376         public static Event channel_pending(byte[] channel_id, org.ldk.util.UInt128 user_channel_id, org.ldk.structs.Option_ThirtyTwoBytesZ former_temporary_channel_id, byte[] counterparty_node_id, org.ldk.structs.OutPoint funding_txo) {
1377                 long ret = bindings.Event_channel_pending(InternalUtils.check_arr_len(channel_id, 32), user_channel_id.getLEBytes(), former_temporary_channel_id.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), funding_txo == null ? 0 : funding_txo.ptr);
1378                 Reference.reachabilityFence(channel_id);
1379                 Reference.reachabilityFence(user_channel_id);
1380                 Reference.reachabilityFence(former_temporary_channel_id);
1381                 Reference.reachabilityFence(counterparty_node_id);
1382                 Reference.reachabilityFence(funding_txo);
1383                 if (ret >= 0 && ret <= 4096) { return null; }
1384                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1385                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1386                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(former_temporary_channel_id); };
1387                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(funding_txo); };
1388                 return ret_hu_conv;
1389         }
1390
1391         /**
1392          * Utility method to constructs a new ChannelReady-variant Event
1393          */
1394         public static Event channel_ready(byte[] channel_id, org.ldk.util.UInt128 user_channel_id, byte[] counterparty_node_id, org.ldk.structs.ChannelTypeFeatures channel_type) {
1395                 long ret = bindings.Event_channel_ready(InternalUtils.check_arr_len(channel_id, 32), user_channel_id.getLEBytes(), InternalUtils.check_arr_len(counterparty_node_id, 33), channel_type == null ? 0 : channel_type.ptr);
1396                 Reference.reachabilityFence(channel_id);
1397                 Reference.reachabilityFence(user_channel_id);
1398                 Reference.reachabilityFence(counterparty_node_id);
1399                 Reference.reachabilityFence(channel_type);
1400                 if (ret >= 0 && ret <= 4096) { return null; }
1401                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1402                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1403                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type); };
1404                 return ret_hu_conv;
1405         }
1406
1407         /**
1408          * Utility method to constructs a new ChannelClosed-variant Event
1409          */
1410         public static Event channel_closed(byte[] channel_id, org.ldk.util.UInt128 user_channel_id, org.ldk.structs.ClosureReason reason, byte[] counterparty_node_id, org.ldk.structs.Option_u64Z channel_capacity_sats) {
1411                 long ret = bindings.Event_channel_closed(InternalUtils.check_arr_len(channel_id, 32), user_channel_id.getLEBytes(), reason.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), channel_capacity_sats.ptr);
1412                 Reference.reachabilityFence(channel_id);
1413                 Reference.reachabilityFence(user_channel_id);
1414                 Reference.reachabilityFence(reason);
1415                 Reference.reachabilityFence(counterparty_node_id);
1416                 Reference.reachabilityFence(channel_capacity_sats);
1417                 if (ret >= 0 && ret <= 4096) { return null; }
1418                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1419                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1420                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(reason); };
1421                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_capacity_sats); };
1422                 return ret_hu_conv;
1423         }
1424
1425         /**
1426          * Utility method to constructs a new DiscardFunding-variant Event
1427          */
1428         public static Event discard_funding(byte[] channel_id, byte[] transaction) {
1429                 long ret = bindings.Event_discard_funding(InternalUtils.check_arr_len(channel_id, 32), transaction);
1430                 Reference.reachabilityFence(channel_id);
1431                 Reference.reachabilityFence(transaction);
1432                 if (ret >= 0 && ret <= 4096) { return null; }
1433                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1434                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1435                 return ret_hu_conv;
1436         }
1437
1438         /**
1439          * Utility method to constructs a new OpenChannelRequest-variant Event
1440          */
1441         public static Event open_channel_request(byte[] temporary_channel_id, byte[] counterparty_node_id, long funding_satoshis, long push_msat, org.ldk.structs.ChannelTypeFeatures channel_type) {
1442                 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);
1443                 Reference.reachabilityFence(temporary_channel_id);
1444                 Reference.reachabilityFence(counterparty_node_id);
1445                 Reference.reachabilityFence(funding_satoshis);
1446                 Reference.reachabilityFence(push_msat);
1447                 Reference.reachabilityFence(channel_type);
1448                 if (ret >= 0 && ret <= 4096) { return null; }
1449                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1450                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1451                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type); };
1452                 return ret_hu_conv;
1453         }
1454
1455         /**
1456          * Utility method to constructs a new HTLCHandlingFailed-variant Event
1457          */
1458         public static Event htlchandling_failed(byte[] prev_channel_id, org.ldk.structs.HTLCDestination failed_next_destination) {
1459                 long ret = bindings.Event_htlchandling_failed(InternalUtils.check_arr_len(prev_channel_id, 32), failed_next_destination.ptr);
1460                 Reference.reachabilityFence(prev_channel_id);
1461                 Reference.reachabilityFence(failed_next_destination);
1462                 if (ret >= 0 && ret <= 4096) { return null; }
1463                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1464                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1465                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(failed_next_destination); };
1466                 return ret_hu_conv;
1467         }
1468
1469         /**
1470          * Utility method to constructs a new BumpTransaction-variant Event
1471          */
1472         public static Event bump_transaction(org.ldk.structs.BumpTransactionEvent a) {
1473                 long ret = bindings.Event_bump_transaction(a.ptr);
1474                 Reference.reachabilityFence(a);
1475                 if (ret >= 0 && ret <= 4096) { return null; }
1476                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1477                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1478                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
1479                 return ret_hu_conv;
1480         }
1481
1482         /**
1483          * Checks if two Events contain equal inner contents.
1484          * This ignores pointers and is_owned flags and looks at the values in fields.
1485          */
1486         public boolean eq(org.ldk.structs.Event b) {
1487                 boolean ret = bindings.Event_eq(this.ptr, b == null ? 0 : b.ptr);
1488                 Reference.reachabilityFence(this);
1489                 Reference.reachabilityFence(b);
1490                 return ret;
1491         }
1492
1493         @Override public boolean equals(Object o) {
1494                 if (!(o instanceof Event)) return false;
1495                 return this.eq((Event)o);
1496         }
1497         /**
1498          * Serialize the Event object into a byte array which can be read by Event_read
1499          */
1500         public byte[] write() {
1501                 byte[] ret = bindings.Event_write(this.ptr);
1502                 Reference.reachabilityFence(this);
1503                 return ret;
1504         }
1505
1506 }