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`] or [`ChannelManager::fail_htlc_backwards_with_reason`]
143 * to free up resources for this HTLC and avoid network congestion.
144 * If you fail to call either [`ChannelManager::claim_funds`], [`ChannelManager::fail_htlc_backwards`],
145 * or [`ChannelManager::fail_htlc_backwards_with_reason`] 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
157 * [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason
159 public final static class PaymentClaimable extends Event {
161 * The node that will receive the payment after it has been claimed.
162 * This is useful to identify payments received via [phantom nodes].
163 * This field will always be filled in when the event was generated by LDK versions
166 * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager
168 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
170 @Nullable public final byte[] receiver_node_id;
172 * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
173 * not stop you from registering duplicate payment hashes for inbound payments.
175 public final byte[] payment_hash;
177 * The value, in thousandths of a satoshi, that this payment is for.
179 public final long amount_msat;
181 * Information for claiming this received payment, based on whether the purpose of the
182 * payment is to pay an invoice or to send a spontaneous payment.
184 public final org.ldk.structs.PaymentPurpose purpose;
186 * The `channel_id` indicating over which channel we received the payment.
188 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
190 @Nullable public final byte[] via_channel_id;
192 * The `user_channel_id` indicating over which channel we received the payment.
194 public final org.ldk.structs.Option_u128Z via_user_channel_id;
195 private PaymentClaimable(long ptr, bindings.LDKEvent.PaymentClaimable obj) {
197 this.receiver_node_id = obj.receiver_node_id;
198 this.payment_hash = obj.payment_hash;
199 this.amount_msat = obj.amount_msat;
200 long purpose = obj.purpose;
201 org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
202 if (purpose_hu_conv != null) { purpose_hu_conv.ptrs_to.add(this); };
203 this.purpose = purpose_hu_conv;
204 this.via_channel_id = obj.via_channel_id;
205 long via_user_channel_id = obj.via_user_channel_id;
206 org.ldk.structs.Option_u128Z via_user_channel_id_hu_conv = org.ldk.structs.Option_u128Z.constr_from_ptr(via_user_channel_id);
207 if (via_user_channel_id_hu_conv != null) { via_user_channel_id_hu_conv.ptrs_to.add(this); };
208 this.via_user_channel_id = via_user_channel_id_hu_conv;
212 * Indicates a payment has been claimed and we've received money!
214 * This most likely occurs when [`ChannelManager::claim_funds`] has been called in response
215 * to an [`Event::PaymentClaimable`]. However, if we previously crashed during a
216 * [`ChannelManager::claim_funds`] call you may see this event without a corresponding
217 * [`Event::PaymentClaimable`] event.
220 * LDK will not stop an inbound payment from being paid multiple times, so multiple
221 * `PaymentClaimable` events may be generated for the same payment. If you then call
222 * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get
223 * multiple `PaymentClaimed` events.
225 * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
227 public final static class PaymentClaimed extends Event {
229 * The node that received the payment.
230 * This is useful to identify payments which were received via [phantom nodes].
231 * This field will always be filled in when the event was generated by LDK versions
234 * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager
236 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
238 @Nullable public final byte[] receiver_node_id;
240 * The payment hash of the claimed payment. Note that LDK will not stop you from
241 * registering duplicate payment hashes for inbound payments.
243 public final byte[] payment_hash;
245 * The value, in thousandths of a satoshi, that this payment is for.
247 public final long amount_msat;
249 * The purpose of the claimed payment, i.e. whether the payment was for an invoice or a
250 * spontaneous payment.
252 public final org.ldk.structs.PaymentPurpose purpose;
253 private PaymentClaimed(long ptr, bindings.LDKEvent.PaymentClaimed obj) {
255 this.receiver_node_id = obj.receiver_node_id;
256 this.payment_hash = obj.payment_hash;
257 this.amount_msat = obj.amount_msat;
258 long purpose = obj.purpose;
259 org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
260 if (purpose_hu_conv != null) { purpose_hu_conv.ptrs_to.add(this); };
261 this.purpose = purpose_hu_conv;
265 * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
266 * and we got back the payment preimage for it).
268 * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
269 * event. In this situation, you SHOULD treat this payment as having succeeded.
271 public final static class PaymentSent extends Event {
273 * The id returned by [`ChannelManager::send_payment`].
275 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
277 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
279 @Nullable public final byte[] payment_id;
281 * The preimage to the hash given to ChannelManager::send_payment.
282 * Note that this serves as a payment receipt, if you wish to have such a thing, you must
285 public final byte[] payment_preimage;
287 * The hash that was given to [`ChannelManager::send_payment`].
289 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
291 public final byte[] payment_hash;
293 * The total fee which was spent at intermediate hops in this payment, across all paths.
295 * Note that, like [`Route::get_total_fees`] this does *not* include any potential
296 * overpayment to the recipient node.
298 * If the recipient or an intermediate node misbehaves and gives us free money, this may
299 * overstate the amount paid, though this is unlikely.
301 * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
303 public final org.ldk.structs.Option_u64Z fee_paid_msat;
304 private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
306 this.payment_id = obj.payment_id;
307 this.payment_preimage = obj.payment_preimage;
308 this.payment_hash = obj.payment_hash;
309 long fee_paid_msat = obj.fee_paid_msat;
310 org.ldk.structs.Option_u64Z fee_paid_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_paid_msat);
311 if (fee_paid_msat_hu_conv != null) { fee_paid_msat_hu_conv.ptrs_to.add(this); };
312 this.fee_paid_msat = fee_paid_msat_hu_conv;
316 * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
317 * provide failure information for each path attempt in the payment, including retries.
319 * This event is provided once there are no further pending HTLCs for the payment and the
320 * payment is no longer retryable, due either to the [`Retry`] provided or
321 * [`ChannelManager::abandon_payment`] having been called for the corresponding payment.
323 * [`Retry`]: crate::ln::channelmanager::Retry
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::abandon_payment`].
331 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
332 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
334 public final byte[] payment_id;
336 * The hash that was given to [`ChannelManager::send_payment`].
338 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
340 public final byte[] payment_hash;
341 private PaymentFailed(long ptr, bindings.LDKEvent.PaymentFailed obj) {
343 this.payment_id = obj.payment_id;
344 this.payment_hash = obj.payment_hash;
348 * Indicates that a path for an outbound payment was successful.
350 * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
351 * [`Event::PaymentSent`] for obtaining the payment preimage.
353 public final static class PaymentPathSuccessful extends Event {
355 * The id returned by [`ChannelManager::send_payment`].
357 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
359 public final byte[] payment_id;
361 * The hash that was given to [`ChannelManager::send_payment`].
363 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
365 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
367 @Nullable public final byte[] payment_hash;
369 * The payment path that was successful.
371 * May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
373 public final RouteHop[] path;
374 private PaymentPathSuccessful(long ptr, bindings.LDKEvent.PaymentPathSuccessful obj) {
376 this.payment_id = obj.payment_id;
377 this.payment_hash = obj.payment_hash;
378 long[] path = obj.path;
379 int path_conv_10_len = path.length;
380 RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
381 for (int k = 0; k < path_conv_10_len; k++) {
382 long path_conv_10 = path[k];
383 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); }
384 if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); };
385 path_conv_10_arr[k] = path_conv_10_hu_conv;
387 this.path = path_conv_10_arr;
391 * Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to
394 * Note that this does *not* indicate that all paths for an MPP payment have failed, see
395 * [`Event::PaymentFailed`].
397 * See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have
400 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
402 public final static class PaymentPathFailed extends Event {
404 * The id returned by [`ChannelManager::send_payment`] and used with
405 * [`ChannelManager::abandon_payment`].
407 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
408 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
410 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
412 @Nullable public final byte[] payment_id;
414 * The hash that was given to [`ChannelManager::send_payment`].
416 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
418 public final byte[] payment_hash;
420 * Indicates the payment was rejected for some reason by the recipient. This implies that
421 * the payment has failed, not just the route in question. If this is not set, the payment may
422 * be retried via a different route.
424 public final boolean payment_failed_permanently;
426 * Extra error details based on the failure type. May contain an update that needs to be
427 * applied to the [`NetworkGraph`].
429 * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
431 public final org.ldk.structs.PathFailure failure;
433 * The payment path that failed.
435 public final RouteHop[] path;
437 * The channel responsible for the failed payment path.
439 * Note that for route hints or for the first hop in a path this may be an SCID alias and
440 * may not refer to a channel in the public network graph. These aliases may also collide
441 * with channels in the public network graph.
443 * If this is `Some`, then the corresponding channel should be avoided when the payment is
444 * retried. May be `None` for older [`Event`] serializations.
446 public final org.ldk.structs.Option_u64Z short_channel_id;
448 * Parameters used by LDK to compute a new [`Route`] when retrying the failed payment path.
450 * [`Route`]: crate::routing::router::Route
452 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
454 @Nullable public final org.ldk.structs.RouteParameters retry;
455 private PaymentPathFailed(long ptr, bindings.LDKEvent.PaymentPathFailed obj) {
457 this.payment_id = obj.payment_id;
458 this.payment_hash = obj.payment_hash;
459 this.payment_failed_permanently = obj.payment_failed_permanently;
460 long failure = obj.failure;
461 org.ldk.structs.PathFailure failure_hu_conv = org.ldk.structs.PathFailure.constr_from_ptr(failure);
462 if (failure_hu_conv != null) { failure_hu_conv.ptrs_to.add(this); };
463 this.failure = failure_hu_conv;
464 long[] path = obj.path;
465 int path_conv_10_len = path.length;
466 RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
467 for (int k = 0; k < path_conv_10_len; k++) {
468 long path_conv_10 = path[k];
469 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); }
470 if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); };
471 path_conv_10_arr[k] = path_conv_10_hu_conv;
473 this.path = path_conv_10_arr;
474 long short_channel_id = obj.short_channel_id;
475 org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id);
476 if (short_channel_id_hu_conv != null) { short_channel_id_hu_conv.ptrs_to.add(this); };
477 this.short_channel_id = short_channel_id_hu_conv;
478 long retry = obj.retry;
479 org.ldk.structs.RouteParameters retry_hu_conv = null; if (retry < 0 || retry > 4096) { retry_hu_conv = new org.ldk.structs.RouteParameters(null, retry); }
480 if (retry_hu_conv != null) { retry_hu_conv.ptrs_to.add(this); };
481 this.retry = retry_hu_conv;
485 * Indicates that a probe payment we sent returned successful, i.e., only failed at the destination.
487 public final static class ProbeSuccessful extends Event {
489 * The id returned by [`ChannelManager::send_probe`].
491 * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
493 public final byte[] payment_id;
495 * The hash generated by [`ChannelManager::send_probe`].
497 * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
499 public final byte[] payment_hash;
501 * The payment path that was successful.
503 public final RouteHop[] path;
504 private ProbeSuccessful(long ptr, bindings.LDKEvent.ProbeSuccessful obj) {
506 this.payment_id = obj.payment_id;
507 this.payment_hash = obj.payment_hash;
508 long[] path = obj.path;
509 int path_conv_10_len = path.length;
510 RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
511 for (int k = 0; k < path_conv_10_len; k++) {
512 long path_conv_10 = path[k];
513 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); }
514 if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); };
515 path_conv_10_arr[k] = path_conv_10_hu_conv;
517 this.path = path_conv_10_arr;
521 * Indicates that a probe payment we sent failed at an intermediary node on the path.
523 public final static class ProbeFailed extends Event {
525 * The id returned by [`ChannelManager::send_probe`].
527 * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
529 public final byte[] payment_id;
531 * The hash generated by [`ChannelManager::send_probe`].
533 * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
535 public final byte[] payment_hash;
537 * The payment path that failed.
539 public final RouteHop[] path;
541 * The channel responsible for the failed probe.
543 * Note that for route hints or for the first hop in a path this may be an SCID alias and
544 * may not refer to a channel in the public network graph. These aliases may also collide
545 * with channels in the public network graph.
547 public final org.ldk.structs.Option_u64Z short_channel_id;
548 private ProbeFailed(long ptr, bindings.LDKEvent.ProbeFailed obj) {
550 this.payment_id = obj.payment_id;
551 this.payment_hash = obj.payment_hash;
552 long[] path = obj.path;
553 int path_conv_10_len = path.length;
554 RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
555 for (int k = 0; k < path_conv_10_len; k++) {
556 long path_conv_10 = path[k];
557 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); }
558 if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); };
559 path_conv_10_arr[k] = path_conv_10_hu_conv;
561 this.path = path_conv_10_arr;
562 long short_channel_id = obj.short_channel_id;
563 org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id);
564 if (short_channel_id_hu_conv != null) { short_channel_id_hu_conv.ptrs_to.add(this); };
565 this.short_channel_id = short_channel_id_hu_conv;
569 * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
570 * a time in the future.
572 * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
574 public final static class PendingHTLCsForwardable extends Event {
576 * The minimum amount of time that should be waited prior to calling
577 * process_pending_htlc_forwards. To increase the effort required to correlate payments,
578 * you should wait a random amount of time in roughly the range (now + time_forwardable,
579 * now + 5*time_forwardable).
581 public final long time_forwardable;
582 private PendingHTLCsForwardable(long ptr, bindings.LDKEvent.PendingHTLCsForwardable obj) {
584 this.time_forwardable = obj.time_forwardable;
588 * Used to indicate that we've intercepted an HTLC forward. This event will only be generated if
589 * you've encoded an intercept scid in the receiver's invoice route hints using
590 * [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`].
592 * [`ChannelManager::forward_intercepted_htlc`] or
593 * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See
594 * their docs for more information.
596 * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
597 * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
598 * [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
599 * [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc
601 public final static class HTLCIntercepted extends Event {
603 * An id to help LDK identify which HTLC is being forwarded or failed.
605 public final byte[] intercept_id;
607 * The fake scid that was programmed as the next hop's scid, generated using
608 * [`ChannelManager::get_intercept_scid`].
610 * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
612 public final long requested_next_hop_scid;
614 * The payment hash used for this HTLC.
616 public final byte[] payment_hash;
618 * How many msats were received on the inbound edge of this HTLC.
620 public final long inbound_amount_msat;
622 * How many msats the payer intended to route to the next node. Depending on the reason you are
623 * intercepting this payment, you might take a fee by forwarding less than this amount.
625 * Note that LDK will NOT check that expected fees were factored into this value. You MUST
626 * check that whatever fee you want has been included here or subtract it as required. Further,
627 * LDK will not stop you from forwarding more than you received.
629 public final long expected_outbound_amount_msat;
630 private HTLCIntercepted(long ptr, bindings.LDKEvent.HTLCIntercepted obj) {
632 this.intercept_id = obj.intercept_id;
633 this.requested_next_hop_scid = obj.requested_next_hop_scid;
634 this.payment_hash = obj.payment_hash;
635 this.inbound_amount_msat = obj.inbound_amount_msat;
636 this.expected_outbound_amount_msat = obj.expected_outbound_amount_msat;
640 * Used to indicate that an output which you should know how to spend was confirmed on chain
641 * and is now spendable.
642 * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
643 * counterparty spending them due to some kind of timeout. Thus, you need to store them
644 * somewhere and spend them when you create on-chain transactions.
646 public final static class SpendableOutputs extends Event {
648 * The outputs which you should store as spendable by you.
650 public final SpendableOutputDescriptor[] outputs;
651 private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
653 long[] outputs = obj.outputs;
654 int outputs_conv_27_len = outputs.length;
655 SpendableOutputDescriptor[] outputs_conv_27_arr = new SpendableOutputDescriptor[outputs_conv_27_len];
656 for (int b = 0; b < outputs_conv_27_len; b++) {
657 long outputs_conv_27 = outputs[b];
658 org.ldk.structs.SpendableOutputDescriptor outputs_conv_27_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(outputs_conv_27);
659 if (outputs_conv_27_hu_conv != null) { outputs_conv_27_hu_conv.ptrs_to.add(this); };
660 outputs_conv_27_arr[b] = outputs_conv_27_hu_conv;
662 this.outputs = outputs_conv_27_arr;
666 * This event is generated when a payment has been successfully forwarded through us and a
667 * forwarding fee earned.
669 public final static class PaymentForwarded extends Event {
671 * The incoming channel between the previous node and us. This is only `None` for events
672 * generated or serialized by versions prior to 0.0.107.
674 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
676 @Nullable public final byte[] prev_channel_id;
678 * The outgoing channel between the next node and us. This is only `None` for events
679 * generated or serialized by versions prior to 0.0.107.
681 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
683 @Nullable public final byte[] next_channel_id;
685 * The fee, in milli-satoshis, which was earned as a result of the payment.
687 * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
688 * was pending, the amount the next hop claimed will have been rounded down to the nearest
689 * whole satoshi. Thus, the fee calculated here may be higher than expected as we still
690 * claimed the full value in millisatoshis from the source. In this case,
691 * `claim_from_onchain_tx` will be set.
693 * If the channel which sent us the payment has been force-closed, we will claim the funds
694 * via an on-chain transaction. In that case we do not yet know the on-chain transaction
695 * fees which we will spend and will instead set this to `None`. It is possible duplicate
696 * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
699 public final org.ldk.structs.Option_u64Z fee_earned_msat;
701 * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
704 public final boolean claim_from_onchain_tx;
705 private PaymentForwarded(long ptr, bindings.LDKEvent.PaymentForwarded obj) {
707 this.prev_channel_id = obj.prev_channel_id;
708 this.next_channel_id = obj.next_channel_id;
709 long fee_earned_msat = obj.fee_earned_msat;
710 org.ldk.structs.Option_u64Z fee_earned_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_earned_msat);
711 if (fee_earned_msat_hu_conv != null) { fee_earned_msat_hu_conv.ptrs_to.add(this); };
712 this.fee_earned_msat = fee_earned_msat_hu_conv;
713 this.claim_from_onchain_tx = obj.claim_from_onchain_tx;
717 * Used to indicate that a channel with the given `channel_id` is ready to
718 * be used. This event is emitted either when the funding transaction has been confirmed
719 * on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel
722 public final static class ChannelReady extends Event {
724 * The channel_id of the channel that is ready.
726 public final byte[] channel_id;
728 * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
729 * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
730 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
731 * `user_channel_id` will be randomized for an inbound channel.
733 * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
734 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
735 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
737 public final org.ldk.util.UInt128 user_channel_id;
739 * The node_id of the channel counterparty.
741 public final byte[] counterparty_node_id;
743 * The features that this channel will operate with.
745 public final org.ldk.structs.ChannelTypeFeatures channel_type;
746 private ChannelReady(long ptr, bindings.LDKEvent.ChannelReady obj) {
748 this.channel_id = obj.channel_id;
749 byte[] user_channel_id = obj.user_channel_id;
750 org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
751 this.user_channel_id = user_channel_id_conv;
752 this.counterparty_node_id = obj.counterparty_node_id;
753 long channel_type = obj.channel_type;
754 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); }
755 if (channel_type_hu_conv != null) { channel_type_hu_conv.ptrs_to.add(this); };
756 this.channel_type = channel_type_hu_conv;
760 * Used to indicate that a previously opened channel with the given `channel_id` is in the
761 * process of closure.
763 public final static class ChannelClosed extends Event {
765 * The channel_id of the channel which has been closed. Note that on-chain transactions
766 * resolving the channel are likely still awaiting confirmation.
768 public final byte[] channel_id;
770 * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
771 * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
772 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
773 * `user_channel_id` will be randomized for inbound channels.
774 * This may be zero for inbound channels serialized prior to 0.0.113 and will always be
775 * zero for objects serialized with LDK versions prior to 0.0.102.
777 * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
778 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
779 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
781 public final org.ldk.util.UInt128 user_channel_id;
783 * The reason the channel was closed.
785 public final org.ldk.structs.ClosureReason reason;
786 private ChannelClosed(long ptr, bindings.LDKEvent.ChannelClosed obj) {
788 this.channel_id = obj.channel_id;
789 byte[] user_channel_id = obj.user_channel_id;
790 org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id);
791 this.user_channel_id = user_channel_id_conv;
792 long reason = obj.reason;
793 org.ldk.structs.ClosureReason reason_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(reason);
794 if (reason_hu_conv != null) { reason_hu_conv.ptrs_to.add(this); };
795 this.reason = reason_hu_conv;
799 * Used to indicate to the user that they can abandon the funding transaction and recycle the
800 * inputs for another purpose.
802 public final static class DiscardFunding extends Event {
804 * The channel_id of the channel which has been closed.
806 public final byte[] channel_id;
808 * The full transaction received from the user
810 public final byte[] transaction;
811 private DiscardFunding(long ptr, bindings.LDKEvent.DiscardFunding obj) {
813 this.channel_id = obj.channel_id;
814 this.transaction = obj.transaction;
818 * Indicates a request to open a new channel by a peer.
820 * To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the
821 * request, call [`ChannelManager::force_close_without_broadcasting_txn`].
823 * The event is only triggered when a new open channel request is received and the
824 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
826 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
827 * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
828 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
830 public final static class OpenChannelRequest extends Event {
832 * The temporary channel ID of the channel requested to be opened.
834 * When responding to the request, the `temporary_channel_id` should be passed
835 * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
836 * or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
838 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
839 * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
841 public final byte[] temporary_channel_id;
843 * The node_id of the counterparty requesting to open the channel.
845 * When responding to the request, the `counterparty_node_id` should be passed
846 * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
847 * accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
850 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
851 * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
853 public final byte[] counterparty_node_id;
855 * The channel value of the requested channel.
857 public final long funding_satoshis;
859 * Our starting balance in the channel if the request is accepted, in milli-satoshi.
861 public final long push_msat;
863 * The features that this channel will operate with. If you reject the channel, a
864 * well-behaved counterparty may automatically re-attempt the channel with a new set of
867 * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
868 * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
871 * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
872 * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
873 * 0.0.107. Channels setting this type also need to get manually accepted via
874 * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`],
875 * or will be rejected otherwise.
877 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
879 public final org.ldk.structs.ChannelTypeFeatures channel_type;
880 private OpenChannelRequest(long ptr, bindings.LDKEvent.OpenChannelRequest obj) {
882 this.temporary_channel_id = obj.temporary_channel_id;
883 this.counterparty_node_id = obj.counterparty_node_id;
884 this.funding_satoshis = obj.funding_satoshis;
885 this.push_msat = obj.push_msat;
886 long channel_type = obj.channel_type;
887 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); }
888 if (channel_type_hu_conv != null) { channel_type_hu_conv.ptrs_to.add(this); };
889 this.channel_type = channel_type_hu_conv;
893 * Indicates that the HTLC was accepted, but could not be processed when or after attempting to
896 * Some scenarios where this event may be sent include:
897 * Insufficient capacity in the outbound channel
898 * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes
899 * When an unknown SCID is requested for forwarding a payment.
900 * Claiming an amount for an MPP payment that exceeds the HTLC total
901 * The HTLC has timed out
903 * This event, however, does not get generated if an HTLC fails to meet the forwarding
904 * requirements (i.e. insufficient fees paid, or a CLTV that is too soon).
906 public final static class HTLCHandlingFailed extends Event {
908 * The channel over which the HTLC was received.
910 public final byte[] prev_channel_id;
912 * Destination of the HTLC that failed to be processed.
914 public final org.ldk.structs.HTLCDestination failed_next_destination;
915 private HTLCHandlingFailed(long ptr, bindings.LDKEvent.HTLCHandlingFailed obj) {
917 this.prev_channel_id = obj.prev_channel_id;
918 long failed_next_destination = obj.failed_next_destination;
919 org.ldk.structs.HTLCDestination failed_next_destination_hu_conv = org.ldk.structs.HTLCDestination.constr_from_ptr(failed_next_destination);
920 if (failed_next_destination_hu_conv != null) { failed_next_destination_hu_conv.ptrs_to.add(this); };
921 this.failed_next_destination = failed_next_destination_hu_conv;
925 long ret = bindings.Event_clone_ptr(this.ptr);
926 Reference.reachabilityFence(this);
931 * Creates a copy of the Event
933 public Event clone() {
934 long ret = bindings.Event_clone(this.ptr);
935 Reference.reachabilityFence(this);
936 if (ret >= 0 && ret <= 4096) { return null; }
937 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
938 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
943 * Utility method to constructs a new FundingGenerationReady-variant Event
945 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) {
946 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());
947 Reference.reachabilityFence(temporary_channel_id);
948 Reference.reachabilityFence(counterparty_node_id);
949 Reference.reachabilityFence(channel_value_satoshis);
950 Reference.reachabilityFence(output_script);
951 Reference.reachabilityFence(user_channel_id);
952 if (ret >= 0 && ret <= 4096) { return null; }
953 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
954 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
959 * Utility method to constructs a new PaymentClaimable-variant Event
961 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) {
962 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);
963 Reference.reachabilityFence(receiver_node_id);
964 Reference.reachabilityFence(payment_hash);
965 Reference.reachabilityFence(amount_msat);
966 Reference.reachabilityFence(purpose);
967 Reference.reachabilityFence(via_channel_id);
968 Reference.reachabilityFence(via_user_channel_id);
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(ret_hu_conv); };
972 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(purpose); };
973 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(via_user_channel_id); };
978 * Utility method to constructs a new PaymentClaimed-variant Event
980 public static Event payment_claimed(byte[] receiver_node_id, byte[] payment_hash, long amount_msat, org.ldk.structs.PaymentPurpose purpose) {
981 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);
982 Reference.reachabilityFence(receiver_node_id);
983 Reference.reachabilityFence(payment_hash);
984 Reference.reachabilityFence(amount_msat);
985 Reference.reachabilityFence(purpose);
986 if (ret >= 0 && ret <= 4096) { return null; }
987 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
988 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
989 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(purpose); };
994 * Utility method to constructs a new PaymentSent-variant Event
996 public static Event payment_sent(byte[] payment_id, byte[] payment_preimage, byte[] payment_hash, org.ldk.structs.Option_u64Z fee_paid_msat) {
997 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);
998 Reference.reachabilityFence(payment_id);
999 Reference.reachabilityFence(payment_preimage);
1000 Reference.reachabilityFence(payment_hash);
1001 Reference.reachabilityFence(fee_paid_msat);
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); };
1005 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_paid_msat); };
1010 * Utility method to constructs a new PaymentFailed-variant Event
1012 public static Event payment_failed(byte[] payment_id, byte[] payment_hash) {
1013 long ret = bindings.Event_payment_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32));
1014 Reference.reachabilityFence(payment_id);
1015 Reference.reachabilityFence(payment_hash);
1016 if (ret >= 0 && ret <= 4096) { return null; }
1017 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1018 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1023 * Utility method to constructs a new PaymentPathSuccessful-variant Event
1025 public static Event payment_path_successful(byte[] payment_id, byte[] payment_hash, RouteHop[] path) {
1026 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);
1027 Reference.reachabilityFence(payment_id);
1028 Reference.reachabilityFence(payment_hash);
1029 Reference.reachabilityFence(path);
1030 if (ret >= 0 && ret <= 4096) { return null; }
1031 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1032 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1033 for (RouteHop path_conv_10: path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path_conv_10); }; };
1038 * Utility method to constructs a new PaymentPathFailed-variant Event
1040 public static Event payment_path_failed(byte[] payment_id, byte[] payment_hash, boolean payment_failed_permanently, org.ldk.structs.PathFailure failure, RouteHop[] path, org.ldk.structs.Option_u64Z short_channel_id, org.ldk.structs.RouteParameters retry) {
1041 long ret = bindings.Event_payment_path_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), payment_failed_permanently, failure.ptr, 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);
1042 Reference.reachabilityFence(payment_id);
1043 Reference.reachabilityFence(payment_hash);
1044 Reference.reachabilityFence(payment_failed_permanently);
1045 Reference.reachabilityFence(failure);
1046 Reference.reachabilityFence(path);
1047 Reference.reachabilityFence(short_channel_id);
1048 Reference.reachabilityFence(retry);
1049 if (ret >= 0 && ret <= 4096) { return null; }
1050 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1051 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1052 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(failure); };
1053 for (RouteHop path_conv_10: path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path_conv_10); }; };
1054 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(short_channel_id); };
1055 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry); };
1060 * Utility method to constructs a new ProbeSuccessful-variant Event
1062 public static Event probe_successful(byte[] payment_id, byte[] payment_hash, RouteHop[] path) {
1063 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);
1064 Reference.reachabilityFence(payment_id);
1065 Reference.reachabilityFence(payment_hash);
1066 Reference.reachabilityFence(path);
1067 if (ret >= 0 && ret <= 4096) { return null; }
1068 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1069 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1070 for (RouteHop path_conv_10: path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path_conv_10); }; };
1075 * Utility method to constructs a new ProbeFailed-variant Event
1077 public static Event probe_failed(byte[] payment_id, byte[] payment_hash, RouteHop[] path, org.ldk.structs.Option_u64Z short_channel_id) {
1078 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);
1079 Reference.reachabilityFence(payment_id);
1080 Reference.reachabilityFence(payment_hash);
1081 Reference.reachabilityFence(path);
1082 Reference.reachabilityFence(short_channel_id);
1083 if (ret >= 0 && ret <= 4096) { return null; }
1084 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1085 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1086 for (RouteHop path_conv_10: path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path_conv_10); }; };
1087 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(short_channel_id); };
1092 * Utility method to constructs a new PendingHTLCsForwardable-variant Event
1094 public static Event pending_htlcs_forwardable(long time_forwardable) {
1095 long ret = bindings.Event_pending_htlcs_forwardable(time_forwardable);
1096 Reference.reachabilityFence(time_forwardable);
1097 if (ret >= 0 && ret <= 4096) { return null; }
1098 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1099 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1104 * Utility method to constructs a new HTLCIntercepted-variant Event
1106 public static Event htlcintercepted(byte[] intercept_id, long requested_next_hop_scid, byte[] payment_hash, long inbound_amount_msat, long expected_outbound_amount_msat) {
1107 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);
1108 Reference.reachabilityFence(intercept_id);
1109 Reference.reachabilityFence(requested_next_hop_scid);
1110 Reference.reachabilityFence(payment_hash);
1111 Reference.reachabilityFence(inbound_amount_msat);
1112 Reference.reachabilityFence(expected_outbound_amount_msat);
1113 if (ret >= 0 && ret <= 4096) { return null; }
1114 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1115 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1120 * Utility method to constructs a new SpendableOutputs-variant Event
1122 public static Event spendable_outputs(SpendableOutputDescriptor[] outputs) {
1123 long ret = bindings.Event_spendable_outputs(outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_27 -> outputs_conv_27.ptr).toArray() : null);
1124 Reference.reachabilityFence(outputs);
1125 if (ret >= 0 && ret <= 4096) { return null; }
1126 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1127 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1128 for (SpendableOutputDescriptor outputs_conv_27: outputs) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outputs_conv_27); }; };
1133 * Utility method to constructs a new PaymentForwarded-variant Event
1135 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) {
1136 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);
1137 Reference.reachabilityFence(prev_channel_id);
1138 Reference.reachabilityFence(next_channel_id);
1139 Reference.reachabilityFence(fee_earned_msat);
1140 Reference.reachabilityFence(claim_from_onchain_tx);
1141 if (ret >= 0 && ret <= 4096) { return null; }
1142 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1143 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1144 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_earned_msat); };
1149 * Utility method to constructs a new ChannelReady-variant Event
1151 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) {
1152 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);
1153 Reference.reachabilityFence(channel_id);
1154 Reference.reachabilityFence(user_channel_id);
1155 Reference.reachabilityFence(counterparty_node_id);
1156 Reference.reachabilityFence(channel_type);
1157 if (ret >= 0 && ret <= 4096) { return null; }
1158 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1159 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1160 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type); };
1165 * Utility method to constructs a new ChannelClosed-variant Event
1167 public static Event channel_closed(byte[] channel_id, org.ldk.util.UInt128 user_channel_id, org.ldk.structs.ClosureReason reason) {
1168 long ret = bindings.Event_channel_closed(InternalUtils.check_arr_len(channel_id, 32), user_channel_id.getLEBytes(), reason.ptr);
1169 Reference.reachabilityFence(channel_id);
1170 Reference.reachabilityFence(user_channel_id);
1171 Reference.reachabilityFence(reason);
1172 if (ret >= 0 && ret <= 4096) { return null; }
1173 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1174 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1175 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(reason); };
1180 * Utility method to constructs a new DiscardFunding-variant Event
1182 public static Event discard_funding(byte[] channel_id, byte[] transaction) {
1183 long ret = bindings.Event_discard_funding(InternalUtils.check_arr_len(channel_id, 32), transaction);
1184 Reference.reachabilityFence(channel_id);
1185 Reference.reachabilityFence(transaction);
1186 if (ret >= 0 && ret <= 4096) { return null; }
1187 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1188 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1193 * Utility method to constructs a new OpenChannelRequest-variant Event
1195 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) {
1196 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);
1197 Reference.reachabilityFence(temporary_channel_id);
1198 Reference.reachabilityFence(counterparty_node_id);
1199 Reference.reachabilityFence(funding_satoshis);
1200 Reference.reachabilityFence(push_msat);
1201 Reference.reachabilityFence(channel_type);
1202 if (ret >= 0 && ret <= 4096) { return null; }
1203 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1204 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1205 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type); };
1210 * Utility method to constructs a new HTLCHandlingFailed-variant Event
1212 public static Event htlchandling_failed(byte[] prev_channel_id, org.ldk.structs.HTLCDestination failed_next_destination) {
1213 long ret = bindings.Event_htlchandling_failed(InternalUtils.check_arr_len(prev_channel_id, 32), failed_next_destination.ptr);
1214 Reference.reachabilityFence(prev_channel_id);
1215 Reference.reachabilityFence(failed_next_destination);
1216 if (ret >= 0 && ret <= 4096) { return null; }
1217 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
1218 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
1219 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(failed_next_destination); };
1224 * Checks if two Events contain equal inner contents.
1225 * This ignores pointers and is_owned flags and looks at the values in fields.
1227 public boolean eq(org.ldk.structs.Event b) {
1228 boolean ret = bindings.Event_eq(this.ptr, b == null ? 0 : b.ptr);
1229 Reference.reachabilityFence(this);
1230 Reference.reachabilityFence(b);
1234 @Override public boolean equals(Object o) {
1235 if (!(o instanceof Event)) return false;
1236 return this.eq((Event)o);
1239 * Serialize the Event object into a byte array which can be read by Event_read
1241 public byte[] write() {
1242 byte[] ret = bindings.Event_write(this.ptr);
1243 Reference.reachabilityFence(this);