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