805b57eb28d477897cd5256d06afcc657f11b00f
[ldk-java] / c_sharp / src / org / ldk / structs / Event.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 /**
9  * An Event which you should probably take some action in response to.
10  * 
11  * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
12  * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
13  * written as it makes no sense to respond to it after reconnecting to peers).
14  */
15 public class Event : CommonBase {
16         protected Event(object _dummy, long ptr) : base(ptr) { }
17         ~Event() {
18                 if (ptr != 0) { bindings.Event_free(ptr); }
19         }
20
21         internal static Event constr_from_ptr(long ptr) {
22                 long raw_ty = bindings.LDKEvent_ty_from_ptr(ptr);
23                 switch (raw_ty) {
24                         case 0: return new Event_FundingGenerationReady(ptr);
25                         case 1: return new Event_PaymentClaimable(ptr);
26                         case 2: return new Event_PaymentClaimed(ptr);
27                         case 3: return new Event_InvoiceRequestFailed(ptr);
28                         case 4: return new Event_PaymentSent(ptr);
29                         case 5: return new Event_PaymentFailed(ptr);
30                         case 6: return new Event_PaymentPathSuccessful(ptr);
31                         case 7: return new Event_PaymentPathFailed(ptr);
32                         case 8: return new Event_ProbeSuccessful(ptr);
33                         case 9: return new Event_ProbeFailed(ptr);
34                         case 10: return new Event_PendingHTLCsForwardable(ptr);
35                         case 11: return new Event_HTLCIntercepted(ptr);
36                         case 12: return new Event_SpendableOutputs(ptr);
37                         case 13: return new Event_PaymentForwarded(ptr);
38                         case 14: return new Event_ChannelPending(ptr);
39                         case 15: return new Event_ChannelReady(ptr);
40                         case 16: return new Event_ChannelClosed(ptr);
41                         case 17: return new Event_DiscardFunding(ptr);
42                         case 18: return new Event_OpenChannelRequest(ptr);
43                         case 19: return new Event_HTLCHandlingFailed(ptr);
44                         case 20: return new Event_BumpTransaction(ptr);
45                         default:
46                                 throw new ArgumentException("Impossible enum variant");
47                 }
48         }
49
50         /** A Event of type FundingGenerationReady */
51         public class Event_FundingGenerationReady : Event {
52                 /**
53                  * The random channel_id we picked which you'll need to pass into
54                  * [`ChannelManager::funding_transaction_generated`].
55                  * 
56                  * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
57                  */
58                 public byte[] temporary_channel_id;
59                 /**
60                  * The counterparty's node_id, which you'll need to pass back into
61                  * [`ChannelManager::funding_transaction_generated`].
62                  * 
63                  * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
64                  */
65                 public byte[] counterparty_node_id;
66                 /**
67                  * The value, in satoshis, that the output should have.
68                  */
69                 public long channel_value_satoshis;
70                 /**
71                  * The script which should be used in the transaction output.
72                  */
73                 public byte[] output_script;
74                 /**
75                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
76                  * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
77                  * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
78                  * `user_channel_id` will be randomized for an inbound channel.  This may be zero for objects
79                  * serialized with LDK versions prior to 0.0.113.
80                  * 
81                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
82                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
83                  * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
84                  */
85                 public UInt128 user_channel_id;
86                 internal Event_FundingGenerationReady(long ptr) : base(null, ptr) {
87                         long temporary_channel_id = bindings.LDKEvent_FundingGenerationReady_get_temporary_channel_id(ptr);
88                         byte[] temporary_channel_id_conv = InternalUtils.decodeUint8Array(temporary_channel_id);
89                         this.temporary_channel_id = temporary_channel_id_conv;
90                         long counterparty_node_id = bindings.LDKEvent_FundingGenerationReady_get_counterparty_node_id(ptr);
91                         byte[] counterparty_node_id_conv = InternalUtils.decodeUint8Array(counterparty_node_id);
92                         this.counterparty_node_id = counterparty_node_id_conv;
93                         this.channel_value_satoshis = bindings.LDKEvent_FundingGenerationReady_get_channel_value_satoshis(ptr);
94                         long output_script = bindings.LDKEvent_FundingGenerationReady_get_output_script(ptr);
95                         byte[] output_script_conv = InternalUtils.decodeUint8Array(output_script);
96                         this.output_script = output_script_conv;
97                         long user_channel_id = bindings.LDKEvent_FundingGenerationReady_get_user_channel_id(ptr);
98                         org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
99                         this.user_channel_id = user_channel_id_conv;
100                 }
101         }
102         /** A Event of type PaymentClaimable */
103         public class Event_PaymentClaimable : Event {
104                 /**
105                  * The node that will receive the payment after it has been claimed.
106                  * This is useful to identify payments received via [phantom nodes].
107                  * This field will always be filled in when the event was generated by LDK versions
108                  * 0.0.113 and above.
109                  * 
110                  * [phantom nodes]: crate::sign::PhantomKeysManager
111                  * 
112                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
113                  */
114                 public byte[] receiver_node_id;
115                 /**
116                  * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
117                  * not stop you from registering duplicate payment hashes for inbound payments.
118                  */
119                 public byte[] payment_hash;
120                 /**
121                  * The fields in the onion which were received with each HTLC. Only fields which were
122                  * identical in each HTLC involved in the payment will be included here.
123                  * 
124                  * Payments received on LDK versions prior to 0.0.115 will have this field unset.
125                  * 
126                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
127                  */
128                 public RecipientOnionFields onion_fields;
129                 /**
130                  * The value, in thousandths of a satoshi, that this payment is claimable for. May be greater
131                  * than the invoice amount.
132                  * 
133                  * May be less than the invoice amount if [`ChannelConfig::accept_underpaying_htlcs`] is set
134                  * and the previous hop took an extra fee.
135                  * 
136                  * # Note
137                  * If [`ChannelConfig::accept_underpaying_htlcs`] is set and you claim without verifying this
138                  * field, you may lose money!
139                  * 
140                  * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
141                  */
142                 public long amount_msat;
143                 /**
144                  * The value, in thousands of a satoshi, that was skimmed off of this payment as an extra fee
145                  * taken by our channel counterparty.
146                  * 
147                  * Will always be 0 unless [`ChannelConfig::accept_underpaying_htlcs`] is set.
148                  * 
149                  * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
150                  */
151                 public long counterparty_skimmed_fee_msat;
152                 /**
153                  * Information for claiming this received payment, based on whether the purpose of the
154                  * payment is to pay an invoice or to send a spontaneous payment.
155                  */
156                 public PaymentPurpose purpose;
157                 /**
158                  * The `channel_id` indicating over which channel we received the payment.
159                  */
160                 public Option_ThirtyTwoBytesZ via_channel_id;
161                 /**
162                  * The `user_channel_id` indicating over which channel we received the payment.
163                  */
164                 public Option_U128Z via_user_channel_id;
165                 /**
166                  * The block height at which this payment will be failed back and will no longer be
167                  * eligible for claiming.
168                  * 
169                  * Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to
170                  * succeed, however you should wait for [`Event::PaymentClaimed`] to be sure.
171                  * 
172                  * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
173                  */
174                 public Option_u32Z claim_deadline;
175                 internal Event_PaymentClaimable(long ptr) : base(null, ptr) {
176                         long receiver_node_id = bindings.LDKEvent_PaymentClaimable_get_receiver_node_id(ptr);
177                         byte[] receiver_node_id_conv = InternalUtils.decodeUint8Array(receiver_node_id);
178                         this.receiver_node_id = receiver_node_id_conv;
179                         long payment_hash = bindings.LDKEvent_PaymentClaimable_get_payment_hash(ptr);
180                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
181                         this.payment_hash = payment_hash_conv;
182                         long onion_fields = bindings.LDKEvent_PaymentClaimable_get_onion_fields(ptr);
183                         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); }
184                         if (onion_fields_hu_conv != null) { onion_fields_hu_conv.ptrs_to.AddLast(this); };
185                         this.onion_fields = onion_fields_hu_conv;
186                         this.amount_msat = bindings.LDKEvent_PaymentClaimable_get_amount_msat(ptr);
187                         this.counterparty_skimmed_fee_msat = bindings.LDKEvent_PaymentClaimable_get_counterparty_skimmed_fee_msat(ptr);
188                         long purpose = bindings.LDKEvent_PaymentClaimable_get_purpose(ptr);
189                         org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
190                         if (purpose_hu_conv != null) { purpose_hu_conv.ptrs_to.AddLast(this); };
191                         this.purpose = purpose_hu_conv;
192                         long via_channel_id = bindings.LDKEvent_PaymentClaimable_get_via_channel_id(ptr);
193                         org.ldk.structs.Option_ThirtyTwoBytesZ via_channel_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(via_channel_id);
194                         if (via_channel_id_hu_conv != null) { via_channel_id_hu_conv.ptrs_to.AddLast(this); };
195                         this.via_channel_id = via_channel_id_hu_conv;
196                         long via_user_channel_id = bindings.LDKEvent_PaymentClaimable_get_via_user_channel_id(ptr);
197                         org.ldk.structs.Option_U128Z via_user_channel_id_hu_conv = org.ldk.structs.Option_U128Z.constr_from_ptr(via_user_channel_id);
198                         if (via_user_channel_id_hu_conv != null) { via_user_channel_id_hu_conv.ptrs_to.AddLast(this); };
199                         this.via_user_channel_id = via_user_channel_id_hu_conv;
200                         long claim_deadline = bindings.LDKEvent_PaymentClaimable_get_claim_deadline(ptr);
201                         org.ldk.structs.Option_u32Z claim_deadline_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(claim_deadline);
202                         if (claim_deadline_hu_conv != null) { claim_deadline_hu_conv.ptrs_to.AddLast(this); };
203                         this.claim_deadline = claim_deadline_hu_conv;
204                 }
205         }
206         /** A Event of type PaymentClaimed */
207         public class Event_PaymentClaimed : Event {
208                 /**
209                  * The node that received the payment.
210                  * This is useful to identify payments which were received via [phantom nodes].
211                  * This field will always be filled in when the event was generated by LDK versions
212                  * 0.0.113 and above.
213                  * 
214                  * [phantom nodes]: crate::sign::PhantomKeysManager
215                  * 
216                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
217                  */
218                 public byte[] receiver_node_id;
219                 /**
220                  * The payment hash of the claimed payment. Note that LDK will not stop you from
221                  * registering duplicate payment hashes for inbound payments.
222                  */
223                 public byte[] payment_hash;
224                 /**
225                  * The value, in thousandths of a satoshi, that this payment is for. May be greater than the
226                  * invoice amount.
227                  */
228                 public long amount_msat;
229                 /**
230                  * The purpose of the claimed payment, i.e. whether the payment was for an invoice or a
231                  * spontaneous payment.
232                  */
233                 public PaymentPurpose purpose;
234                 /**
235                  * The HTLCs that comprise the claimed payment. This will be empty for events serialized prior
236                  * to LDK version 0.0.117.
237                  */
238                 public ClaimedHTLC[] htlcs;
239                 /**
240                  * The sender-intended sum total of all the MPP parts. This will be `None` for events
241                  * serialized prior to LDK version 0.0.117.
242                  */
243                 public Option_u64Z sender_intended_total_msat;
244                 internal Event_PaymentClaimed(long ptr) : base(null, ptr) {
245                         long receiver_node_id = bindings.LDKEvent_PaymentClaimed_get_receiver_node_id(ptr);
246                         byte[] receiver_node_id_conv = InternalUtils.decodeUint8Array(receiver_node_id);
247                         this.receiver_node_id = receiver_node_id_conv;
248                         long payment_hash = bindings.LDKEvent_PaymentClaimed_get_payment_hash(ptr);
249                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
250                         this.payment_hash = payment_hash_conv;
251                         this.amount_msat = bindings.LDKEvent_PaymentClaimed_get_amount_msat(ptr);
252                         long purpose = bindings.LDKEvent_PaymentClaimed_get_purpose(ptr);
253                         org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
254                         if (purpose_hu_conv != null) { purpose_hu_conv.ptrs_to.AddLast(this); };
255                         this.purpose = purpose_hu_conv;
256                         long htlcs = bindings.LDKEvent_PaymentClaimed_get_htlcs(ptr);
257                         int htlcs_conv_13_len = InternalUtils.getArrayLength(htlcs);
258                         ClaimedHTLC[] htlcs_conv_13_arr = new ClaimedHTLC[htlcs_conv_13_len];
259                         for (int n = 0; n < htlcs_conv_13_len; n++) {
260                                 long htlcs_conv_13 = InternalUtils.getU64ArrayElem(htlcs, n);
261                                 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); }
262                                 if (htlcs_conv_13_hu_conv != null) { htlcs_conv_13_hu_conv.ptrs_to.AddLast(this); };
263                                 htlcs_conv_13_arr[n] = htlcs_conv_13_hu_conv;
264                         }
265                         bindings.free_buffer(htlcs);
266                         this.htlcs = htlcs_conv_13_arr;
267                         long sender_intended_total_msat = bindings.LDKEvent_PaymentClaimed_get_sender_intended_total_msat(ptr);
268                         org.ldk.structs.Option_u64Z sender_intended_total_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(sender_intended_total_msat);
269                         if (sender_intended_total_msat_hu_conv != null) { sender_intended_total_msat_hu_conv.ptrs_to.AddLast(this); };
270                         this.sender_intended_total_msat = sender_intended_total_msat_hu_conv;
271                 }
272         }
273         /** A Event of type InvoiceRequestFailed */
274         public class Event_InvoiceRequestFailed : Event {
275                 /**
276                  * The `payment_id` to have been associated with payment for the requested invoice.
277                  */
278                 public byte[] payment_id;
279                 internal Event_InvoiceRequestFailed(long ptr) : base(null, ptr) {
280                         long payment_id = bindings.LDKEvent_InvoiceRequestFailed_get_payment_id(ptr);
281                         byte[] payment_id_conv = InternalUtils.decodeUint8Array(payment_id);
282                         this.payment_id = payment_id_conv;
283                 }
284         }
285         /** A Event of type PaymentSent */
286         public class Event_PaymentSent : Event {
287                 /**
288                  * The `payment_id` passed to [`ChannelManager::send_payment`].
289                  * 
290                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
291                  */
292                 public Option_ThirtyTwoBytesZ payment_id;
293                 /**
294                  * The preimage to the hash given to ChannelManager::send_payment.
295                  * Note that this serves as a payment receipt, if you wish to have such a thing, you must
296                  * store it somehow!
297                  */
298                 public byte[] payment_preimage;
299                 /**
300                  * The hash that was given to [`ChannelManager::send_payment`].
301                  * 
302                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
303                  */
304                 public byte[] payment_hash;
305                 /**
306                  * The total fee which was spent at intermediate hops in this payment, across all paths.
307                  * 
308                  * Note that, like [`Route::get_total_fees`] this does *not* include any potential
309                  * overpayment to the recipient node.
310                  * 
311                  * If the recipient or an intermediate node misbehaves and gives us free money, this may
312                  * overstate the amount paid, though this is unlikely.
313                  * 
314                  * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
315                  */
316                 public Option_u64Z fee_paid_msat;
317                 internal Event_PaymentSent(long ptr) : base(null, ptr) {
318                         long payment_id = bindings.LDKEvent_PaymentSent_get_payment_id(ptr);
319                         org.ldk.structs.Option_ThirtyTwoBytesZ payment_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(payment_id);
320                         if (payment_id_hu_conv != null) { payment_id_hu_conv.ptrs_to.AddLast(this); };
321                         this.payment_id = payment_id_hu_conv;
322                         long payment_preimage = bindings.LDKEvent_PaymentSent_get_payment_preimage(ptr);
323                         byte[] payment_preimage_conv = InternalUtils.decodeUint8Array(payment_preimage);
324                         this.payment_preimage = payment_preimage_conv;
325                         long payment_hash = bindings.LDKEvent_PaymentSent_get_payment_hash(ptr);
326                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
327                         this.payment_hash = payment_hash_conv;
328                         long fee_paid_msat = bindings.LDKEvent_PaymentSent_get_fee_paid_msat(ptr);
329                         org.ldk.structs.Option_u64Z fee_paid_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_paid_msat);
330                         if (fee_paid_msat_hu_conv != null) { fee_paid_msat_hu_conv.ptrs_to.AddLast(this); };
331                         this.fee_paid_msat = fee_paid_msat_hu_conv;
332                 }
333         }
334         /** A Event of type PaymentFailed */
335         public class Event_PaymentFailed : Event {
336                 /**
337                  * The `payment_id` passed to [`ChannelManager::send_payment`].
338                  * 
339                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
340                  */
341                 public byte[] payment_id;
342                 /**
343                  * The hash that was given to [`ChannelManager::send_payment`].
344                  * 
345                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
346                  */
347                 public byte[] payment_hash;
348                 /**
349                  * The reason the payment failed. This is only `None` for events generated or serialized
350                  * by versions prior to 0.0.115.
351                  */
352                 public Option_PaymentFailureReasonZ reason;
353                 internal Event_PaymentFailed(long ptr) : base(null, ptr) {
354                         long payment_id = bindings.LDKEvent_PaymentFailed_get_payment_id(ptr);
355                         byte[] payment_id_conv = InternalUtils.decodeUint8Array(payment_id);
356                         this.payment_id = payment_id_conv;
357                         long payment_hash = bindings.LDKEvent_PaymentFailed_get_payment_hash(ptr);
358                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
359                         this.payment_hash = payment_hash_conv;
360                         long reason = bindings.LDKEvent_PaymentFailed_get_reason(ptr);
361                         org.ldk.structs.Option_PaymentFailureReasonZ reason_hu_conv = org.ldk.structs.Option_PaymentFailureReasonZ.constr_from_ptr(reason);
362                         if (reason_hu_conv != null) { reason_hu_conv.ptrs_to.AddLast(this); };
363                         this.reason = reason_hu_conv;
364                 }
365         }
366         /** A Event of type PaymentPathSuccessful */
367         public class Event_PaymentPathSuccessful : Event {
368                 /**
369                  * The `payment_id` passed to [`ChannelManager::send_payment`].
370                  * 
371                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
372                  */
373                 public byte[] payment_id;
374                 /**
375                  * The hash that was given to [`ChannelManager::send_payment`].
376                  * 
377                  * This will be `Some` for all payments which completed on LDK 0.0.104 or later.
378                  * 
379                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
380                  */
381                 public Option_ThirtyTwoBytesZ payment_hash;
382                 /**
383                  * The payment path that was successful.
384                  * 
385                  * May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
386                  */
387                 public Path path;
388                 internal Event_PaymentPathSuccessful(long ptr) : base(null, ptr) {
389                         long payment_id = bindings.LDKEvent_PaymentPathSuccessful_get_payment_id(ptr);
390                         byte[] payment_id_conv = InternalUtils.decodeUint8Array(payment_id);
391                         this.payment_id = payment_id_conv;
392                         long payment_hash = bindings.LDKEvent_PaymentPathSuccessful_get_payment_hash(ptr);
393                         org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(payment_hash);
394                         if (payment_hash_hu_conv != null) { payment_hash_hu_conv.ptrs_to.AddLast(this); };
395                         this.payment_hash = payment_hash_hu_conv;
396                         long path = bindings.LDKEvent_PaymentPathSuccessful_get_path(ptr);
397                         org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
398                         if (path_hu_conv != null) { path_hu_conv.ptrs_to.AddLast(this); };
399                         this.path = path_hu_conv;
400                 }
401         }
402         /** A Event of type PaymentPathFailed */
403         public class Event_PaymentPathFailed : Event {
404                 /**
405                  * The `payment_id` passed to [`ChannelManager::send_payment`].
406                  * 
407                  * This will be `Some` for all payment paths which failed on LDK 0.0.103 or later.
408                  * 
409                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
410                  * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
411                  */
412                 public Option_ThirtyTwoBytesZ payment_id;
413                 /**
414                  * The hash that was given to [`ChannelManager::send_payment`].
415                  * 
416                  * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
417                  */
418                 public byte[] payment_hash;
419                 /**
420                  * Indicates the payment was rejected for some reason by the recipient. This implies that
421                  * the payment has failed, not just the route in question. If this is not set, the payment may
422                  * be retried via a different route.
423                  */
424                 public bool payment_failed_permanently;
425                 /**
426                  * Extra error details based on the failure type. May contain an update that needs to be
427                  * applied to the [`NetworkGraph`].
428                  * 
429                  * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
430                  */
431                 public PathFailure failure;
432                 /**
433                  * The payment path that failed.
434                  */
435                 public Path path;
436                 /**
437                  * The channel responsible for the failed payment path.
438                  * 
439                  * Note that for route hints or for the first hop in a path this may be an SCID alias and
440                  * may not refer to a channel in the public network graph. These aliases may also collide
441                  * with channels in the public network graph.
442                  * 
443                  * If this is `Some`, then the corresponding channel should be avoided when the payment is
444                  * retried. May be `None` for older [`Event`] serializations.
445                  */
446                 public Option_u64Z short_channel_id;
447                 internal Event_PaymentPathFailed(long ptr) : base(null, ptr) {
448                         long payment_id = bindings.LDKEvent_PaymentPathFailed_get_payment_id(ptr);
449                         org.ldk.structs.Option_ThirtyTwoBytesZ payment_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(payment_id);
450                         if (payment_id_hu_conv != null) { payment_id_hu_conv.ptrs_to.AddLast(this); };
451                         this.payment_id = payment_id_hu_conv;
452                         long payment_hash = bindings.LDKEvent_PaymentPathFailed_get_payment_hash(ptr);
453                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
454                         this.payment_hash = payment_hash_conv;
455                         this.payment_failed_permanently = bindings.LDKEvent_PaymentPathFailed_get_payment_failed_permanently(ptr);
456                         long failure = bindings.LDKEvent_PaymentPathFailed_get_failure(ptr);
457                         org.ldk.structs.PathFailure failure_hu_conv = org.ldk.structs.PathFailure.constr_from_ptr(failure);
458                         if (failure_hu_conv != null) { failure_hu_conv.ptrs_to.AddLast(this); };
459                         this.failure = failure_hu_conv;
460                         long path = bindings.LDKEvent_PaymentPathFailed_get_path(ptr);
461                         org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
462                         if (path_hu_conv != null) { path_hu_conv.ptrs_to.AddLast(this); };
463                         this.path = path_hu_conv;
464                         long short_channel_id = bindings.LDKEvent_PaymentPathFailed_get_short_channel_id(ptr);
465                         org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id);
466                         if (short_channel_id_hu_conv != null) { short_channel_id_hu_conv.ptrs_to.AddLast(this); };
467                         this.short_channel_id = short_channel_id_hu_conv;
468                 }
469         }
470         /** A Event of type ProbeSuccessful */
471         public class Event_ProbeSuccessful : Event {
472                 /**
473                  * The id returned by [`ChannelManager::send_probe`].
474                  * 
475                  * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
476                  */
477                 public byte[] payment_id;
478                 /**
479                  * The hash generated by [`ChannelManager::send_probe`].
480                  * 
481                  * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
482                  */
483                 public byte[] payment_hash;
484                 /**
485                  * The payment path that was successful.
486                  */
487                 public Path path;
488                 internal Event_ProbeSuccessful(long ptr) : base(null, ptr) {
489                         long payment_id = bindings.LDKEvent_ProbeSuccessful_get_payment_id(ptr);
490                         byte[] payment_id_conv = InternalUtils.decodeUint8Array(payment_id);
491                         this.payment_id = payment_id_conv;
492                         long payment_hash = bindings.LDKEvent_ProbeSuccessful_get_payment_hash(ptr);
493                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
494                         this.payment_hash = payment_hash_conv;
495                         long path = bindings.LDKEvent_ProbeSuccessful_get_path(ptr);
496                         org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
497                         if (path_hu_conv != null) { path_hu_conv.ptrs_to.AddLast(this); };
498                         this.path = path_hu_conv;
499                 }
500         }
501         /** A Event of type ProbeFailed */
502         public class Event_ProbeFailed : Event {
503                 /**
504                  * The id returned by [`ChannelManager::send_probe`].
505                  * 
506                  * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
507                  */
508                 public byte[] payment_id;
509                 /**
510                  * The hash generated by [`ChannelManager::send_probe`].
511                  * 
512                  * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
513                  */
514                 public byte[] payment_hash;
515                 /**
516                  * The payment path that failed.
517                  */
518                 public Path path;
519                 /**
520                  * The channel responsible for the failed probe.
521                  * 
522                  * Note that for route hints or for the first hop in a path this may be an SCID alias and
523                  * may not refer to a channel in the public network graph. These aliases may also collide
524                  * with channels in the public network graph.
525                  */
526                 public Option_u64Z short_channel_id;
527                 internal Event_ProbeFailed(long ptr) : base(null, ptr) {
528                         long payment_id = bindings.LDKEvent_ProbeFailed_get_payment_id(ptr);
529                         byte[] payment_id_conv = InternalUtils.decodeUint8Array(payment_id);
530                         this.payment_id = payment_id_conv;
531                         long payment_hash = bindings.LDKEvent_ProbeFailed_get_payment_hash(ptr);
532                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
533                         this.payment_hash = payment_hash_conv;
534                         long path = bindings.LDKEvent_ProbeFailed_get_path(ptr);
535                         org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
536                         if (path_hu_conv != null) { path_hu_conv.ptrs_to.AddLast(this); };
537                         this.path = path_hu_conv;
538                         long short_channel_id = bindings.LDKEvent_ProbeFailed_get_short_channel_id(ptr);
539                         org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id);
540                         if (short_channel_id_hu_conv != null) { short_channel_id_hu_conv.ptrs_to.AddLast(this); };
541                         this.short_channel_id = short_channel_id_hu_conv;
542                 }
543         }
544         /** A Event of type PendingHTLCsForwardable */
545         public class Event_PendingHTLCsForwardable : Event {
546                 /**
547                  * The minimum amount of time that should be waited prior to calling
548                  * process_pending_htlc_forwards. To increase the effort required to correlate payments,
549                  * you should wait a random amount of time in roughly the range (now + time_forwardable,
550                  * now + 5*time_forwardable).
551                  */
552                 public long time_forwardable;
553                 internal Event_PendingHTLCsForwardable(long ptr) : base(null, ptr) {
554                         this.time_forwardable = bindings.LDKEvent_PendingHTLCsForwardable_get_time_forwardable(ptr);
555                 }
556         }
557         /** A Event of type HTLCIntercepted */
558         public class Event_HTLCIntercepted : Event {
559                 /**
560                  * An id to help LDK identify which HTLC is being forwarded or failed.
561                  */
562                 public byte[] intercept_id;
563                 /**
564                  * The fake scid that was programmed as the next hop's scid, generated using
565                  * [`ChannelManager::get_intercept_scid`].
566                  * 
567                  * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
568                  */
569                 public long requested_next_hop_scid;
570                 /**
571                  * The payment hash used for this HTLC.
572                  */
573                 public byte[] payment_hash;
574                 /**
575                  * How many msats were received on the inbound edge of this HTLC.
576                  */
577                 public long inbound_amount_msat;
578                 /**
579                  * How many msats the payer intended to route to the next node. Depending on the reason you are
580                  * intercepting this payment, you might take a fee by forwarding less than this amount.
581                  * Forwarding less than this amount may break compatibility with LDK versions prior to 0.0.116.
582                  * 
583                  * Note that LDK will NOT check that expected fees were factored into this value. You MUST
584                  * check that whatever fee you want has been included here or subtract it as required. Further,
585                  * LDK will not stop you from forwarding more than you received.
586                  */
587                 public long expected_outbound_amount_msat;
588                 internal Event_HTLCIntercepted(long ptr) : base(null, ptr) {
589                         long intercept_id = bindings.LDKEvent_HTLCIntercepted_get_intercept_id(ptr);
590                         byte[] intercept_id_conv = InternalUtils.decodeUint8Array(intercept_id);
591                         this.intercept_id = intercept_id_conv;
592                         this.requested_next_hop_scid = bindings.LDKEvent_HTLCIntercepted_get_requested_next_hop_scid(ptr);
593                         long payment_hash = bindings.LDKEvent_HTLCIntercepted_get_payment_hash(ptr);
594                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
595                         this.payment_hash = payment_hash_conv;
596                         this.inbound_amount_msat = bindings.LDKEvent_HTLCIntercepted_get_inbound_amount_msat(ptr);
597                         this.expected_outbound_amount_msat = bindings.LDKEvent_HTLCIntercepted_get_expected_outbound_amount_msat(ptr);
598                 }
599         }
600         /** A Event of type SpendableOutputs */
601         public class Event_SpendableOutputs : Event {
602                 /**
603                  * The outputs which you should store as spendable by you.
604                  */
605                 public SpendableOutputDescriptor[] outputs;
606                 /**
607                  * The `channel_id` indicating which channel the spendable outputs belong to.
608                  * 
609                  * This will always be `Some` for events generated by LDK versions 0.0.117 and above.
610                  */
611                 public Option_ThirtyTwoBytesZ channel_id;
612                 internal Event_SpendableOutputs(long ptr) : base(null, ptr) {
613                         long outputs = bindings.LDKEvent_SpendableOutputs_get_outputs(ptr);
614                         int outputs_conv_27_len = InternalUtils.getArrayLength(outputs);
615                         SpendableOutputDescriptor[] outputs_conv_27_arr = new SpendableOutputDescriptor[outputs_conv_27_len];
616                         for (int b = 0; b < outputs_conv_27_len; b++) {
617                                 long outputs_conv_27 = InternalUtils.getU64ArrayElem(outputs, b);
618                                 org.ldk.structs.SpendableOutputDescriptor outputs_conv_27_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(outputs_conv_27);
619                                 if (outputs_conv_27_hu_conv != null) { outputs_conv_27_hu_conv.ptrs_to.AddLast(this); };
620                                 outputs_conv_27_arr[b] = outputs_conv_27_hu_conv;
621                         }
622                         bindings.free_buffer(outputs);
623                         this.outputs = outputs_conv_27_arr;
624                         long channel_id = bindings.LDKEvent_SpendableOutputs_get_channel_id(ptr);
625                         org.ldk.structs.Option_ThirtyTwoBytesZ channel_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(channel_id);
626                         if (channel_id_hu_conv != null) { channel_id_hu_conv.ptrs_to.AddLast(this); };
627                         this.channel_id = channel_id_hu_conv;
628                 }
629         }
630         /** A Event of type PaymentForwarded */
631         public class Event_PaymentForwarded : Event {
632                 /**
633                  * The incoming channel between the previous node and us. This is only `None` for events
634                  * generated or serialized by versions prior to 0.0.107.
635                  */
636                 public Option_ThirtyTwoBytesZ prev_channel_id;
637                 /**
638                  * The outgoing channel between the next node and us. This is only `None` for events
639                  * generated or serialized by versions prior to 0.0.107.
640                  */
641                 public Option_ThirtyTwoBytesZ next_channel_id;
642                 /**
643                  * The fee, in milli-satoshis, which was earned as a result of the payment.
644                  * 
645                  * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
646                  * was pending, the amount the next hop claimed will have been rounded down to the nearest
647                  * whole satoshi. Thus, the fee calculated here may be higher than expected as we still
648                  * claimed the full value in millisatoshis from the source. In this case,
649                  * `claim_from_onchain_tx` will be set.
650                  * 
651                  * If the channel which sent us the payment has been force-closed, we will claim the funds
652                  * via an on-chain transaction. In that case we do not yet know the on-chain transaction
653                  * fees which we will spend and will instead set this to `None`. It is possible duplicate
654                  * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
655                  * `None`.
656                  */
657                 public Option_u64Z fee_earned_msat;
658                 /**
659                  * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
660                  * transaction.
661                  */
662                 public bool claim_from_onchain_tx;
663                 /**
664                  * The final amount forwarded, in milli-satoshis, after the fee is deducted.
665                  * 
666                  * The caveat described above the `fee_earned_msat` field applies here as well.
667                  */
668                 public Option_u64Z outbound_amount_forwarded_msat;
669                 internal Event_PaymentForwarded(long ptr) : base(null, ptr) {
670                         long prev_channel_id = bindings.LDKEvent_PaymentForwarded_get_prev_channel_id(ptr);
671                         org.ldk.structs.Option_ThirtyTwoBytesZ prev_channel_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(prev_channel_id);
672                         if (prev_channel_id_hu_conv != null) { prev_channel_id_hu_conv.ptrs_to.AddLast(this); };
673                         this.prev_channel_id = prev_channel_id_hu_conv;
674                         long next_channel_id = bindings.LDKEvent_PaymentForwarded_get_next_channel_id(ptr);
675                         org.ldk.structs.Option_ThirtyTwoBytesZ next_channel_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(next_channel_id);
676                         if (next_channel_id_hu_conv != null) { next_channel_id_hu_conv.ptrs_to.AddLast(this); };
677                         this.next_channel_id = next_channel_id_hu_conv;
678                         long fee_earned_msat = bindings.LDKEvent_PaymentForwarded_get_fee_earned_msat(ptr);
679                         org.ldk.structs.Option_u64Z fee_earned_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_earned_msat);
680                         if (fee_earned_msat_hu_conv != null) { fee_earned_msat_hu_conv.ptrs_to.AddLast(this); };
681                         this.fee_earned_msat = fee_earned_msat_hu_conv;
682                         this.claim_from_onchain_tx = bindings.LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(ptr);
683                         long outbound_amount_forwarded_msat = bindings.LDKEvent_PaymentForwarded_get_outbound_amount_forwarded_msat(ptr);
684                         org.ldk.structs.Option_u64Z outbound_amount_forwarded_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(outbound_amount_forwarded_msat);
685                         if (outbound_amount_forwarded_msat_hu_conv != null) { outbound_amount_forwarded_msat_hu_conv.ptrs_to.AddLast(this); };
686                         this.outbound_amount_forwarded_msat = outbound_amount_forwarded_msat_hu_conv;
687                 }
688         }
689         /** A Event of type ChannelPending */
690         public class Event_ChannelPending : Event {
691                 /**
692                  * The `channel_id` of the channel that is pending confirmation.
693                  */
694                 public byte[] channel_id;
695                 /**
696                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
697                  * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
698                  * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
699                  * `user_channel_id` will be randomized for an inbound channel.
700                  * 
701                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
702                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
703                  * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
704                  */
705                 public UInt128 user_channel_id;
706                 /**
707                  * The `temporary_channel_id` this channel used to be known by during channel establishment.
708                  * 
709                  * Will be `None` for channels created prior to LDK version 0.0.115.
710                  */
711                 public Option_ThirtyTwoBytesZ former_temporary_channel_id;
712                 /**
713                  * The `node_id` of the channel counterparty.
714                  */
715                 public byte[] counterparty_node_id;
716                 /**
717                  * The outpoint of the channel's funding transaction.
718                  */
719                 public OutPoint funding_txo;
720                 internal Event_ChannelPending(long ptr) : base(null, ptr) {
721                         long channel_id = bindings.LDKEvent_ChannelPending_get_channel_id(ptr);
722                         byte[] channel_id_conv = InternalUtils.decodeUint8Array(channel_id);
723                         this.channel_id = channel_id_conv;
724                         long user_channel_id = bindings.LDKEvent_ChannelPending_get_user_channel_id(ptr);
725                         org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
726                         this.user_channel_id = user_channel_id_conv;
727                         long former_temporary_channel_id = bindings.LDKEvent_ChannelPending_get_former_temporary_channel_id(ptr);
728                         org.ldk.structs.Option_ThirtyTwoBytesZ former_temporary_channel_id_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(former_temporary_channel_id);
729                         if (former_temporary_channel_id_hu_conv != null) { former_temporary_channel_id_hu_conv.ptrs_to.AddLast(this); };
730                         this.former_temporary_channel_id = former_temporary_channel_id_hu_conv;
731                         long counterparty_node_id = bindings.LDKEvent_ChannelPending_get_counterparty_node_id(ptr);
732                         byte[] counterparty_node_id_conv = InternalUtils.decodeUint8Array(counterparty_node_id);
733                         this.counterparty_node_id = counterparty_node_id_conv;
734                         long funding_txo = bindings.LDKEvent_ChannelPending_get_funding_txo(ptr);
735                         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); }
736                         if (funding_txo_hu_conv != null) { funding_txo_hu_conv.ptrs_to.AddLast(this); };
737                         this.funding_txo = funding_txo_hu_conv;
738                 }
739         }
740         /** A Event of type ChannelReady */
741         public class Event_ChannelReady : Event {
742                 /**
743                  * The `channel_id` of the channel that is ready.
744                  */
745                 public byte[] channel_id;
746                 /**
747                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
748                  * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
749                  * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
750                  * `user_channel_id` will be randomized for an inbound channel.
751                  * 
752                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
753                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
754                  * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
755                  */
756                 public UInt128 user_channel_id;
757                 /**
758                  * The `node_id` of the channel counterparty.
759                  */
760                 public byte[] counterparty_node_id;
761                 /**
762                  * The features that this channel will operate with.
763                  */
764                 public ChannelTypeFeatures channel_type;
765                 internal Event_ChannelReady(long ptr) : base(null, ptr) {
766                         long channel_id = bindings.LDKEvent_ChannelReady_get_channel_id(ptr);
767                         byte[] channel_id_conv = InternalUtils.decodeUint8Array(channel_id);
768                         this.channel_id = channel_id_conv;
769                         long user_channel_id = bindings.LDKEvent_ChannelReady_get_user_channel_id(ptr);
770                         org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
771                         this.user_channel_id = user_channel_id_conv;
772                         long counterparty_node_id = bindings.LDKEvent_ChannelReady_get_counterparty_node_id(ptr);
773                         byte[] counterparty_node_id_conv = InternalUtils.decodeUint8Array(counterparty_node_id);
774                         this.counterparty_node_id = counterparty_node_id_conv;
775                         long channel_type = bindings.LDKEvent_ChannelReady_get_channel_type(ptr);
776                         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); }
777                         if (channel_type_hu_conv != null) { channel_type_hu_conv.ptrs_to.AddLast(this); };
778                         this.channel_type = channel_type_hu_conv;
779                 }
780         }
781         /** A Event of type ChannelClosed */
782         public class Event_ChannelClosed : Event {
783                 /**
784                  * The `channel_id` of the channel which has been closed. Note that on-chain transactions
785                  * resolving the channel are likely still awaiting confirmation.
786                  */
787                 public byte[] channel_id;
788                 /**
789                  * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
790                  * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
791                  * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
792                  * `user_channel_id` will be randomized for inbound channels.
793                  * This may be zero for inbound channels serialized prior to 0.0.113 and will always be
794                  * zero for objects serialized with LDK versions prior to 0.0.102.
795                  * 
796                  * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
797                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
798                  * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
799                  */
800                 public UInt128 user_channel_id;
801                 /**
802                  * The reason the channel was closed.
803                  */
804                 public ClosureReason reason;
805                 /**
806                  * Counterparty in the closed channel.
807                  * 
808                  * This field will be `None` for objects serialized prior to LDK 0.0.117.
809                  * 
810                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
811                  */
812                 public byte[] counterparty_node_id;
813                 /**
814                  * Channel capacity of the closing channel (sats).
815                  * 
816                  * This field will be `None` for objects serialized prior to LDK 0.0.117.
817                  */
818                 public Option_u64Z channel_capacity_sats;
819                 internal Event_ChannelClosed(long ptr) : base(null, ptr) {
820                         long channel_id = bindings.LDKEvent_ChannelClosed_get_channel_id(ptr);
821                         byte[] channel_id_conv = InternalUtils.decodeUint8Array(channel_id);
822                         this.channel_id = channel_id_conv;
823                         long user_channel_id = bindings.LDKEvent_ChannelClosed_get_user_channel_id(ptr);
824                         org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
825                         this.user_channel_id = user_channel_id_conv;
826                         long reason = bindings.LDKEvent_ChannelClosed_get_reason(ptr);
827                         org.ldk.structs.ClosureReason reason_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(reason);
828                         if (reason_hu_conv != null) { reason_hu_conv.ptrs_to.AddLast(this); };
829                         this.reason = reason_hu_conv;
830                         long counterparty_node_id = bindings.LDKEvent_ChannelClosed_get_counterparty_node_id(ptr);
831                         byte[] counterparty_node_id_conv = InternalUtils.decodeUint8Array(counterparty_node_id);
832                         this.counterparty_node_id = counterparty_node_id_conv;
833                         long channel_capacity_sats = bindings.LDKEvent_ChannelClosed_get_channel_capacity_sats(ptr);
834                         org.ldk.structs.Option_u64Z channel_capacity_sats_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(channel_capacity_sats);
835                         if (channel_capacity_sats_hu_conv != null) { channel_capacity_sats_hu_conv.ptrs_to.AddLast(this); };
836                         this.channel_capacity_sats = channel_capacity_sats_hu_conv;
837                 }
838         }
839         /** A Event of type DiscardFunding */
840         public class Event_DiscardFunding : Event {
841                 /**
842                  * The channel_id of the channel which has been closed.
843                  */
844                 public byte[] channel_id;
845                 /**
846                  * The full transaction received from the user
847                  */
848                 public byte[] transaction;
849                 internal Event_DiscardFunding(long ptr) : base(null, ptr) {
850                         long channel_id = bindings.LDKEvent_DiscardFunding_get_channel_id(ptr);
851                         byte[] channel_id_conv = InternalUtils.decodeUint8Array(channel_id);
852                         this.channel_id = channel_id_conv;
853                         long transaction = bindings.LDKEvent_DiscardFunding_get_transaction(ptr);
854                         byte[] transaction_conv = InternalUtils.decodeUint8Array(transaction);
855                         this.transaction = transaction_conv;
856                 }
857         }
858         /** A Event of type OpenChannelRequest */
859         public class Event_OpenChannelRequest : Event {
860                 /**
861                  * The temporary channel ID of the channel requested to be opened.
862                  * 
863                  * When responding to the request, the `temporary_channel_id` should be passed
864                  * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
865                  * or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
866                  * 
867                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
868                  * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
869                  */
870                 public byte[] temporary_channel_id;
871                 /**
872                  * The node_id of the counterparty requesting to open the channel.
873                  * 
874                  * When responding to the request, the `counterparty_node_id` should be passed
875                  * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
876                  * accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
877                  * request.
878                  * 
879                  * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
880                  * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
881                  */
882                 public byte[] counterparty_node_id;
883                 /**
884                  * The channel value of the requested channel.
885                  */
886                 public long funding_satoshis;
887                 /**
888                  * Our starting balance in the channel if the request is accepted, in milli-satoshi.
889                  */
890                 public long push_msat;
891                 /**
892                  * The features that this channel will operate with. If you reject the channel, a
893                  * well-behaved counterparty may automatically re-attempt the channel with a new set of
894                  * feature flags.
895                  * 
896                  * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
897                  * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
898                  * 0.0.106.
899                  * 
900                  * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
901                  * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
902                  * 0.0.107. Channels setting this type also need to get manually accepted via
903                  * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`],
904                  * or will be rejected otherwise.
905                  * 
906                  * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
907                  */
908                 public ChannelTypeFeatures channel_type;
909                 internal Event_OpenChannelRequest(long ptr) : base(null, ptr) {
910                         long temporary_channel_id = bindings.LDKEvent_OpenChannelRequest_get_temporary_channel_id(ptr);
911                         byte[] temporary_channel_id_conv = InternalUtils.decodeUint8Array(temporary_channel_id);
912                         this.temporary_channel_id = temporary_channel_id_conv;
913                         long counterparty_node_id = bindings.LDKEvent_OpenChannelRequest_get_counterparty_node_id(ptr);
914                         byte[] counterparty_node_id_conv = InternalUtils.decodeUint8Array(counterparty_node_id);
915                         this.counterparty_node_id = counterparty_node_id_conv;
916                         this.funding_satoshis = bindings.LDKEvent_OpenChannelRequest_get_funding_satoshis(ptr);
917                         this.push_msat = bindings.LDKEvent_OpenChannelRequest_get_push_msat(ptr);
918                         long channel_type = bindings.LDKEvent_OpenChannelRequest_get_channel_type(ptr);
919                         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); }
920                         if (channel_type_hu_conv != null) { channel_type_hu_conv.ptrs_to.AddLast(this); };
921                         this.channel_type = channel_type_hu_conv;
922                 }
923         }
924         /** A Event of type HTLCHandlingFailed */
925         public class Event_HTLCHandlingFailed : Event {
926                 /**
927                  * The channel over which the HTLC was received.
928                  */
929                 public byte[] prev_channel_id;
930                 /**
931                  * Destination of the HTLC that failed to be processed.
932                  */
933                 public HTLCDestination failed_next_destination;
934                 internal Event_HTLCHandlingFailed(long ptr) : base(null, ptr) {
935                         long prev_channel_id = bindings.LDKEvent_HTLCHandlingFailed_get_prev_channel_id(ptr);
936                         byte[] prev_channel_id_conv = InternalUtils.decodeUint8Array(prev_channel_id);
937                         this.prev_channel_id = prev_channel_id_conv;
938                         long failed_next_destination = bindings.LDKEvent_HTLCHandlingFailed_get_failed_next_destination(ptr);
939                         org.ldk.structs.HTLCDestination failed_next_destination_hu_conv = org.ldk.structs.HTLCDestination.constr_from_ptr(failed_next_destination);
940                         if (failed_next_destination_hu_conv != null) { failed_next_destination_hu_conv.ptrs_to.AddLast(this); };
941                         this.failed_next_destination = failed_next_destination_hu_conv;
942                 }
943         }
944         /** A Event of type BumpTransaction */
945         public class Event_BumpTransaction : Event {
946                 public BumpTransactionEvent bump_transaction;
947                 internal Event_BumpTransaction(long ptr) : base(null, ptr) {
948                         long bump_transaction = bindings.LDKEvent_BumpTransaction_get_bump_transaction(ptr);
949                         org.ldk.structs.BumpTransactionEvent bump_transaction_hu_conv = org.ldk.structs.BumpTransactionEvent.constr_from_ptr(bump_transaction);
950                         if (bump_transaction_hu_conv != null) { bump_transaction_hu_conv.ptrs_to.AddLast(this); };
951                         this.bump_transaction = bump_transaction_hu_conv;
952                 }
953         }
954         internal long clone_ptr() {
955                 long ret = bindings.Event_clone_ptr(this.ptr);
956                 GC.KeepAlive(this);
957                 return ret;
958         }
959
960         /**
961          * Creates a copy of the Event
962          */
963         public Event clone() {
964                 long ret = bindings.Event_clone(this.ptr);
965                 GC.KeepAlive(this);
966                 if (ret >= 0 && ret <= 4096) { return null; }
967                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
968                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
969                 return ret_hu_conv;
970         }
971
972         /**
973          * Utility method to constructs a new FundingGenerationReady-variant Event
974          */
975         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) {
976                 long ret = bindings.Event_funding_generation_ready(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(temporary_channel_id, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)), channel_value_satoshis, InternalUtils.encodeUint8Array(output_script), InternalUtils.encodeUint8Array(user_channel_id.getLEBytes()));
977                 GC.KeepAlive(temporary_channel_id);
978                 GC.KeepAlive(counterparty_node_id);
979                 GC.KeepAlive(channel_value_satoshis);
980                 GC.KeepAlive(output_script);
981                 GC.KeepAlive(user_channel_id);
982                 if (ret >= 0 && ret <= 4096) { return null; }
983                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
984                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
985                 return ret_hu_conv;
986         }
987
988         /**
989          * Utility method to constructs a new PaymentClaimable-variant Event
990          */
991         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) {
992                 long ret = bindings.Event_payment_claimable(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(receiver_node_id, 33)), InternalUtils.encodeUint8Array(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);
993                 GC.KeepAlive(receiver_node_id);
994                 GC.KeepAlive(payment_hash);
995                 GC.KeepAlive(onion_fields);
996                 GC.KeepAlive(amount_msat);
997                 GC.KeepAlive(counterparty_skimmed_fee_msat);
998                 GC.KeepAlive(purpose);
999                 GC.KeepAlive(via_channel_id);
1000                 GC.KeepAlive(via_user_channel_id);
1001                 GC.KeepAlive(claim_deadline);
1002                 if (ret >= 0 && ret <= 4096) { return null; }
1003                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1004                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1005                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(onion_fields); };
1006                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(purpose); };
1007                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(via_channel_id); };
1008                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(via_user_channel_id); };
1009                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(claim_deadline); };
1010                 return ret_hu_conv;
1011         }
1012
1013         /**
1014          * Utility method to constructs a new PaymentClaimed-variant Event
1015          */
1016         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) {
1017                 long ret = bindings.Event_payment_claimed(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(receiver_node_id, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), amount_msat, purpose.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(htlcs, htlcs_conv_13 => htlcs_conv_13 == null ? 0 : htlcs_conv_13.ptr)), sender_intended_total_msat.ptr);
1018                 GC.KeepAlive(receiver_node_id);
1019                 GC.KeepAlive(payment_hash);
1020                 GC.KeepAlive(amount_msat);
1021                 GC.KeepAlive(purpose);
1022                 GC.KeepAlive(htlcs);
1023                 GC.KeepAlive(sender_intended_total_msat);
1024                 if (ret >= 0 && ret <= 4096) { return null; }
1025                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1026                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1027                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(purpose); };
1028                 foreach (ClaimedHTLC htlcs_conv_13 in htlcs) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(htlcs_conv_13); }; };
1029                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(sender_intended_total_msat); };
1030                 return ret_hu_conv;
1031         }
1032
1033         /**
1034          * Utility method to constructs a new InvoiceRequestFailed-variant Event
1035          */
1036         public static Event invoice_request_failed(byte[] payment_id) {
1037                 long ret = bindings.Event_invoice_request_failed(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)));
1038                 GC.KeepAlive(payment_id);
1039                 if (ret >= 0 && ret <= 4096) { return null; }
1040                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1041                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1042                 return ret_hu_conv;
1043         }
1044
1045         /**
1046          * Utility method to constructs a new PaymentSent-variant Event
1047          */
1048         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) {
1049                 long ret = bindings.Event_payment_sent(payment_id.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), fee_paid_msat.ptr);
1050                 GC.KeepAlive(payment_id);
1051                 GC.KeepAlive(payment_preimage);
1052                 GC.KeepAlive(payment_hash);
1053                 GC.KeepAlive(fee_paid_msat);
1054                 if (ret >= 0 && ret <= 4096) { return null; }
1055                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1056                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1057                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_id); };
1058                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_paid_msat); };
1059                 return ret_hu_conv;
1060         }
1061
1062         /**
1063          * Utility method to constructs a new PaymentFailed-variant Event
1064          */
1065         public static Event payment_failed(byte[] payment_id, byte[] payment_hash, org.ldk.structs.Option_PaymentFailureReasonZ reason) {
1066                 long ret = bindings.Event_payment_failed(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), reason.ptr);
1067                 GC.KeepAlive(payment_id);
1068                 GC.KeepAlive(payment_hash);
1069                 GC.KeepAlive(reason);
1070                 if (ret >= 0 && ret <= 4096) { return null; }
1071                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1072                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1073                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(reason); };
1074                 return ret_hu_conv;
1075         }
1076
1077         /**
1078          * Utility method to constructs a new PaymentPathSuccessful-variant Event
1079          */
1080         public static Event payment_path_successful(byte[] payment_id, org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash, org.ldk.structs.Path path) {
1081                 long ret = bindings.Event_payment_path_successful(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)), payment_hash.ptr, path == null ? 0 : path.ptr);
1082                 GC.KeepAlive(payment_id);
1083                 GC.KeepAlive(payment_hash);
1084                 GC.KeepAlive(path);
1085                 if (ret >= 0 && ret <= 4096) { return null; }
1086                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1087                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1088                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_hash); };
1089                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); };
1090                 return ret_hu_conv;
1091         }
1092
1093         /**
1094          * Utility method to constructs a new PaymentPathFailed-variant Event
1095          */
1096         public static Event payment_path_failed(org.ldk.structs.Option_ThirtyTwoBytesZ payment_id, byte[] payment_hash, bool payment_failed_permanently, org.ldk.structs.PathFailure failure, org.ldk.structs.Path path, org.ldk.structs.Option_u64Z short_channel_id) {
1097                 long ret = bindings.Event_payment_path_failed(payment_id.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), payment_failed_permanently, failure.ptr, path == null ? 0 : path.ptr, short_channel_id.ptr);
1098                 GC.KeepAlive(payment_id);
1099                 GC.KeepAlive(payment_hash);
1100                 GC.KeepAlive(payment_failed_permanently);
1101                 GC.KeepAlive(failure);
1102                 GC.KeepAlive(path);
1103                 GC.KeepAlive(short_channel_id);
1104                 if (ret >= 0 && ret <= 4096) { return null; }
1105                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_id); };
1108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(failure); };
1109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); };
1110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(short_channel_id); };
1111                 return ret_hu_conv;
1112         }
1113
1114         /**
1115          * Utility method to constructs a new ProbeSuccessful-variant Event
1116          */
1117         public static Event probe_successful(byte[] payment_id, byte[] payment_hash, org.ldk.structs.Path path) {
1118                 long ret = bindings.Event_probe_successful(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), path == null ? 0 : path.ptr);
1119                 GC.KeepAlive(payment_id);
1120                 GC.KeepAlive(payment_hash);
1121                 GC.KeepAlive(path);
1122                 if (ret >= 0 && ret <= 4096) { return null; }
1123                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1124                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); };
1126                 return ret_hu_conv;
1127         }
1128
1129         /**
1130          * Utility method to constructs a new ProbeFailed-variant Event
1131          */
1132         public static Event probe_failed(byte[] payment_id, byte[] payment_hash, org.ldk.structs.Path path, org.ldk.structs.Option_u64Z short_channel_id) {
1133                 long ret = bindings.Event_probe_failed(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), path == null ? 0 : path.ptr, short_channel_id.ptr);
1134                 GC.KeepAlive(payment_id);
1135                 GC.KeepAlive(payment_hash);
1136                 GC.KeepAlive(path);
1137                 GC.KeepAlive(short_channel_id);
1138                 if (ret >= 0 && ret <= 4096) { return null; }
1139                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1140                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1141                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); };
1142                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(short_channel_id); };
1143                 return ret_hu_conv;
1144         }
1145
1146         /**
1147          * Utility method to constructs a new PendingHTLCsForwardable-variant Event
1148          */
1149         public static Event pending_htlcs_forwardable(long time_forwardable) {
1150                 long ret = bindings.Event_pending_htlcs_forwardable(time_forwardable);
1151                 GC.KeepAlive(time_forwardable);
1152                 if (ret >= 0 && ret <= 4096) { return null; }
1153                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1154                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1155                 return ret_hu_conv;
1156         }
1157
1158         /**
1159          * Utility method to constructs a new HTLCIntercepted-variant Event
1160          */
1161         public static Event htlcintercepted(byte[] intercept_id, long requested_next_hop_scid, byte[] payment_hash, long inbound_amount_msat, long expected_outbound_amount_msat) {
1162                 long ret = bindings.Event_htlcintercepted(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(intercept_id, 32)), requested_next_hop_scid, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), inbound_amount_msat, expected_outbound_amount_msat);
1163                 GC.KeepAlive(intercept_id);
1164                 GC.KeepAlive(requested_next_hop_scid);
1165                 GC.KeepAlive(payment_hash);
1166                 GC.KeepAlive(inbound_amount_msat);
1167                 GC.KeepAlive(expected_outbound_amount_msat);
1168                 if (ret >= 0 && ret <= 4096) { return null; }
1169                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1170                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1171                 return ret_hu_conv;
1172         }
1173
1174         /**
1175          * Utility method to constructs a new SpendableOutputs-variant Event
1176          */
1177         public static Event spendable_outputs(SpendableOutputDescriptor[] outputs, org.ldk.structs.Option_ThirtyTwoBytesZ channel_id) {
1178                 long ret = bindings.Event_spendable_outputs(InternalUtils.encodeUint64Array(InternalUtils.mapArray(outputs, outputs_conv_27 => outputs_conv_27.ptr)), channel_id.ptr);
1179                 GC.KeepAlive(outputs);
1180                 GC.KeepAlive(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.AddLast(ret_hu_conv); };
1184                 foreach (SpendableOutputDescriptor outputs_conv_27 in outputs) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outputs_conv_27); }; };
1185                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id); };
1186                 return ret_hu_conv;
1187         }
1188
1189         /**
1190          * Utility method to constructs a new PaymentForwarded-variant Event
1191          */
1192         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, bool claim_from_onchain_tx, org.ldk.structs.Option_u64Z outbound_amount_forwarded_msat) {
1193                 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);
1194                 GC.KeepAlive(prev_channel_id);
1195                 GC.KeepAlive(next_channel_id);
1196                 GC.KeepAlive(fee_earned_msat);
1197                 GC.KeepAlive(claim_from_onchain_tx);
1198                 GC.KeepAlive(outbound_amount_forwarded_msat);
1199                 if (ret >= 0 && ret <= 4096) { return null; }
1200                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1201                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1202                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(prev_channel_id); };
1203                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(next_channel_id); };
1204                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_earned_msat); };
1205                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outbound_amount_forwarded_msat); };
1206                 return ret_hu_conv;
1207         }
1208
1209         /**
1210          * Utility method to constructs a new ChannelPending-variant Event
1211          */
1212         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) {
1213                 long ret = bindings.Event_channel_pending(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id, 32)), InternalUtils.encodeUint8Array(user_channel_id.getLEBytes()), former_temporary_channel_id.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)), funding_txo == null ? 0 : funding_txo.ptr);
1214                 GC.KeepAlive(channel_id);
1215                 GC.KeepAlive(user_channel_id);
1216                 GC.KeepAlive(former_temporary_channel_id);
1217                 GC.KeepAlive(counterparty_node_id);
1218                 GC.KeepAlive(funding_txo);
1219                 if (ret >= 0 && ret <= 4096) { return null; }
1220                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1221                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1222                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(former_temporary_channel_id); };
1223                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(funding_txo); };
1224                 return ret_hu_conv;
1225         }
1226
1227         /**
1228          * Utility method to constructs a new ChannelReady-variant Event
1229          */
1230         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) {
1231                 long ret = bindings.Event_channel_ready(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id, 32)), InternalUtils.encodeUint8Array(user_channel_id.getLEBytes()), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)), channel_type == null ? 0 : channel_type.ptr);
1232                 GC.KeepAlive(channel_id);
1233                 GC.KeepAlive(user_channel_id);
1234                 GC.KeepAlive(counterparty_node_id);
1235                 GC.KeepAlive(channel_type);
1236                 if (ret >= 0 && ret <= 4096) { return null; }
1237                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1238                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1239                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_type); };
1240                 return ret_hu_conv;
1241         }
1242
1243         /**
1244          * Utility method to constructs a new ChannelClosed-variant Event
1245          */
1246         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) {
1247                 long ret = bindings.Event_channel_closed(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id, 32)), InternalUtils.encodeUint8Array(user_channel_id.getLEBytes()), reason.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)), channel_capacity_sats.ptr);
1248                 GC.KeepAlive(channel_id);
1249                 GC.KeepAlive(user_channel_id);
1250                 GC.KeepAlive(reason);
1251                 GC.KeepAlive(counterparty_node_id);
1252                 GC.KeepAlive(channel_capacity_sats);
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.AddLast(ret_hu_conv); };
1256                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(reason); };
1257                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_capacity_sats); };
1258                 return ret_hu_conv;
1259         }
1260
1261         /**
1262          * Utility method to constructs a new DiscardFunding-variant Event
1263          */
1264         public static Event discard_funding(byte[] channel_id, byte[] transaction) {
1265                 long ret = bindings.Event_discard_funding(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id, 32)), InternalUtils.encodeUint8Array(transaction));
1266                 GC.KeepAlive(channel_id);
1267                 GC.KeepAlive(transaction);
1268                 if (ret >= 0 && ret <= 4096) { return null; }
1269                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1270                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1271                 return ret_hu_conv;
1272         }
1273
1274         /**
1275          * Utility method to constructs a new OpenChannelRequest-variant Event
1276          */
1277         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) {
1278                 long ret = bindings.Event_open_channel_request(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(temporary_channel_id, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)), funding_satoshis, push_msat, channel_type == null ? 0 : channel_type.ptr);
1279                 GC.KeepAlive(temporary_channel_id);
1280                 GC.KeepAlive(counterparty_node_id);
1281                 GC.KeepAlive(funding_satoshis);
1282                 GC.KeepAlive(push_msat);
1283                 GC.KeepAlive(channel_type);
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.AddLast(ret_hu_conv); };
1287                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_type); };
1288                 return ret_hu_conv;
1289         }
1290
1291         /**
1292          * Utility method to constructs a new HTLCHandlingFailed-variant Event
1293          */
1294         public static Event htlchandling_failed(byte[] prev_channel_id, org.ldk.structs.HTLCDestination failed_next_destination) {
1295                 long ret = bindings.Event_htlchandling_failed(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(prev_channel_id, 32)), failed_next_destination.ptr);
1296                 GC.KeepAlive(prev_channel_id);
1297                 GC.KeepAlive(failed_next_destination);
1298                 if (ret >= 0 && ret <= 4096) { return null; }
1299                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1300                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1301                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(failed_next_destination); };
1302                 return ret_hu_conv;
1303         }
1304
1305         /**
1306          * Utility method to constructs a new BumpTransaction-variant Event
1307          */
1308         public static Event bump_transaction(org.ldk.structs.BumpTransactionEvent a) {
1309                 long ret = bindings.Event_bump_transaction(a.ptr);
1310                 GC.KeepAlive(a);
1311                 if (ret >= 0 && ret <= 4096) { return null; }
1312                 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1313                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
1314                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
1315                 return ret_hu_conv;
1316         }
1317
1318         /**
1319          * Checks if two Events contain equal inner contents.
1320          * This ignores pointers and is_owned flags and looks at the values in fields.
1321          */
1322         public bool eq(org.ldk.structs.Event b) {
1323                 bool ret = bindings.Event_eq(this.ptr, b == null ? 0 : b.ptr);
1324                 GC.KeepAlive(this);
1325                 GC.KeepAlive(b);
1326                 return ret;
1327         }
1328
1329         public override bool Equals(object o) {
1330                 if (!(o is Event)) return false;
1331                 return this.eq((Event)o);
1332         }
1333         /**
1334          * Serialize the Event object into a byte array which can be read by Event_read
1335          */
1336         public byte[] write() {
1337                 long ret = bindings.Event_write(this.ptr);
1338                 GC.KeepAlive(this);
1339                 if (ret >= 0 && ret <= 4096) { return null; }
1340                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
1341                 return ret_conv;
1342         }
1343
1344 }
1345 } } }