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