+ /**
+ * This event is generated when a payment has been successfully forwarded through us and a
+ * forwarding fee earned.
+ */
+ public final static class PaymentForwarded extends Event {
+ /**
+ * The fee, in milli-satoshis, which was earned as a result of the payment.
+ *
+ * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
+ * was pending, the amount the next hop claimed will have been rounded down to the nearest
+ * whole satoshi. Thus, the fee calculated here may be higher than expected as we still
+ * claimed the full value in millisatoshis from the source. In this case,
+ * `claim_from_onchain_tx` will be set.
+ *
+ * If the channel which sent us the payment has been force-closed, we will claim the funds
+ * via an on-chain transaction. In that case we do not yet know the on-chain transaction
+ * fees which we will spend and will instead set this to `None`. It is possible duplicate
+ * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
+ * `None`.
+ */
+ public final Option_u64Z fee_earned_msat;
+ /**
+ * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
+ * transaction.
+ */
+ public final boolean claim_from_onchain_tx;
+ private PaymentForwarded(long ptr, bindings.LDKEvent.PaymentForwarded obj) {
+ super(null, ptr);
+ long fee_earned_msat = obj.fee_earned_msat;
+ Option_u64Z fee_earned_msat_hu_conv = Option_u64Z.constr_from_ptr(fee_earned_msat);
+ fee_earned_msat_hu_conv.ptrs_to.add(this);
+ this.fee_earned_msat = fee_earned_msat_hu_conv;
+ this.claim_from_onchain_tx = obj.claim_from_onchain_tx;
+ }
+ }
+ /**
+ * Used to indicate that a channel with the given `channel_id` is in the process of closure.
+ */
+ public final static class ChannelClosed extends Event {
+ /**
+ * The channel_id of the channel which has been closed. Note that on-chain transactions
+ * resolving the channel are likely still awaiting confirmation.
+ */
+ public final byte[] channel_id;
+ /**
+ * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
+ * an inbound channel. This will always be zero for objects serialized with LDK versions
+ * prior to 0.0.102.
+ *
+ * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+ */
+ public final long user_channel_id;
+ /**
+ * The reason the channel was closed.
+ */
+ public final ClosureReason reason;
+ private ChannelClosed(long ptr, bindings.LDKEvent.ChannelClosed obj) {
+ super(null, ptr);
+ this.channel_id = obj.channel_id;
+ this.user_channel_id = obj.user_channel_id;
+ long reason = obj.reason;
+ ClosureReason reason_hu_conv = ClosureReason.constr_from_ptr(reason);
+ reason_hu_conv.ptrs_to.add(this);
+ this.reason = reason_hu_conv;
+ }
+ }
+ /**
+ * Used to indicate to the user that they can abandon the funding transaction and recycle the
+ * inputs for another purpose.
+ */
+ public final static class DiscardFunding extends Event {
+ /**
+ * The channel_id of the channel which has been closed.
+ */
+ public final byte[] channel_id;
+ /**
+ * The full transaction received from the user
+ */
+ public final byte[] transaction;
+ private DiscardFunding(long ptr, bindings.LDKEvent.DiscardFunding obj) {
+ super(null, ptr);
+ this.channel_id = obj.channel_id;
+ this.transaction = obj.transaction;
+ }
+ }
+ long clone_ptr() {
+ long ret = bindings.Event_clone_ptr(this.ptr);
+ return ret;
+ }
+
+ /**
+ * Creates a copy of the Event
+ */
+ public Event clone() {
+ long ret = bindings.Event_clone(this.ptr);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(this);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new FundingGenerationReady-variant Event
+ */
+ public static Event funding_generation_ready(byte[] temporary_channel_id, long channel_value_satoshis, byte[] output_script, long user_channel_id) {
+ long ret = bindings.Event_funding_generation_ready(InternalUtils.check_arr_len(temporary_channel_id, 32), channel_value_satoshis, output_script, user_channel_id);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new PaymentReceived-variant Event
+ */
+ public static Event payment_received(byte[] payment_hash, long amt, PaymentPurpose purpose) {
+ long ret = bindings.Event_payment_received(InternalUtils.check_arr_len(payment_hash, 32), amt, purpose.ptr);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new PaymentSent-variant Event
+ */
+ public static Event payment_sent(byte[] payment_id, byte[] payment_preimage, byte[] payment_hash, Option_u64Z fee_paid_msat) {
+ 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);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new PaymentPathFailed-variant Event
+ */
+ 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) {
+ 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);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new PendingHTLCsForwardable-variant Event
+ */
+ public static Event pending_htlcs_forwardable(long time_forwardable) {
+ long ret = bindings.Event_pending_htlcs_forwardable(time_forwardable);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new SpendableOutputs-variant Event
+ */
+ public static Event spendable_outputs(SpendableOutputDescriptor[] outputs) {
+ long ret = bindings.Event_spendable_outputs(outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_27 -> outputs_conv_27.ptr).toArray() : null);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new PaymentForwarded-variant Event
+ */
+ public static Event payment_forwarded(Option_u64Z fee_earned_msat, boolean claim_from_onchain_tx) {
+ long ret = bindings.Event_payment_forwarded(fee_earned_msat.ptr, claim_from_onchain_tx);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new ChannelClosed-variant Event
+ */
+ public static Event channel_closed(byte[] channel_id, long user_channel_id, ClosureReason reason) {
+ long ret = bindings.Event_channel_closed(InternalUtils.check_arr_len(channel_id, 32), user_channel_id, reason.ptr);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new DiscardFunding-variant Event
+ */
+ public static Event discard_funding(byte[] channel_id, byte[] transaction) {
+ long ret = bindings.Event_discard_funding(InternalUtils.check_arr_len(channel_id, 32), transaction);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Serialize the Event object into a byte array which can be read by Event_read
+ */
+ public byte[] write() {
+ byte[] ret = bindings.Event_write(this.ptr);
+ return ret;
+ }
+