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.PaymentReceived.class) {
32 return new PaymentReceived(ptr, (bindings.LDKEvent.PaymentReceived)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.PendingHTLCsForwardable.class) {
50 return new PendingHTLCsForwardable(ptr, (bindings.LDKEvent.PendingHTLCsForwardable)raw_val);
52 if (raw_val.getClass() == bindings.LDKEvent.SpendableOutputs.class) {
53 return new SpendableOutputs(ptr, (bindings.LDKEvent.SpendableOutputs)raw_val);
55 if (raw_val.getClass() == bindings.LDKEvent.PaymentForwarded.class) {
56 return new PaymentForwarded(ptr, (bindings.LDKEvent.PaymentForwarded)raw_val);
58 if (raw_val.getClass() == bindings.LDKEvent.ChannelClosed.class) {
59 return new ChannelClosed(ptr, (bindings.LDKEvent.ChannelClosed)raw_val);
61 if (raw_val.getClass() == bindings.LDKEvent.DiscardFunding.class) {
62 return new DiscardFunding(ptr, (bindings.LDKEvent.DiscardFunding)raw_val);
64 if (raw_val.getClass() == bindings.LDKEvent.OpenChannelRequest.class) {
65 return new OpenChannelRequest(ptr, (bindings.LDKEvent.OpenChannelRequest)raw_val);
67 assert false; return null; // Unreachable without extending the (internal) bindings interface
71 * Used to indicate that the client should generate a funding transaction with the given
72 * parameters and then call [`ChannelManager::funding_transaction_generated`].
73 * Generated in [`ChannelManager`] message handling.
74 * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
75 * counterparty can steal your funds!
77 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
78 * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
80 public final static class FundingGenerationReady extends Event {
82 * The random channel_id we picked which you'll need to pass into
83 * [`ChannelManager::funding_transaction_generated`].
85 * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
87 public final byte[] temporary_channel_id;
89 * The counterparty's node_id, which you'll need to pass back into
90 * [`ChannelManager::funding_transaction_generated`].
92 * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
94 public final byte[] counterparty_node_id;
96 * The value, in satoshis, that the output should have.
98 public final long channel_value_satoshis;
100 * The script which should be used in the transaction output.
102 public final byte[] output_script;
104 * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
105 * an inbound channel.
107 * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
109 public final long user_channel_id;
110 private FundingGenerationReady(long ptr, bindings.LDKEvent.FundingGenerationReady obj) {
112 this.temporary_channel_id = obj.temporary_channel_id;
113 this.counterparty_node_id = obj.counterparty_node_id;
114 this.channel_value_satoshis = obj.channel_value_satoshis;
115 this.output_script = obj.output_script;
116 this.user_channel_id = obj.user_channel_id;
120 * Indicates we've received (an offer of) money! Just gotta dig out that payment preimage and
121 * feed it to [`ChannelManager::claim_funds`] to get it....
123 * Note that if the preimage is not known, you should call
124 * [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid
125 * network congestion.
126 * If you fail to call either [`ChannelManager::claim_funds`] or
127 * [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be
128 * automatically failed.
131 * LDK will not stop an inbound payment from being paid multiple times, so multiple
132 * `PaymentReceived` events may be generated for the same payment.
134 * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
135 * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
137 public final static class PaymentReceived extends Event {
139 * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
140 * not stop you from registering duplicate payment hashes for inbound payments.
142 public final byte[] payment_hash;
144 * The value, in thousandths of a satoshi, that this payment is for.
146 public final long amount_msat;
148 * Information for claiming this received payment, based on whether the purpose of the
149 * payment is to pay an invoice or to send a spontaneous payment.
151 public final org.ldk.structs.PaymentPurpose purpose;
152 private PaymentReceived(long ptr, bindings.LDKEvent.PaymentReceived obj) {
154 this.payment_hash = obj.payment_hash;
155 this.amount_msat = obj.amount_msat;
156 long purpose = obj.purpose;
157 org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
158 purpose_hu_conv.ptrs_to.add(this);
159 this.purpose = purpose_hu_conv;
163 * Indicates a payment has been claimed and we've received money!
165 * This most likely occurs when [`ChannelManager::claim_funds`] has been called in response
166 * to an [`Event::PaymentReceived`]. However, if we previously crashed during a
167 * [`ChannelManager::claim_funds`] call you may see this event without a corresponding
168 * [`Event::PaymentReceived`] event.
171 * LDK will not stop an inbound payment from being paid multiple times, so multiple
172 * `PaymentReceived` events may be generated for the same payment. If you then call
173 * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentReceived`] you may get
174 * multiple `PaymentClaimed` events.
176 * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
178 public final static class PaymentClaimed extends Event {
180 * The payment hash of the claimed payment. Note that LDK will not stop you from
181 * registering duplicate payment hashes for inbound payments.
183 public final byte[] payment_hash;
185 * The value, in thousandths of a satoshi, that this payment is for.
187 public final long amount_msat;
189 * The purpose of this claimed payment, i.e. whether the payment was for an invoice or a
190 * spontaneous payment.
192 public final org.ldk.structs.PaymentPurpose purpose;
193 private PaymentClaimed(long ptr, bindings.LDKEvent.PaymentClaimed obj) {
195 this.payment_hash = obj.payment_hash;
196 this.amount_msat = obj.amount_msat;
197 long purpose = obj.purpose;
198 org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose);
199 purpose_hu_conv.ptrs_to.add(this);
200 this.purpose = purpose_hu_conv;
204 * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
205 * and we got back the payment preimage for it).
207 * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
208 * event. In this situation, you SHOULD treat this payment as having succeeded.
210 public final static class PaymentSent extends Event {
212 * The id returned by [`ChannelManager::send_payment`] and used with
213 * [`ChannelManager::retry_payment`].
215 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
216 * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
218 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
220 @Nullable public final byte[] payment_id;
222 * The preimage to the hash given to ChannelManager::send_payment.
223 * Note that this serves as a payment receipt, if you wish to have such a thing, you must
226 public final byte[] payment_preimage;
228 * The hash that was given to [`ChannelManager::send_payment`].
230 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
232 public final byte[] payment_hash;
234 * The total fee which was spent at intermediate hops in this payment, across all paths.
236 * Note that, like [`Route::get_total_fees`] this does *not* include any potential
237 * overpayment to the recipient node.
239 * If the recipient or an intermediate node misbehaves and gives us free money, this may
240 * overstate the amount paid, though this is unlikely.
242 * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
244 public final org.ldk.structs.Option_u64Z fee_paid_msat;
245 private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
247 this.payment_id = obj.payment_id;
248 this.payment_preimage = obj.payment_preimage;
249 this.payment_hash = obj.payment_hash;
250 long fee_paid_msat = obj.fee_paid_msat;
251 org.ldk.structs.Option_u64Z fee_paid_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_paid_msat);
252 fee_paid_msat_hu_conv.ptrs_to.add(this);
253 this.fee_paid_msat = fee_paid_msat_hu_conv;
257 * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
258 * provide failure information for each MPP part in the payment.
260 * This event is provided once there are no further pending HTLCs for the payment and the
261 * payment is no longer retryable, either due to a several-block timeout or because
262 * [`ChannelManager::abandon_payment`] was previously called for the corresponding payment.
264 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
266 public final static class PaymentFailed extends Event {
268 * The id returned by [`ChannelManager::send_payment`] and used with
269 * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
271 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
272 * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
273 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
275 public final byte[] payment_id;
277 * The hash that was given to [`ChannelManager::send_payment`].
279 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
281 public final byte[] payment_hash;
282 private PaymentFailed(long ptr, bindings.LDKEvent.PaymentFailed obj) {
284 this.payment_id = obj.payment_id;
285 this.payment_hash = obj.payment_hash;
289 * Indicates that a path for an outbound payment was successful.
291 * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
292 * [`Event::PaymentSent`] for obtaining the payment preimage.
294 public final static class PaymentPathSuccessful extends Event {
296 * The id returned by [`ChannelManager::send_payment`] and used with
297 * [`ChannelManager::retry_payment`].
299 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
300 * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
302 public final byte[] payment_id;
304 * The hash that was given to [`ChannelManager::send_payment`].
306 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
308 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
310 @Nullable public final byte[] payment_hash;
312 * The payment path that was successful.
314 * May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
316 public final RouteHop[] path;
317 private PaymentPathSuccessful(long ptr, bindings.LDKEvent.PaymentPathSuccessful obj) {
319 this.payment_id = obj.payment_id;
320 this.payment_hash = obj.payment_hash;
321 long[] path = obj.path;
322 int path_conv_10_len = path.length;
323 RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
324 for (int k = 0; k < path_conv_10_len; k++) {
325 long path_conv_10 = path[k];
326 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); }
327 path_conv_10_hu_conv.ptrs_to.add(this);
328 path_conv_10_arr[k] = path_conv_10_hu_conv;
330 this.path = path_conv_10_arr;
334 * Indicates an outbound HTLC we sent failed. Probably some intermediary node dropped
335 * something. You may wish to retry with a different route.
337 * Note that this does *not* indicate that all paths for an MPP payment have failed, see
338 * [`Event::PaymentFailed`] and [`all_paths_failed`].
340 * [`all_paths_failed`]: Self::PaymentPathFailed::all_paths_failed
342 public final static class PaymentPathFailed extends Event {
344 * The id returned by [`ChannelManager::send_payment`] and used with
345 * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
347 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
348 * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
349 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
351 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
353 @Nullable public final byte[] payment_id;
355 * The hash that was given to [`ChannelManager::send_payment`].
357 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
359 public final byte[] payment_hash;
361 * Indicates the payment was rejected for some reason by the recipient. This implies that
362 * the payment has failed, not just the route in question. If this is not set, you may
363 * retry the payment via a different route.
365 public final boolean rejected_by_dest;
367 * Any failure information conveyed via the Onion return packet by a node along the failed
370 * Should be applied to the [`NetworkGraph`] so that routing decisions can take into
371 * account the update.
373 * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
375 public final org.ldk.structs.Option_NetworkUpdateZ network_update;
377 * For both single-path and multi-path payments, this is set if all paths of the payment have
378 * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
379 * larger MPP payment were still in flight when this event was generated.
381 * Note that if you are retrying individual MPP parts, using this value to determine if a
382 * payment has fully failed is race-y. Because multiple failures can happen prior to events
383 * being processed, you may retry in response to a first failure, with a second failure
384 * (with `all_paths_failed` set) still pending. Then, when the second failure is processed
385 * you will see `all_paths_failed` set even though the retry of the first failure still
386 * has an associated in-flight HTLC. See (1) for an example of such a failure.
388 * If you wish to retry individual MPP parts and learn when a payment has failed, you must
389 * call [`ChannelManager::abandon_payment`] and wait for a [`Event::PaymentFailed`] event.
391 * (1) <https://github.com/lightningdevkit/rust-lightning/issues/1164>
393 * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
395 public final boolean all_paths_failed;
397 * The payment path that failed.
399 public final RouteHop[] path;
401 * The channel responsible for the failed payment path.
403 * Note that for route hints or for the first hop in a path this may be an SCID alias and
404 * may not refer to a channel in the public network graph. These aliases may also collide
405 * with channels in the public network graph.
407 * If this is `Some`, then the corresponding channel should be avoided when the payment is
408 * retried. May be `None` for older [`Event`] serializations.
410 public final org.ldk.structs.Option_u64Z short_channel_id;
412 * Parameters needed to compute a new [`Route`] when retrying the failed payment path.
414 * See [`find_route`] for details.
416 * [`Route`]: crate::routing::router::Route
417 * [`find_route`]: crate::routing::router::find_route
419 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
421 @Nullable public final org.ldk.structs.RouteParameters retry;
422 private PaymentPathFailed(long ptr, bindings.LDKEvent.PaymentPathFailed obj) {
424 this.payment_id = obj.payment_id;
425 this.payment_hash = obj.payment_hash;
426 this.rejected_by_dest = obj.rejected_by_dest;
427 long network_update = obj.network_update;
428 org.ldk.structs.Option_NetworkUpdateZ network_update_hu_conv = org.ldk.structs.Option_NetworkUpdateZ.constr_from_ptr(network_update);
429 network_update_hu_conv.ptrs_to.add(this);
430 this.network_update = network_update_hu_conv;
431 this.all_paths_failed = obj.all_paths_failed;
432 long[] path = obj.path;
433 int path_conv_10_len = path.length;
434 RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len];
435 for (int k = 0; k < path_conv_10_len; k++) {
436 long path_conv_10 = path[k];
437 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); }
438 path_conv_10_hu_conv.ptrs_to.add(this);
439 path_conv_10_arr[k] = path_conv_10_hu_conv;
441 this.path = path_conv_10_arr;
442 long short_channel_id = obj.short_channel_id;
443 org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id);
444 short_channel_id_hu_conv.ptrs_to.add(this);
445 this.short_channel_id = short_channel_id_hu_conv;
446 long retry = obj.retry;
447 org.ldk.structs.RouteParameters retry_hu_conv = null; if (retry < 0 || retry > 4096) { retry_hu_conv = new org.ldk.structs.RouteParameters(null, retry); }
448 retry_hu_conv.ptrs_to.add(this);
449 this.retry = retry_hu_conv;
453 * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
454 * a time in the future.
456 * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
458 public final static class PendingHTLCsForwardable extends Event {
460 * The minimum amount of time that should be waited prior to calling
461 * process_pending_htlc_forwards. To increase the effort required to correlate payments,
462 * you should wait a random amount of time in roughly the range (now + time_forwardable,
463 * now + 5*time_forwardable).
465 public final long time_forwardable;
466 private PendingHTLCsForwardable(long ptr, bindings.LDKEvent.PendingHTLCsForwardable obj) {
468 this.time_forwardable = obj.time_forwardable;
472 * Used to indicate that an output which you should know how to spend was confirmed on chain
473 * and is now spendable.
474 * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
475 * counterparty spending them due to some kind of timeout. Thus, you need to store them
476 * somewhere and spend them when you create on-chain transactions.
478 public final static class SpendableOutputs extends Event {
480 * The outputs which you should store as spendable by you.
482 public final SpendableOutputDescriptor[] outputs;
483 private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
485 long[] outputs = obj.outputs;
486 int outputs_conv_27_len = outputs.length;
487 SpendableOutputDescriptor[] outputs_conv_27_arr = new SpendableOutputDescriptor[outputs_conv_27_len];
488 for (int b = 0; b < outputs_conv_27_len; b++) {
489 long outputs_conv_27 = outputs[b];
490 org.ldk.structs.SpendableOutputDescriptor outputs_conv_27_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(outputs_conv_27);
491 outputs_conv_27_hu_conv.ptrs_to.add(this);
492 outputs_conv_27_arr[b] = outputs_conv_27_hu_conv;
494 this.outputs = outputs_conv_27_arr;
498 * This event is generated when a payment has been successfully forwarded through us and a
499 * forwarding fee earned.
501 public final static class PaymentForwarded extends Event {
503 * The incoming channel between the previous node and us. This is only `None` for events
504 * generated or serialized by versions prior to 0.0.107.
506 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
508 @Nullable public final byte[] prev_channel_id;
510 * The outgoing channel between the next node and us. This is only `None` for events
511 * generated or serialized by versions prior to 0.0.107.
513 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
515 @Nullable public final byte[] next_channel_id;
517 * The fee, in milli-satoshis, which was earned as a result of the payment.
519 * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
520 * was pending, the amount the next hop claimed will have been rounded down to the nearest
521 * whole satoshi. Thus, the fee calculated here may be higher than expected as we still
522 * claimed the full value in millisatoshis from the source. In this case,
523 * `claim_from_onchain_tx` will be set.
525 * If the channel which sent us the payment has been force-closed, we will claim the funds
526 * via an on-chain transaction. In that case we do not yet know the on-chain transaction
527 * fees which we will spend and will instead set this to `None`. It is possible duplicate
528 * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
531 public final org.ldk.structs.Option_u64Z fee_earned_msat;
533 * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
536 public final boolean claim_from_onchain_tx;
537 private PaymentForwarded(long ptr, bindings.LDKEvent.PaymentForwarded obj) {
539 this.prev_channel_id = obj.prev_channel_id;
540 this.next_channel_id = obj.next_channel_id;
541 long fee_earned_msat = obj.fee_earned_msat;
542 org.ldk.structs.Option_u64Z fee_earned_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(fee_earned_msat);
543 fee_earned_msat_hu_conv.ptrs_to.add(this);
544 this.fee_earned_msat = fee_earned_msat_hu_conv;
545 this.claim_from_onchain_tx = obj.claim_from_onchain_tx;
549 * Used to indicate that a previously opened channel with the given `channel_id` is in the
550 * process of closure.
552 public final static class ChannelClosed extends Event {
554 * The channel_id of the channel which has been closed. Note that on-chain transactions
555 * resolving the channel are likely still awaiting confirmation.
557 public final byte[] channel_id;
559 * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
560 * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
561 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
562 * `user_channel_id` will be 0 for an inbound channel.
563 * This will always be zero for objects serialized with LDK versions prior to 0.0.102.
565 * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
566 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
567 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
569 public final long user_channel_id;
571 * The reason the channel was closed.
573 public final org.ldk.structs.ClosureReason reason;
574 private ChannelClosed(long ptr, bindings.LDKEvent.ChannelClosed obj) {
576 this.channel_id = obj.channel_id;
577 this.user_channel_id = obj.user_channel_id;
578 long reason = obj.reason;
579 org.ldk.structs.ClosureReason reason_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(reason);
580 reason_hu_conv.ptrs_to.add(this);
581 this.reason = reason_hu_conv;
585 * Used to indicate to the user that they can abandon the funding transaction and recycle the
586 * inputs for another purpose.
588 public final static class DiscardFunding extends Event {
590 * The channel_id of the channel which has been closed.
592 public final byte[] channel_id;
594 * The full transaction received from the user
596 public final byte[] transaction;
597 private DiscardFunding(long ptr, bindings.LDKEvent.DiscardFunding obj) {
599 this.channel_id = obj.channel_id;
600 this.transaction = obj.transaction;
604 * Indicates a request to open a new channel by a peer.
606 * To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the
607 * request, call [`ChannelManager::force_close_channel`].
609 * The event is only triggered when a new open channel request is received and the
610 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
612 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
613 * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
614 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
616 public final static class OpenChannelRequest extends Event {
618 * The temporary channel ID of the channel requested to be opened.
620 * When responding to the request, the `temporary_channel_id` should be passed
621 * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
622 * or through [`ChannelManager::force_close_channel`] to reject.
624 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
625 * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
627 public final byte[] temporary_channel_id;
629 * The node_id of the counterparty requesting to open the channel.
631 * When responding to the request, the `counterparty_node_id` should be passed
632 * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
633 * accept the request, or through [`ChannelManager::force_close_channel`] to reject the
636 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
637 * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
639 public final byte[] counterparty_node_id;
641 * The channel value of the requested channel.
643 public final long funding_satoshis;
645 * Our starting balance in the channel if the request is accepted, in milli-satoshi.
647 public final long push_msat;
649 * The features that this channel will operate with. If you reject the channel, a
650 * well-behaved counterparty may automatically re-attempt the channel with a new set of
653 * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
654 * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
657 * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
658 * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
659 * 0.0.107. Channels setting this type also need to get manually accepted via
660 * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`],
661 * or will be rejected otherwise.
663 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
665 public final org.ldk.structs.ChannelTypeFeatures channel_type;
666 private OpenChannelRequest(long ptr, bindings.LDKEvent.OpenChannelRequest obj) {
668 this.temporary_channel_id = obj.temporary_channel_id;
669 this.counterparty_node_id = obj.counterparty_node_id;
670 this.funding_satoshis = obj.funding_satoshis;
671 this.push_msat = obj.push_msat;
672 long channel_type = obj.channel_type;
673 org.ldk.structs.ChannelTypeFeatures channel_type_hu_conv = null; if (channel_type < 0 || channel_type > 4096) { channel_type_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, channel_type); }
674 channel_type_hu_conv.ptrs_to.add(this);
675 this.channel_type = channel_type_hu_conv;
679 long ret = bindings.Event_clone_ptr(this.ptr);
680 Reference.reachabilityFence(this);
685 * Creates a copy of the Event
687 public Event clone() {
688 long ret = bindings.Event_clone(this.ptr);
689 Reference.reachabilityFence(this);
690 if (ret >= 0 && ret <= 4096) { return null; }
691 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
692 ret_hu_conv.ptrs_to.add(this);
697 * Utility method to constructs a new FundingGenerationReady-variant Event
699 public static Event funding_generation_ready(byte[] temporary_channel_id, byte[] counterparty_node_id, long channel_value_satoshis, byte[] output_script, long user_channel_id) {
700 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);
701 Reference.reachabilityFence(temporary_channel_id);
702 Reference.reachabilityFence(counterparty_node_id);
703 Reference.reachabilityFence(channel_value_satoshis);
704 Reference.reachabilityFence(output_script);
705 Reference.reachabilityFence(user_channel_id);
706 if (ret >= 0 && ret <= 4096) { return null; }
707 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
708 ret_hu_conv.ptrs_to.add(ret_hu_conv);
713 * Utility method to constructs a new PaymentReceived-variant Event
715 public static Event payment_received(byte[] payment_hash, long amount_msat, PaymentPurpose purpose) {
716 long ret = bindings.Event_payment_received(InternalUtils.check_arr_len(payment_hash, 32), amount_msat, purpose.ptr);
717 Reference.reachabilityFence(payment_hash);
718 Reference.reachabilityFence(amount_msat);
719 Reference.reachabilityFence(purpose);
720 if (ret >= 0 && ret <= 4096) { return null; }
721 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
722 ret_hu_conv.ptrs_to.add(ret_hu_conv);
727 * Utility method to constructs a new PaymentClaimed-variant Event
729 public static Event payment_claimed(byte[] payment_hash, long amount_msat, PaymentPurpose purpose) {
730 long ret = bindings.Event_payment_claimed(InternalUtils.check_arr_len(payment_hash, 32), amount_msat, purpose.ptr);
731 Reference.reachabilityFence(payment_hash);
732 Reference.reachabilityFence(amount_msat);
733 Reference.reachabilityFence(purpose);
734 if (ret >= 0 && ret <= 4096) { return null; }
735 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
736 ret_hu_conv.ptrs_to.add(ret_hu_conv);
741 * Utility method to constructs a new PaymentSent-variant Event
743 public static Event payment_sent(byte[] payment_id, byte[] payment_preimage, byte[] payment_hash, Option_u64Z fee_paid_msat) {
744 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);
745 Reference.reachabilityFence(payment_id);
746 Reference.reachabilityFence(payment_preimage);
747 Reference.reachabilityFence(payment_hash);
748 Reference.reachabilityFence(fee_paid_msat);
749 if (ret >= 0 && ret <= 4096) { return null; }
750 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
751 ret_hu_conv.ptrs_to.add(ret_hu_conv);
756 * Utility method to constructs a new PaymentFailed-variant Event
758 public static Event payment_failed(byte[] payment_id, byte[] payment_hash) {
759 long ret = bindings.Event_payment_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32));
760 Reference.reachabilityFence(payment_id);
761 Reference.reachabilityFence(payment_hash);
762 if (ret >= 0 && ret <= 4096) { return null; }
763 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
764 ret_hu_conv.ptrs_to.add(ret_hu_conv);
769 * Utility method to constructs a new PaymentPathSuccessful-variant Event
771 public static Event payment_path_successful(byte[] payment_id, byte[] payment_hash, RouteHop[] path) {
772 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 & ~1).toArray() : null);
773 Reference.reachabilityFence(payment_id);
774 Reference.reachabilityFence(payment_hash);
775 Reference.reachabilityFence(path);
776 if (ret >= 0 && ret <= 4096) { return null; }
777 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
778 ret_hu_conv.ptrs_to.add(ret_hu_conv);
783 * Utility method to constructs a new PaymentPathFailed-variant Event
785 public static Event payment_path_failed(byte[] payment_id, byte[] payment_hash, boolean rejected_by_dest, Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path, Option_u64Z short_channel_id, RouteParameters retry) {
786 long ret = bindings.Event_payment_path_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), rejected_by_dest, network_update.ptr, all_paths_failed, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray() : null, short_channel_id.ptr, retry == null ? 0 : retry.ptr & ~1);
787 Reference.reachabilityFence(payment_id);
788 Reference.reachabilityFence(payment_hash);
789 Reference.reachabilityFence(rejected_by_dest);
790 Reference.reachabilityFence(network_update);
791 Reference.reachabilityFence(all_paths_failed);
792 Reference.reachabilityFence(path);
793 Reference.reachabilityFence(short_channel_id);
794 Reference.reachabilityFence(retry);
795 if (ret >= 0 && ret <= 4096) { return null; }
796 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
797 ret_hu_conv.ptrs_to.add(ret_hu_conv);
802 * Utility method to constructs a new PendingHTLCsForwardable-variant Event
804 public static Event pending_htlcs_forwardable(long time_forwardable) {
805 long ret = bindings.Event_pending_htlcs_forwardable(time_forwardable);
806 Reference.reachabilityFence(time_forwardable);
807 if (ret >= 0 && ret <= 4096) { return null; }
808 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
809 ret_hu_conv.ptrs_to.add(ret_hu_conv);
814 * Utility method to constructs a new SpendableOutputs-variant Event
816 public static Event spendable_outputs(SpendableOutputDescriptor[] outputs) {
817 long ret = bindings.Event_spendable_outputs(outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_27 -> outputs_conv_27.ptr).toArray() : null);
818 Reference.reachabilityFence(outputs);
819 if (ret >= 0 && ret <= 4096) { return null; }
820 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
821 ret_hu_conv.ptrs_to.add(ret_hu_conv);
826 * Utility method to constructs a new PaymentForwarded-variant Event
828 public static Event payment_forwarded(byte[] prev_channel_id, byte[] next_channel_id, Option_u64Z fee_earned_msat, boolean claim_from_onchain_tx) {
829 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);
830 Reference.reachabilityFence(prev_channel_id);
831 Reference.reachabilityFence(next_channel_id);
832 Reference.reachabilityFence(fee_earned_msat);
833 Reference.reachabilityFence(claim_from_onchain_tx);
834 if (ret >= 0 && ret <= 4096) { return null; }
835 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
836 ret_hu_conv.ptrs_to.add(ret_hu_conv);
841 * Utility method to constructs a new ChannelClosed-variant Event
843 public static Event channel_closed(byte[] channel_id, long user_channel_id, ClosureReason reason) {
844 long ret = bindings.Event_channel_closed(InternalUtils.check_arr_len(channel_id, 32), user_channel_id, reason.ptr);
845 Reference.reachabilityFence(channel_id);
846 Reference.reachabilityFence(user_channel_id);
847 Reference.reachabilityFence(reason);
848 if (ret >= 0 && ret <= 4096) { return null; }
849 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
850 ret_hu_conv.ptrs_to.add(ret_hu_conv);
855 * Utility method to constructs a new DiscardFunding-variant Event
857 public static Event discard_funding(byte[] channel_id, byte[] transaction) {
858 long ret = bindings.Event_discard_funding(InternalUtils.check_arr_len(channel_id, 32), transaction);
859 Reference.reachabilityFence(channel_id);
860 Reference.reachabilityFence(transaction);
861 if (ret >= 0 && ret <= 4096) { return null; }
862 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
863 ret_hu_conv.ptrs_to.add(ret_hu_conv);
868 * Utility method to constructs a new OpenChannelRequest-variant Event
870 public static Event open_channel_request(byte[] temporary_channel_id, byte[] counterparty_node_id, long funding_satoshis, long push_msat, ChannelTypeFeatures channel_type) {
871 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 & ~1);
872 Reference.reachabilityFence(temporary_channel_id);
873 Reference.reachabilityFence(counterparty_node_id);
874 Reference.reachabilityFence(funding_satoshis);
875 Reference.reachabilityFence(push_msat);
876 Reference.reachabilityFence(channel_type);
877 if (ret >= 0 && ret <= 4096) { return null; }
878 org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret);
879 ret_hu_conv.ptrs_to.add(ret_hu_conv);
884 * Serialize the Event object into a byte array which can be read by Event_read
886 public byte[] write() {
887 byte[] ret = bindings.Event_write(this.ptr);
888 Reference.reachabilityFence(this);