1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * An Event which you should probably take some action in response to.
14 * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
15 * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
16 * written as it makes no sense to respond to it after reconnecting to peers).
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class Event extends CommonBase {
20 private Event(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.Event_free(ptr); }
26 static Event constr_from_ptr(long ptr) {
27 bindings.LDKEvent raw_val = bindings.LDKEvent_ref_from_ptr(ptr);
28 if (raw_val.getClass() == bindings.LDKEvent.FundingGenerationReady.class) {
29 return new FundingGenerationReady(ptr, (bindings.LDKEvent.FundingGenerationReady)raw_val);
31 if (raw_val.getClass() == bindings.LDKEvent.PaymentClaimable.class) {
32 return new PaymentClaimable(ptr, (bindings.LDKEvent.PaymentClaimable)raw_val);
34 if (raw_val.getClass() == bindings.LDKEvent.PaymentClaimed.class) {
35 return new PaymentClaimed(ptr, (bindings.LDKEvent.PaymentClaimed)raw_val);
37 if (raw_val.getClass() == bindings.LDKEvent.PaymentSent.class) {
38 return new PaymentSent(ptr, (bindings.LDKEvent.PaymentSent)raw_val);
40 if (raw_val.getClass() == bindings.LDKEvent.PaymentFailed.class) {
41 return new PaymentFailed(ptr, (bindings.LDKEvent.PaymentFailed)raw_val);
43 if (raw_val.getClass() == bindings.LDKEvent.PaymentPathSuccessful.class) {
44 return new PaymentPathSuccessful(ptr, (bindings.LDKEvent.PaymentPathSuccessful)raw_val);
46 if (raw_val.getClass() == bindings.LDKEvent.PaymentPathFailed.class) {
47 return new PaymentPathFailed(ptr, (bindings.LDKEvent.PaymentPathFailed)raw_val);
49 if (raw_val.getClass() == bindings.LDKEvent.ProbeSuccessful.class) {
50 return new ProbeSuccessful(ptr, (bindings.LDKEvent.ProbeSuccessful)raw_val);
52 if (raw_val.getClass() == bindings.LDKEvent.ProbeFailed.class) {
53 return new ProbeFailed(ptr, (bindings.LDKEvent.ProbeFailed)raw_val);
55 if (raw_val.getClass() == bindings.LDKEvent.PendingHTLCsForwardable.class) {
56 return new PendingHTLCsForwardable(ptr, (bindings.LDKEvent.PendingHTLCsForwardable)raw_val);
58 if (raw_val.getClass() == bindings.LDKEvent.HTLCIntercepted.class) {
59 return new HTLCIntercepted(ptr, (bindings.LDKEvent.HTLCIntercepted)raw_val);
61 if (raw_val.getClass() == bindings.LDKEvent.SpendableOutputs.class) {
62 return new SpendableOutputs(ptr, (bindings.LDKEvent.SpendableOutputs)raw_val);
64 if (raw_val.getClass() == bindings.LDKEvent.PaymentForwarded.class) {
65 return new PaymentForwarded(ptr, (bindings.LDKEvent.PaymentForwarded)raw_val);
67 if (raw_val.getClass() == bindings.LDKEvent.ChannelReady.class) {
68 return new ChannelReady(ptr, (bindings.LDKEvent.ChannelReady)raw_val);
70 if (raw_val.getClass() == bindings.LDKEvent.ChannelClosed.class) {
71 return new ChannelClosed(ptr, (bindings.LDKEvent.ChannelClosed)raw_val);
73 if (raw_val.getClass() == bindings.LDKEvent.DiscardFunding.class) {
74 return new DiscardFunding(ptr, (bindings.LDKEvent.DiscardFunding)raw_val);
76 if (raw_val.getClass() == bindings.LDKEvent.OpenChannelRequest.class) {
77 return new OpenChannelRequest(ptr, (bindings.LDKEvent.OpenChannelRequest)raw_val);
79 if (raw_val.getClass() == bindings.LDKEvent.HTLCHandlingFailed.class) {
80 return new HTLCHandlingFailed(ptr, (bindings.LDKEvent.HTLCHandlingFailed)raw_val);
82 assert false; return null; // Unreachable without extending the (internal) bindings interface
86 * Used to indicate that the client should generate a funding transaction with the given
87 * parameters and then call [`ChannelManager::funding_transaction_generated`].
88 * Generated in [`ChannelManager`] message handling.
89 * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
90 * counterparty can steal your funds!
92 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
93 * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
95 public final static class FundingGenerationReady extends Event {
97 * The random channel_id we picked which you'll need to pass into
98 * [`ChannelManager::funding_transaction_generated`].
100 * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
102 public final byte[] temporary_channel_id;
104 * The counterparty's node_id, which you'll need to pass back into
105 * [`ChannelManager::funding_transaction_generated`].
107 * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
109 public final byte[] counterparty_node_id;
111 * The value, in satoshis, that the output should have.
113 public final long channel_value_satoshis;
115 * The script which should be used in the transaction output.
117 public final byte[] output_script;
119 * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or a
120 * random value for an inbound channel. This may be zero for objects serialized with LDK
121 * versions prior to 0.0.113.
123 * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
125 public final org.ldk.util.UInt128 user_channel_id;
126 private FundingGenerationReady(long ptr, bindings.LDKEvent.FundingGenerationReady obj) {
128 this.temporary_channel_id = obj.temporary_channel_id;
129 this.counterparty_node_id = obj.counterparty_node_id;
130 this.channel_value_satoshis = obj.channel_value_satoshis;
131 this.output_script = obj.output_script;
132 byte[] user_channel_id = obj.user_channel_id;
133 org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
134 this.user_channel_id = user_channel_id_conv;
138 * Indicates that we've been offered a payment and it needs to be claimed via calling
139 * [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`].
141 * Note that if the preimage is not known, you should call
142 * [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid
143 * network congestion.
144 * If you fail to call either [`ChannelManager::claim_funds`] or
145 * [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be
146 * automatically failed.
149 * LDK will not stop an inbound payment from being paid multiple times, so multiple
150 * `PaymentClaimable` events may be generated for the same payment.
153 * This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier.
155 * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
156 * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
158 public final static class PaymentClaimable extends Event {
160 * The node that will receive the payment after it has been claimed.
161 * This is useful to identify payments received via [phantom nodes].
162 * This field will always be filled in when the event was generated by LDK versions
165 * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager
167 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
169 @Nullable public final byte[] receiver_node_id;
171 * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
172 * not stop you from registering duplicate payment hashes for inbound payments.
174 public final byte[] payment_hash;
176 * The value, in thousandths of a satoshi, that this payment is for.
178 public final long amount_msat;
180 * Information for claiming this received payment, based on whether the purpose of the
181 * payment is to pay an invoice or to send a spontaneous payment.
183 public final org.ldk.structs.PaymentPurpose purpose;
185 * The `channel_id` indicating over which channel we received the payment.
187 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
189 @Nullable public final byte[] via_channel_id;
191 * The `user_channel_id` indicating over which channel we received the payment.
193 public final org.ldk.structs.Option_u128Z via_user_channel_id;
194 private PaymentClaimable(long ptr, bindings.LDKEvent.PaymentClaimable obj) {
196 this.receiver_node_id = obj.receiver_node_id;
197 this.payment_hash = obj.payment_hash;
198 this.amount_msat = obj.amount_msat;
199 long purpose = obj.purpose;
200 org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
201 if (purpose_hu_conv != null) { purpose_hu_conv.ptrs_to.add(this); };
202 this.purpose = purpose_hu_conv;
203 this.via_channel_id = obj.via_channel_id;
204 long via_user_channel_id = obj.via_user_channel_id;
205 org.ldk.structs.Option_u128Z via_user_channel_id_hu_conv = org.ldk.structs.Option_u128Z.constr_from_ptr(via_user_channel_id);
206 if (via_user_channel_id_hu_conv != null) { via_user_channel_id_hu_conv.ptrs_to.add(this); };
207 this.via_user_channel_id = via_user_channel_id_hu_conv;
211 * Indicates a payment has been claimed and we've received money!
213 * This most likely occurs when [`ChannelManager::claim_funds`] has been called in response
214 * to an [`Event::PaymentClaimable`]. However, if we previously crashed during a
215 * [`ChannelManager::claim_funds`] call you may see this event without a corresponding
216 * [`Event::PaymentClaimable`] event.
219 * LDK will not stop an inbound payment from being paid multiple times, so multiple
220 * `PaymentClaimable` events may be generated for the same payment. If you then call
221 * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get
222 * multiple `PaymentClaimed` events.
224 * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
226 public final static class PaymentClaimed extends Event {
228 * The node that received the payment.
229 * This is useful to identify payments which were received via [phantom nodes].
230 * This field will always be filled in when the event was generated by LDK versions
233 * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager
235 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
237 @Nullable public final byte[] receiver_node_id;
239 * The payment hash of the claimed payment. Note that LDK will not stop you from
240 * registering duplicate payment hashes for inbound payments.
242 public final byte[] payment_hash;
244 * The value, in thousandths of a satoshi, that this payment is for.
246 public final long amount_msat;
248 * The purpose of the claimed payment, i.e. whether the payment was for an invoice or a
249 * spontaneous payment.
251 public final org.ldk.structs.PaymentPurpose purpose;
252 private PaymentClaimed(long ptr, bindings.LDKEvent.PaymentClaimed obj) {
254 this.receiver_node_id = obj.receiver_node_id;
255 this.payment_hash = obj.payment_hash;
256 this.amount_msat = obj.amount_msat;
257 long purpose = obj.purpose;
258 org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
259 if (purpose_hu_conv != null) { purpose_hu_conv.ptrs_to.add(this); };
260 this.purpose = purpose_hu_conv;
264 * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
265 * and we got back the payment preimage for it).
267 * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
268 * event. In this situation, you SHOULD treat this payment as having succeeded.
270 public final static class PaymentSent extends Event {
272 * The id returned by [`ChannelManager::send_payment`] and used with
273 * [`ChannelManager::retry_payment`].
275 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
276 * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
278 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
280 @Nullable public final byte[] payment_id;
282 * The preimage to the hash given to ChannelManager::send_payment.
283 * Note that this serves as a payment receipt, if you wish to have such a thing, you must
286 public final byte[] payment_preimage;
288 * The hash that was given to [`ChannelManager::send_payment`].
290 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
292 public final byte[] payment_hash;
294 * The total fee which was spent at intermediate hops in this payment, across all paths.
296 * Note that, like [`Route::get_total_fees`] this does *not* include any potential
297 * overpayment to the recipient node.
299 * If the recipient or an intermediate node misbehaves and gives us free money, this may
300 * overstate the amount paid, though this is unlikely.
302 * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
304 public final org.ldk.structs.Option_u64Z fee_paid_msat;
305 private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
307 this.payment_id = obj.payment_id;
308 this.payment_preimage = obj.payment_preimage;
309 this.payment_hash = obj.payment_hash;
310 long fee_paid_msat = obj.fee_paid_msat;
311 org.ldk.structs.Option_u64Z fee_paid_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_paid_msat);
312 if (fee_paid_msat_hu_conv != null) { fee_paid_msat_hu_conv.ptrs_to.add(this); };
313 this.fee_paid_msat = fee_paid_msat_hu_conv;
317 * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
318 * provide failure information for each MPP part in the payment.
320 * This event is provided once there are no further pending HTLCs for the payment and the
321 * payment is no longer retryable due to [`ChannelManager::abandon_payment`] having been
322 * called for the corresponding payment.
324 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
326 public final static class PaymentFailed extends Event {
328 * The id returned by [`ChannelManager::send_payment`] and used with
329 * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
331 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
332 * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
333 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
335 public final byte[] payment_id;
337 * The hash that was given to [`ChannelManager::send_payment`].
339 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
341 public final byte[] payment_hash;
342 private PaymentFailed(long ptr, bindings.LDKEvent.PaymentFailed obj) {
344 this.payment_id = obj.payment_id;
345 this.payment_hash = obj.payment_hash;
349 * Indicates that a path for an outbound payment was successful.
351 * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
352 * [`Event::PaymentSent`] for obtaining the payment preimage.
354 public final static class PaymentPathSuccessful extends Event {
356 * The id returned by [`ChannelManager::send_payment`] and used with
357 * [`ChannelManager::retry_payment`].
359 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
360 * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
362 public final byte[] payment_id;
364 * The hash that was given to [`ChannelManager::send_payment`].
366 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
368 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
370 @Nullable public final byte[] payment_hash;
372 * The payment path that was successful.
374 * May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
376 public final RouteHop[] path;
377 private PaymentPathSuccessful(long ptr, bindings.LDKEvent.PaymentPathSuccessful obj) {
379 this.payment_id = obj.payment_id;
380 this.payment_hash = obj.payment_hash;
381 long[] path = obj.path;
382 int path_conv_10_len = path.length;
383 RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
384 for (int k = 0; k < path_conv_10_len; k++) {
385 long path_conv_10 = path[k];
386 org.ldk.structs.RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, path_conv_10); }
387 if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); };
388 path_conv_10_arr[k] = path_conv_10_hu_conv;
390 this.path = path_conv_10_arr;
394 * Indicates an outbound HTLC we sent failed. Probably some intermediary node dropped
395 * something. You may wish to retry with a different route.
397 * If you have given up retrying this payment and wish to fail it, you MUST call
398 * [`ChannelManager::abandon_payment`] at least once for a given [`PaymentId`] or memory
399 * related to payment tracking will leak.
401 * Note that this does *not* indicate that all paths for an MPP payment have failed, see
402 * [`Event::PaymentFailed`] and [`all_paths_failed`].
404 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
405 * [`all_paths_failed`]: Self::PaymentPathFailed::all_paths_failed
407 public final static class PaymentPathFailed extends Event {
409 * The id returned by [`ChannelManager::send_payment`] and used with
410 * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
412 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
413 * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
414 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
416 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
418 @Nullable public final byte[] payment_id;
420 * The hash that was given to [`ChannelManager::send_payment`].
422 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
424 public final byte[] payment_hash;
426 * Indicates the payment was rejected for some reason by the recipient. This implies that
427 * the payment has failed, not just the route in question. If this is not set, you may
428 * retry the payment via a different route.
430 public final boolean payment_failed_permanently;
432 * Any failure information conveyed via the Onion return packet by a node along the failed
435 * Should be applied to the [`NetworkGraph`] so that routing decisions can take into
436 * account the update.
438 * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
440 public final org.ldk.structs.Option_NetworkUpdateZ network_update;
442 * For both single-path and multi-path payments, this is set if all paths of the payment have
443 * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
444 * larger MPP payment were still in flight when this event was generated.
446 * Note that if you are retrying individual MPP parts, using this value to determine if a
447 * payment has fully failed is race-y. Because multiple failures can happen prior to events
448 * being processed, you may retry in response to a first failure, with a second failure
449 * (with `all_paths_failed` set) still pending. Then, when the second failure is processed
450 * you will see `all_paths_failed` set even though the retry of the first failure still
451 * has an associated in-flight HTLC. See (1) for an example of such a failure.
453 * If you wish to retry individual MPP parts and learn when a payment has failed, you must
454 * call [`ChannelManager::abandon_payment`] and wait for a [`Event::PaymentFailed`] event.
456 * (1) <https://github.com/lightningdevkit/rust-lightning/issues/1164>
458 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
460 public final boolean all_paths_failed;
462 * The payment path that failed.
464 public final RouteHop[] path;
466 * The channel responsible for the failed payment path.
468 * Note that for route hints or for the first hop in a path this may be an SCID alias and
469 * may not refer to a channel in the public network graph. These aliases may also collide
470 * with channels in the public network graph.
472 * If this is `Some`, then the corresponding channel should be avoided when the payment is
473 * retried. May be `None` for older [`Event`] serializations.
475 public final org.ldk.structs.Option_u64Z short_channel_id;
477 * Parameters needed to compute a new [`Route`] when retrying the failed payment path.
479 * See [`find_route`] for details.
481 * [`Route`]: crate::routing::router::Route
482 * [`find_route`]: crate::routing::router::find_route
484 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
486 @Nullable public final org.ldk.structs.RouteParameters retry;
487 private PaymentPathFailed(long ptr, bindings.LDKEvent.PaymentPathFailed obj) {
489 this.payment_id = obj.payment_id;
490 this.payment_hash = obj.payment_hash;
491 this.payment_failed_permanently = obj.payment_failed_permanently;
492 long network_update = obj.network_update;
493 org.ldk.structs.Option_NetworkUpdateZ network_update_hu_conv = org.ldk.structs.Option_NetworkUpdateZ.constr_from_ptr(network_update);
494 if (network_update_hu_conv != null) { network_update_hu_conv.ptrs_to.add(this); };
495 this.network_update = network_update_hu_conv;
496 this.all_paths_failed = obj.all_paths_failed;
497 long[] path = obj.path;
498 int path_conv_10_len = path.length;
499 RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
500 for (int k = 0; k < path_conv_10_len; k++) {
501 long path_conv_10 = path[k];
502 org.ldk.structs.RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, path_conv_10); }
503 if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); };
504 path_conv_10_arr[k] = path_conv_10_hu_conv;
506 this.path = path_conv_10_arr;
507 long short_channel_id = obj.short_channel_id;
508 org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id);
509 if (short_channel_id_hu_conv != null) { short_channel_id_hu_conv.ptrs_to.add(this); };
510 this.short_channel_id = short_channel_id_hu_conv;
511 long retry = obj.retry;
512 org.ldk.structs.RouteParameters retry_hu_conv = null; if (retry < 0 || retry > 4096) { retry_hu_conv = new org.ldk.structs.RouteParameters(null, retry); }
513 if (retry_hu_conv != null) { retry_hu_conv.ptrs_to.add(this); };
514 this.retry = retry_hu_conv;
518 * Indicates that a probe payment we sent returned successful, i.e., only failed at the destination.
520 public final static class ProbeSuccessful extends Event {
522 * The id returned by [`ChannelManager::send_probe`].
524 * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
526 public final byte[] payment_id;
528 * The hash generated by [`ChannelManager::send_probe`].
530 * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
532 public final byte[] payment_hash;
534 * The payment path that was successful.
536 public final RouteHop[] path;
537 private ProbeSuccessful(long ptr, bindings.LDKEvent.ProbeSuccessful obj) {
539 this.payment_id = obj.payment_id;
540 this.payment_hash = obj.payment_hash;
541 long[] path = obj.path;
542 int path_conv_10_len = path.length;
543 RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
544 for (int k = 0; k < path_conv_10_len; k++) {
545 long path_conv_10 = path[k];
546 org.ldk.structs.RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, path_conv_10); }
547 if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); };
548 path_conv_10_arr[k] = path_conv_10_hu_conv;
550 this.path = path_conv_10_arr;
554 * Indicates that a probe payment we sent failed at an intermediary node on the path.
556 public final static class ProbeFailed extends Event {
558 * The id returned by [`ChannelManager::send_probe`].
560 * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
562 public final byte[] payment_id;
564 * The hash generated by [`ChannelManager::send_probe`].
566 * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
568 public final byte[] payment_hash;
570 * The payment path that failed.
572 public final RouteHop[] path;
574 * The channel responsible for the failed probe.
576 * Note that for route hints or for the first hop in a path this may be an SCID alias and
577 * may not refer to a channel in the public network graph. These aliases may also collide
578 * with channels in the public network graph.
580 public final org.ldk.structs.Option_u64Z short_channel_id;
581 private ProbeFailed(long ptr, bindings.LDKEvent.ProbeFailed obj) {
583 this.payment_id = obj.payment_id;
584 this.payment_hash = obj.payment_hash;
585 long[] path = obj.path;
586 int path_conv_10_len = path.length;
587 RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
588 for (int k = 0; k < path_conv_10_len; k++) {
589 long path_conv_10 = path[k];
590 org.ldk.structs.RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, path_conv_10); }
591 if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); };
592 path_conv_10_arr[k] = path_conv_10_hu_conv;
594 this.path = path_conv_10_arr;
595 long short_channel_id = obj.short_channel_id;
596 org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id);
597 if (short_channel_id_hu_conv != null) { short_channel_id_hu_conv.ptrs_to.add(this); };
598 this.short_channel_id = short_channel_id_hu_conv;
602 * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
603 * a time in the future.
605 * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
607 public final static class PendingHTLCsForwardable extends Event {
609 * The minimum amount of time that should be waited prior to calling
610 * process_pending_htlc_forwards. To increase the effort required to correlate payments,
611 * you should wait a random amount of time in roughly the range (now + time_forwardable,
612 * now + 5*time_forwardable).
614 public final long time_forwardable;
615 private PendingHTLCsForwardable(long ptr, bindings.LDKEvent.PendingHTLCsForwardable obj) {
617 this.time_forwardable = obj.time_forwardable;
621 * Used to indicate that we've intercepted an HTLC forward. This event will only be generated if
622 * you've encoded an intercept scid in the receiver's invoice route hints using
623 * [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`].
625 * [`ChannelManager::forward_intercepted_htlc`] or
626 * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See
627 * their docs for more information.
629 * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
630 * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
631 * [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
632 * [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc
634 public final static class HTLCIntercepted extends Event {
636 * An id to help LDK identify which HTLC is being forwarded or failed.
638 public final byte[] intercept_id;
640 * The fake scid that was programmed as the next hop's scid, generated using
641 * [`ChannelManager::get_intercept_scid`].
643 * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
645 public final long requested_next_hop_scid;
647 * The payment hash used for this HTLC.
649 public final byte[] payment_hash;
651 * How many msats were received on the inbound edge of this HTLC.
653 public final long inbound_amount_msat;
655 * How many msats the payer intended to route to the next node. Depending on the reason you are
656 * intercepting this payment, you might take a fee by forwarding less than this amount.
658 * Note that LDK will NOT check that expected fees were factored into this value. You MUST
659 * check that whatever fee you want has been included here or subtract it as required. Further,
660 * LDK will not stop you from forwarding more than you received.
662 public final long expected_outbound_amount_msat;
663 private HTLCIntercepted(long ptr, bindings.LDKEvent.HTLCIntercepted obj) {
665 this.intercept_id = obj.intercept_id;
666 this.requested_next_hop_scid = obj.requested_next_hop_scid;
667 this.payment_hash = obj.payment_hash;
668 this.inbound_amount_msat = obj.inbound_amount_msat;
669 this.expected_outbound_amount_msat = obj.expected_outbound_amount_msat;
673 * Used to indicate that an output which you should know how to spend was confirmed on chain
674 * and is now spendable.
675 * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
676 * counterparty spending them due to some kind of timeout. Thus, you need to store them
677 * somewhere and spend them when you create on-chain transactions.
679 public final static class SpendableOutputs extends Event {
681 * The outputs which you should store as spendable by you.
683 public final SpendableOutputDescriptor[] outputs;
684 private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
686 long[] outputs = obj.outputs;
687 int outputs_conv_27_len = outputs.length;
688 SpendableOutputDescriptor[] outputs_conv_27_arr = new SpendableOutputDescriptor[outputs_conv_27_len];
689 for (int b = 0; b < outputs_conv_27_len; b++) {
690 long outputs_conv_27 = outputs[b];
691 org.ldk.structs.SpendableOutputDescriptor outputs_conv_27_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(outputs_conv_27);
692 if (outputs_conv_27_hu_conv != null) { outputs_conv_27_hu_conv.ptrs_to.add(this); };
693 outputs_conv_27_arr[b] = outputs_conv_27_hu_conv;
695 this.outputs = outputs_conv_27_arr;
699 * This event is generated when a payment has been successfully forwarded through us and a
700 * forwarding fee earned.
702 public final static class PaymentForwarded extends Event {
704 * The incoming channel between the previous node and us. This is only `None` for events
705 * generated or serialized by versions prior to 0.0.107.
707 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
709 @Nullable public final byte[] prev_channel_id;
711 * The outgoing channel between the next node and us. This is only `None` for events
712 * generated or serialized by versions prior to 0.0.107.
714 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
716 @Nullable public final byte[] next_channel_id;
718 * The fee, in milli-satoshis, which was earned as a result of the payment.
720 * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
721 * was pending, the amount the next hop claimed will have been rounded down to the nearest
722 * whole satoshi. Thus, the fee calculated here may be higher than expected as we still
723 * claimed the full value in millisatoshis from the source. In this case,
724 * `claim_from_onchain_tx` will be set.
726 * If the channel which sent us the payment has been force-closed, we will claim the funds
727 * via an on-chain transaction. In that case we do not yet know the on-chain transaction
728 * fees which we will spend and will instead set this to `None`. It is possible duplicate
729 * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
732 public final org.ldk.structs.Option_u64Z fee_earned_msat;
734 * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
737 public final boolean claim_from_onchain_tx;
738 private PaymentForwarded(long ptr, bindings.LDKEvent.PaymentForwarded obj) {
740 this.prev_channel_id = obj.prev_channel_id;
741 this.next_channel_id = obj.next_channel_id;
742 long fee_earned_msat = obj.fee_earned_msat;
743 org.ldk.structs.Option_u64Z fee_earned_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_earned_msat);
744 if (fee_earned_msat_hu_conv != null) { fee_earned_msat_hu_conv.ptrs_to.add(this); };
745 this.fee_earned_msat = fee_earned_msat_hu_conv;
746 this.claim_from_onchain_tx = obj.claim_from_onchain_tx;
750 * Used to indicate that a channel with the given `channel_id` is ready to
751 * be used. This event is emitted either when the funding transaction has been confirmed
752 * on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel
755 public final static class ChannelReady extends Event {
757 * The channel_id of the channel that is ready.
759 public final byte[] channel_id;
761 * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
762 * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
763 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
764 * `user_channel_id` will be randomized for an inbound channel.
766 * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
767 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
768 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
770 public final org.ldk.util.UInt128 user_channel_id;
772 * The node_id of the channel counterparty.
774 public final byte[] counterparty_node_id;
776 * The features that this channel will operate with.
778 public final org.ldk.structs.ChannelTypeFeatures channel_type;
779 private ChannelReady(long ptr, bindings.LDKEvent.ChannelReady obj) {
781 this.channel_id = obj.channel_id;
782 byte[] user_channel_id = obj.user_channel_id;
783 org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
784 this.user_channel_id = user_channel_id_conv;
785 this.counterparty_node_id = obj.counterparty_node_id;
786 long channel_type = obj.channel_type;
787 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); }
788 if (channel_type_hu_conv != null) { channel_type_hu_conv.ptrs_to.add(this); };
789 this.channel_type = channel_type_hu_conv;
793 * Used to indicate that a previously opened channel with the given `channel_id` is in the
794 * process of closure.
796 public final static class ChannelClosed extends Event {
798 * The channel_id of the channel which has been closed. Note that on-chain transactions
799 * resolving the channel are likely still awaiting confirmation.
801 public final byte[] channel_id;
803 * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
804 * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
805 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
806 * `user_channel_id` will be randomized for inbound channels.
807 * This may be zero for inbound channels serialized prior to 0.0.113 and will always be
808 * zero for objects serialized with LDK versions prior to 0.0.102.
810 * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
811 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
812 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
814 public final org.ldk.util.UInt128 user_channel_id;
816 * The reason the channel was closed.
818 public final org.ldk.structs.ClosureReason reason;
819 private ChannelClosed(long ptr, bindings.LDKEvent.ChannelClosed obj) {
821 this.channel_id = obj.channel_id;
822 byte[] user_channel_id = obj.user_channel_id;
823 org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
824 this.user_channel_id = user_channel_id_conv;
825 long reason = obj.reason;
826 org.ldk.structs.ClosureReason reason_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(reason);
827 if (reason_hu_conv != null) { reason_hu_conv.ptrs_to.add(this); };
828 this.reason = reason_hu_conv;
832 * Used to indicate to the user that they can abandon the funding transaction and recycle the
833 * inputs for another purpose.
835 public final static class DiscardFunding extends Event {
837 * The channel_id of the channel which has been closed.
839 public final byte[] channel_id;
841 * The full transaction received from the user
843 public final byte[] transaction;
844 private DiscardFunding(long ptr, bindings.LDKEvent.DiscardFunding obj) {
846 this.channel_id = obj.channel_id;
847 this.transaction = obj.transaction;
851 * Indicates a request to open a new channel by a peer.
853 * To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the
854 * request, call [`ChannelManager::force_close_without_broadcasting_txn`].
856 * The event is only triggered when a new open channel request is received and the
857 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
859 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
860 * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
861 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
863 public final static class OpenChannelRequest extends Event {
865 * The temporary channel ID of the channel requested to be opened.
867 * When responding to the request, the `temporary_channel_id` should be passed
868 * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
869 * or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
871 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
872 * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
874 public final byte[] temporary_channel_id;
876 * The node_id of the counterparty requesting to open the channel.
878 * When responding to the request, the `counterparty_node_id` should be passed
879 * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
880 * accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
883 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
884 * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
886 public final byte[] counterparty_node_id;
888 * The channel value of the requested channel.
890 public final long funding_satoshis;
892 * Our starting balance in the channel if the request is accepted, in milli-satoshi.
894 public final long push_msat;
896 * The features that this channel will operate with. If you reject the channel, a
897 * well-behaved counterparty may automatically re-attempt the channel with a new set of
900 * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
901 * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
904 * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
905 * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
906 * 0.0.107. Channels setting this type also need to get manually accepted via
907 * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`],
908 * or will be rejected otherwise.
910 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
912 public final org.ldk.structs.ChannelTypeFeatures channel_type;
913 private OpenChannelRequest(long ptr, bindings.LDKEvent.OpenChannelRequest obj) {
915 this.temporary_channel_id = obj.temporary_channel_id;
916 this.counterparty_node_id = obj.counterparty_node_id;
917 this.funding_satoshis = obj.funding_satoshis;
918 this.push_msat = obj.push_msat;
919 long channel_type = obj.channel_type;
920 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); }
921 if (channel_type_hu_conv != null) { channel_type_hu_conv.ptrs_to.add(this); };
922 this.channel_type = channel_type_hu_conv;
926 * Indicates that the HTLC was accepted, but could not be processed when or after attempting to
929 * Some scenarios where this event may be sent include:
930 * Insufficient capacity in the outbound channel
931 * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes
932 * When an unknown SCID is requested for forwarding a payment.
933 * Claiming an amount for an MPP payment that exceeds the HTLC total
934 * The HTLC has timed out
936 * This event, however, does not get generated if an HTLC fails to meet the forwarding
937 * requirements (i.e. insufficient fees paid, or a CLTV that is too soon).
939 public final static class HTLCHandlingFailed extends Event {
941 * The channel over which the HTLC was received.
943 public final byte[] prev_channel_id;
945 * Destination of the HTLC that failed to be processed.
947 public final org.ldk.structs.HTLCDestination failed_next_destination;
948 private HTLCHandlingFailed(long ptr, bindings.LDKEvent.HTLCHandlingFailed obj) {
950 this.prev_channel_id = obj.prev_channel_id;
951 long failed_next_destination = obj.failed_next_destination;
952 org.ldk.structs.HTLCDestination failed_next_destination_hu_conv = org.ldk.structs.HTLCDestination.constr_from_ptr(failed_next_destination);
953 if (failed_next_destination_hu_conv != null) { failed_next_destination_hu_conv.ptrs_to.add(this); };
954 this.failed_next_destination = failed_next_destination_hu_conv;
958 long ret = bindings.Event_clone_ptr(this.ptr);
959 Reference.reachabilityFence(this);
964 * Creates a copy of the Event
966 public Event clone() {
967 long ret = bindings.Event_clone(this.ptr);
968 Reference.reachabilityFence(this);
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.add(this); };
976 * Utility method to constructs a new FundingGenerationReady-variant Event
978 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) {
979 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());
980 Reference.reachabilityFence(temporary_channel_id);
981 Reference.reachabilityFence(counterparty_node_id);
982 Reference.reachabilityFence(channel_value_satoshis);
983 Reference.reachabilityFence(output_script);
984 Reference.reachabilityFence(user_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.add(ret_hu_conv); };
992 * Utility method to constructs a new PaymentClaimable-variant Event
994 public static Event payment_claimable(byte[] receiver_node_id, byte[] payment_hash, long amount_msat, org.ldk.structs.PaymentPurpose purpose, byte[] via_channel_id, org.ldk.structs.Option_u128Z via_user_channel_id) {
995 long ret = bindings.Event_payment_claimable(InternalUtils.check_arr_len(receiver_node_id, 33), InternalUtils.check_arr_len(payment_hash, 32), amount_msat, purpose.ptr, InternalUtils.check_arr_len(via_channel_id, 32), via_user_channel_id.ptr);
996 Reference.reachabilityFence(receiver_node_id);
997 Reference.reachabilityFence(payment_hash);
998 Reference.reachabilityFence(amount_msat);
999 Reference.reachabilityFence(purpose);
1000 Reference.reachabilityFence(via_channel_id);
1001 Reference.reachabilityFence(via_user_channel_id);
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.add(ret_hu_conv); };
1009 * Utility method to constructs a new PaymentClaimed-variant Event
1011 public static Event payment_claimed(byte[] receiver_node_id, byte[] payment_hash, long amount_msat, org.ldk.structs.PaymentPurpose purpose) {
1012 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);
1013 Reference.reachabilityFence(receiver_node_id);
1014 Reference.reachabilityFence(payment_hash);
1015 Reference.reachabilityFence(amount_msat);
1016 Reference.reachabilityFence(purpose);
1017 if (ret >= 0 && ret <= 4096) { return null; }
1018 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1019 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1024 * Utility method to constructs a new PaymentSent-variant Event
1026 public static Event payment_sent(byte[] payment_id, byte[] payment_preimage, byte[] payment_hash, org.ldk.structs.Option_u64Z fee_paid_msat) {
1027 long ret = bindings.Event_payment_sent(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_preimage, 32), InternalUtils.check_arr_len(payment_hash, 32), fee_paid_msat.ptr);
1028 Reference.reachabilityFence(payment_id);
1029 Reference.reachabilityFence(payment_preimage);
1030 Reference.reachabilityFence(payment_hash);
1031 Reference.reachabilityFence(fee_paid_msat);
1032 if (ret >= 0 && ret <= 4096) { return null; }
1033 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1034 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1039 * Utility method to constructs a new PaymentFailed-variant Event
1041 public static Event payment_failed(byte[] payment_id, byte[] payment_hash) {
1042 long ret = bindings.Event_payment_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32));
1043 Reference.reachabilityFence(payment_id);
1044 Reference.reachabilityFence(payment_hash);
1045 if (ret >= 0 && ret <= 4096) { return null; }
1046 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1047 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1052 * Utility method to constructs a new PaymentPathSuccessful-variant Event
1054 public static Event payment_path_successful(byte[] payment_id, byte[] payment_hash, RouteHop[] path) {
1055 long ret = bindings.Event_payment_path_successful(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr).toArray() : null);
1056 Reference.reachabilityFence(payment_id);
1057 Reference.reachabilityFence(payment_hash);
1058 Reference.reachabilityFence(path);
1059 if (ret >= 0 && ret <= 4096) { return null; }
1060 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1061 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1062 for (RouteHop path_conv_10: path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path_conv_10); }; };
1067 * Utility method to constructs a new PaymentPathFailed-variant Event
1069 public static Event payment_path_failed(byte[] payment_id, byte[] payment_hash, boolean payment_failed_permanently, org.ldk.structs.Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path, org.ldk.structs.Option_u64Z short_channel_id, org.ldk.structs.RouteParameters retry) {
1070 long ret = bindings.Event_payment_path_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), payment_failed_permanently, network_update.ptr, all_paths_failed, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr).toArray() : null, short_channel_id.ptr, retry == null ? 0 : retry.ptr);
1071 Reference.reachabilityFence(payment_id);
1072 Reference.reachabilityFence(payment_hash);
1073 Reference.reachabilityFence(payment_failed_permanently);
1074 Reference.reachabilityFence(network_update);
1075 Reference.reachabilityFence(all_paths_failed);
1076 Reference.reachabilityFence(path);
1077 Reference.reachabilityFence(short_channel_id);
1078 Reference.reachabilityFence(retry);
1079 if (ret >= 0 && ret <= 4096) { return null; }
1080 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1081 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1082 for (RouteHop path_conv_10: path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path_conv_10); }; };
1083 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry); };
1088 * Utility method to constructs a new ProbeSuccessful-variant Event
1090 public static Event probe_successful(byte[] payment_id, byte[] payment_hash, RouteHop[] path) {
1091 long ret = bindings.Event_probe_successful(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr).toArray() : null);
1092 Reference.reachabilityFence(payment_id);
1093 Reference.reachabilityFence(payment_hash);
1094 Reference.reachabilityFence(path);
1095 if (ret >= 0 && ret <= 4096) { return null; }
1096 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1097 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1098 for (RouteHop path_conv_10: path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path_conv_10); }; };
1103 * Utility method to constructs a new ProbeFailed-variant Event
1105 public static Event probe_failed(byte[] payment_id, byte[] payment_hash, RouteHop[] path, org.ldk.structs.Option_u64Z short_channel_id) {
1106 long ret = bindings.Event_probe_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr).toArray() : null, short_channel_id.ptr);
1107 Reference.reachabilityFence(payment_id);
1108 Reference.reachabilityFence(payment_hash);
1109 Reference.reachabilityFence(path);
1110 Reference.reachabilityFence(short_channel_id);
1111 if (ret >= 0 && ret <= 4096) { return null; }
1112 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1113 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1114 for (RouteHop path_conv_10: path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path_conv_10); }; };
1119 * Utility method to constructs a new PendingHTLCsForwardable-variant Event
1121 public static Event pending_htlcs_forwardable(long time_forwardable) {
1122 long ret = bindings.Event_pending_htlcs_forwardable(time_forwardable);
1123 Reference.reachabilityFence(time_forwardable);
1124 if (ret >= 0 && ret <= 4096) { return null; }
1125 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1126 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1131 * Utility method to constructs a new HTLCIntercepted-variant Event
1133 public static Event htlcintercepted(byte[] intercept_id, long requested_next_hop_scid, byte[] payment_hash, long inbound_amount_msat, long expected_outbound_amount_msat) {
1134 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);
1135 Reference.reachabilityFence(intercept_id);
1136 Reference.reachabilityFence(requested_next_hop_scid);
1137 Reference.reachabilityFence(payment_hash);
1138 Reference.reachabilityFence(inbound_amount_msat);
1139 Reference.reachabilityFence(expected_outbound_amount_msat);
1140 if (ret >= 0 && ret <= 4096) { return null; }
1141 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1142 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1147 * Utility method to constructs a new SpendableOutputs-variant Event
1149 public static Event spendable_outputs(SpendableOutputDescriptor[] outputs) {
1150 long ret = bindings.Event_spendable_outputs(outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_27 -> outputs_conv_27.ptr).toArray() : null);
1151 Reference.reachabilityFence(outputs);
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.add(ret_hu_conv); };
1159 * Utility method to constructs a new PaymentForwarded-variant Event
1161 public static Event payment_forwarded(byte[] prev_channel_id, byte[] next_channel_id, org.ldk.structs.Option_u64Z fee_earned_msat, boolean claim_from_onchain_tx) {
1162 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);
1163 Reference.reachabilityFence(prev_channel_id);
1164 Reference.reachabilityFence(next_channel_id);
1165 Reference.reachabilityFence(fee_earned_msat);
1166 Reference.reachabilityFence(claim_from_onchain_tx);
1167 if (ret >= 0 && ret <= 4096) { return null; }
1168 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1169 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1174 * Utility method to constructs a new ChannelReady-variant Event
1176 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) {
1177 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);
1178 Reference.reachabilityFence(channel_id);
1179 Reference.reachabilityFence(user_channel_id);
1180 Reference.reachabilityFence(counterparty_node_id);
1181 Reference.reachabilityFence(channel_type);
1182 if (ret >= 0 && ret <= 4096) { return null; }
1183 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1184 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1185 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type); };
1190 * Utility method to constructs a new ChannelClosed-variant Event
1192 public static Event channel_closed(byte[] channel_id, org.ldk.util.UInt128 user_channel_id, org.ldk.structs.ClosureReason reason) {
1193 long ret = bindings.Event_channel_closed(InternalUtils.check_arr_len(channel_id, 32), user_channel_id.getLEBytes(), reason.ptr);
1194 Reference.reachabilityFence(channel_id);
1195 Reference.reachabilityFence(user_channel_id);
1196 Reference.reachabilityFence(reason);
1197 if (ret >= 0 && ret <= 4096) { return null; }
1198 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1199 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1204 * Utility method to constructs a new DiscardFunding-variant Event
1206 public static Event discard_funding(byte[] channel_id, byte[] transaction) {
1207 long ret = bindings.Event_discard_funding(InternalUtils.check_arr_len(channel_id, 32), transaction);
1208 Reference.reachabilityFence(channel_id);
1209 Reference.reachabilityFence(transaction);
1210 if (ret >= 0 && ret <= 4096) { return null; }
1211 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1217 * Utility method to constructs a new OpenChannelRequest-variant Event
1219 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) {
1220 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);
1221 Reference.reachabilityFence(temporary_channel_id);
1222 Reference.reachabilityFence(counterparty_node_id);
1223 Reference.reachabilityFence(funding_satoshis);
1224 Reference.reachabilityFence(push_msat);
1225 Reference.reachabilityFence(channel_type);
1226 if (ret >= 0 && ret <= 4096) { return null; }
1227 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1228 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1229 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type); };
1234 * Utility method to constructs a new HTLCHandlingFailed-variant Event
1236 public static Event htlchandling_failed(byte[] prev_channel_id, org.ldk.structs.HTLCDestination failed_next_destination) {
1237 long ret = bindings.Event_htlchandling_failed(InternalUtils.check_arr_len(prev_channel_id, 32), failed_next_destination.ptr);
1238 Reference.reachabilityFence(prev_channel_id);
1239 Reference.reachabilityFence(failed_next_destination);
1240 if (ret >= 0 && ret <= 4096) { return null; }
1241 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1242 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1247 * Serialize the Event object into a byte array which can be read by Event_read
1249 public byte[] write() {
1250 byte[] ret = bindings.Event_write(this.ptr);
1251 Reference.reachabilityFence(this);