X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FEvent.cs;fp=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FEvent.cs;h=bf9bb5202fa461431476bc7a850aa3003a74bfbc;hb=c6777737ea14e7814b0fa7d6fe16536f31d4a82b;hp=3c3d9c13b23d9611f4dbdf056749a197a534b15f;hpb=ee72c84d4bf9e2404e02fe20155efb502ceaee1b;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/Event.cs b/c_sharp/src/org/ldk/structs/Event.cs index 3c3d9c13..bf9bb520 100644 --- a/c_sharp/src/org/ldk/structs/Event.cs +++ b/c_sharp/src/org/ldk/structs/Event.cs @@ -34,11 +34,13 @@ public class Event : CommonBase { case 10: return new Event_HTLCIntercepted(ptr); case 11: return new Event_SpendableOutputs(ptr); case 12: return new Event_PaymentForwarded(ptr); - case 13: return new Event_ChannelReady(ptr); - case 14: return new Event_ChannelClosed(ptr); - case 15: return new Event_DiscardFunding(ptr); - case 16: return new Event_OpenChannelRequest(ptr); - case 17: return new Event_HTLCHandlingFailed(ptr); + case 13: return new Event_ChannelPending(ptr); + case 14: return new Event_ChannelReady(ptr); + case 15: return new Event_ChannelClosed(ptr); + case 16: return new Event_DiscardFunding(ptr); + case 17: return new Event_OpenChannelRequest(ptr); + case 18: return new Event_HTLCHandlingFailed(ptr); + case 19: return new Event_BumpTransaction(ptr); default: throw new ArgumentException("Impossible enum variant"); } @@ -94,7 +96,7 @@ public class Event : CommonBase { * This field will always be filled in when the event was generated by LDK versions * 0.0.113 and above. * - * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager + * [phantom nodes]: crate::sign::PhantomKeysManager * * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ @@ -105,9 +107,37 @@ public class Event : CommonBase { */ public byte[] payment_hash; /** - * The value, in thousandths of a satoshi, that this payment is for. + * The fields in the onion which were received with each HTLC. Only fields which were + * identical in each HTLC involved in the payment will be included here. + * + * Payments received on LDK versions prior to 0.0.115 will have this field unset. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + public RecipientOnionFields onion_fields; + /** + * The value, in thousandths of a satoshi, that this payment is claimable for. May be greater + * than the invoice amount. + * + * May be less than the invoice amount if [`ChannelConfig::accept_underpaying_htlcs`] is set + * and the previous hop took an extra fee. + * + * # Note + * If [`ChannelConfig::accept_underpaying_htlcs`] is set and you claim without verifying this + * field, you may lose money! + * + * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs */ public long amount_msat; + /** + * The value, in thousands of a satoshi, that was skimmed off of this payment as an extra fee + * taken by our channel counterparty. + * + * Will always be 0 unless [`ChannelConfig::accept_underpaying_htlcs`] is set. + * + * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs + */ + public long counterparty_skimmed_fee_msat; /** * Information for claiming this received payment, based on whether the purpose of the * payment is to pay an invoice or to send a spontaneous payment. @@ -123,10 +153,25 @@ public class Event : CommonBase { * The `user_channel_id` indicating over which channel we received the payment. */ public Option_u128Z via_user_channel_id; + /** + * The block height at which this payment will be failed back and will no longer be + * eligible for claiming. + * + * Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to + * succeed, however you should wait for [`Event::PaymentClaimed`] to be sure. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + */ + public Option_u32Z claim_deadline; internal Event_PaymentClaimable(long ptr) : base(null, ptr) { this.receiver_node_id = bindings.LDKEvent_PaymentClaimable_get_receiver_node_id(ptr); this.payment_hash = bindings.LDKEvent_PaymentClaimable_get_payment_hash(ptr); + long onion_fields = bindings.LDKEvent_PaymentClaimable_get_onion_fields(ptr); + org.ldk.structs.RecipientOnionFields onion_fields_hu_conv = null; if (onion_fields < 0 || onion_fields > 4096) { onion_fields_hu_conv = new org.ldk.structs.RecipientOnionFields(null, onion_fields); } + if (onion_fields_hu_conv != null) { onion_fields_hu_conv.ptrs_to.AddLast(this); }; + this.onion_fields = onion_fields_hu_conv; this.amount_msat = bindings.LDKEvent_PaymentClaimable_get_amount_msat(ptr); + this.counterparty_skimmed_fee_msat = bindings.LDKEvent_PaymentClaimable_get_counterparty_skimmed_fee_msat(ptr); long purpose = bindings.LDKEvent_PaymentClaimable_get_purpose(ptr); org.ldk.structs.PaymentPurpose purpose_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(purpose); if (purpose_hu_conv != null) { purpose_hu_conv.ptrs_to.AddLast(this); }; @@ -136,6 +181,10 @@ public class Event : CommonBase { org.ldk.structs.Option_u128Z via_user_channel_id_hu_conv = org.ldk.structs.Option_u128Z.constr_from_ptr(via_user_channel_id); if (via_user_channel_id_hu_conv != null) { via_user_channel_id_hu_conv.ptrs_to.AddLast(this); }; this.via_user_channel_id = via_user_channel_id_hu_conv; + long claim_deadline = bindings.LDKEvent_PaymentClaimable_get_claim_deadline(ptr); + org.ldk.structs.Option_u32Z claim_deadline_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(claim_deadline); + if (claim_deadline_hu_conv != null) { claim_deadline_hu_conv.ptrs_to.AddLast(this); }; + this.claim_deadline = claim_deadline_hu_conv; } } /** A Event of type PaymentClaimed */ @@ -146,7 +195,7 @@ public class Event : CommonBase { * This field will always be filled in when the event was generated by LDK versions * 0.0.113 and above. * - * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager + * [phantom nodes]: crate::sign::PhantomKeysManager * * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ @@ -157,7 +206,8 @@ public class Event : CommonBase { */ public byte[] payment_hash; /** - * The value, in thousandths of a satoshi, that this payment is for. + * The value, in thousandths of a satoshi, that this payment is for. May be greater than the + * invoice amount. */ public long amount_msat; /** @@ -178,15 +228,11 @@ public class Event : CommonBase { /** A Event of type PaymentSent */ public class Event_PaymentSent : Event { /** - * The id returned by [`ChannelManager::send_payment`] and used with - * [`ChannelManager::retry_payment`]. + * The `payment_id` passed to [`ChannelManager::send_payment`]. * * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public byte[] payment_id; + public Option_PaymentIdZ payment_id; /** * The preimage to the hash given to ChannelManager::send_payment. * Note that this serves as a payment receipt, if you wish to have such a thing, you must @@ -212,7 +258,10 @@ public class Event : CommonBase { */ public Option_u64Z fee_paid_msat; internal Event_PaymentSent(long ptr) : base(null, ptr) { - this.payment_id = bindings.LDKEvent_PaymentSent_get_payment_id(ptr); + long payment_id = bindings.LDKEvent_PaymentSent_get_payment_id(ptr); + org.ldk.structs.Option_PaymentIdZ payment_id_hu_conv = org.ldk.structs.Option_PaymentIdZ.constr_from_ptr(payment_id); + if (payment_id_hu_conv != null) { payment_id_hu_conv.ptrs_to.AddLast(this); }; + this.payment_id = payment_id_hu_conv; this.payment_preimage = bindings.LDKEvent_PaymentSent_get_payment_preimage(ptr); this.payment_hash = bindings.LDKEvent_PaymentSent_get_payment_hash(ptr); long fee_paid_msat = bindings.LDKEvent_PaymentSent_get_fee_paid_msat(ptr); @@ -224,12 +273,9 @@ public class Event : CommonBase { /** A Event of type PaymentFailed */ public class Event_PaymentFailed : Event { /** - * The id returned by [`ChannelManager::send_payment`] and used with - * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`]. + * The `payment_id` passed to [`ChannelManager::send_payment`]. * * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ public byte[] payment_id; /** @@ -238,63 +284,65 @@ public class Event : CommonBase { * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ public byte[] payment_hash; + /** + * The reason the payment failed. This is only `None` for events generated or serialized + * by versions prior to 0.0.115. + */ + public Option_PaymentFailureReasonZ reason; internal Event_PaymentFailed(long ptr) : base(null, ptr) { this.payment_id = bindings.LDKEvent_PaymentFailed_get_payment_id(ptr); this.payment_hash = bindings.LDKEvent_PaymentFailed_get_payment_hash(ptr); + long reason = bindings.LDKEvent_PaymentFailed_get_reason(ptr); + org.ldk.structs.Option_PaymentFailureReasonZ reason_hu_conv = org.ldk.structs.Option_PaymentFailureReasonZ.constr_from_ptr(reason); + if (reason_hu_conv != null) { reason_hu_conv.ptrs_to.AddLast(this); }; + this.reason = reason_hu_conv; } } /** A Event of type PaymentPathSuccessful */ public class Event_PaymentPathSuccessful : Event { /** - * The id returned by [`ChannelManager::send_payment`] and used with - * [`ChannelManager::retry_payment`]. + * The `payment_id` passed to [`ChannelManager::send_payment`]. * * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment */ public byte[] payment_id; /** * The hash that was given to [`ChannelManager::send_payment`]. * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * This will be `Some` for all payments which completed on LDK 0.0.104 or later. * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - public byte[] payment_hash; + public Option_PaymentHashZ payment_hash; /** * The payment path that was successful. * * May contain a closed channel if the HTLC sent along the path was fulfilled on chain. */ - public RouteHop[] path; + public Path path; internal Event_PaymentPathSuccessful(long ptr) : base(null, ptr) { this.payment_id = bindings.LDKEvent_PaymentPathSuccessful_get_payment_id(ptr); - this.payment_hash = bindings.LDKEvent_PaymentPathSuccessful_get_payment_hash(ptr); - long[] path = bindings.LDKEvent_PaymentPathSuccessful_get_path(ptr); - int path_conv_10_len = path.Length; - RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len]; - for (int k = 0; k < path_conv_10_len; k++) { - long path_conv_10 = path[k]; - 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); } - if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.AddLast(this); }; - path_conv_10_arr[k] = path_conv_10_hu_conv; - } - this.path = path_conv_10_arr; + long payment_hash = bindings.LDKEvent_PaymentPathSuccessful_get_payment_hash(ptr); + org.ldk.structs.Option_PaymentHashZ payment_hash_hu_conv = org.ldk.structs.Option_PaymentHashZ.constr_from_ptr(payment_hash); + if (payment_hash_hu_conv != null) { payment_hash_hu_conv.ptrs_to.AddLast(this); }; + this.payment_hash = payment_hash_hu_conv; + long path = bindings.LDKEvent_PaymentPathSuccessful_get_path(ptr); + org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); } + if (path_hu_conv != null) { path_hu_conv.ptrs_to.AddLast(this); }; + this.path = path_hu_conv; } } /** A Event of type PaymentPathFailed */ public class Event_PaymentPathFailed : Event { /** - * The id returned by [`ChannelManager::send_payment`] and used with - * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`]. + * The `payment_id` passed to [`ChannelManager::send_payment`]. + * + * This will be `Some` for all payment paths which failed on LDK 0.0.103 or later. * * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public byte[] payment_id; + public Option_PaymentIdZ payment_id; /** * The hash that was given to [`ChannelManager::send_payment`]. * @@ -303,44 +351,21 @@ public class Event : CommonBase { public byte[] payment_hash; /** * Indicates the payment was rejected for some reason by the recipient. This implies that - * the payment has failed, not just the route in question. If this is not set, you may - * retry the payment via a different route. + * the payment has failed, not just the route in question. If this is not set, the payment may + * be retried via a different route. */ public bool payment_failed_permanently; /** - * Any failure information conveyed via the Onion return packet by a node along the failed - * payment route. - * - * Should be applied to the [`NetworkGraph`] so that routing decisions can take into - * account the update. + * Extra error details based on the failure type. May contain an update that needs to be + * applied to the [`NetworkGraph`]. * * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph */ - public Option_NetworkUpdateZ network_update; - /** - * For both single-path and multi-path payments, this is set if all paths of the payment have - * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the - * larger MPP payment were still in flight when this event was generated. - * - * Note that if you are retrying individual MPP parts, using this value to determine if a - * payment has fully failed is race-y. Because multiple failures can happen prior to events - * being processed, you may retry in response to a first failure, with a second failure - * (with `all_paths_failed` set) still pending. Then, when the second failure is processed - * you will see `all_paths_failed` set even though the retry of the first failure still - * has an associated in-flight HTLC. See (1) for an example of such a failure. - * - * If you wish to retry individual MPP parts and learn when a payment has failed, you must - * call [`ChannelManager::abandon_payment`] and wait for a [`Event::PaymentFailed`] event. - * - * (1) - * - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - */ - public bool all_paths_failed; + public PathFailure failure; /** * The payment path that failed. */ - public RouteHop[] path; + public Path path; /** * The channel responsible for the failed payment path. * @@ -352,44 +377,25 @@ public class Event : CommonBase { * retried. May be `None` for older [`Event`] serializations. */ public Option_u64Z short_channel_id; - /** - * Parameters needed to compute a new [`Route`] when retrying the failed payment path. - * - * See [`find_route`] for details. - * - * [`Route`]: crate::routing::router::Route - * [`find_route`]: crate::routing::router::find_route - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - public RouteParameters retry; internal Event_PaymentPathFailed(long ptr) : base(null, ptr) { - this.payment_id = bindings.LDKEvent_PaymentPathFailed_get_payment_id(ptr); + long payment_id = bindings.LDKEvent_PaymentPathFailed_get_payment_id(ptr); + org.ldk.structs.Option_PaymentIdZ payment_id_hu_conv = org.ldk.structs.Option_PaymentIdZ.constr_from_ptr(payment_id); + if (payment_id_hu_conv != null) { payment_id_hu_conv.ptrs_to.AddLast(this); }; + this.payment_id = payment_id_hu_conv; this.payment_hash = bindings.LDKEvent_PaymentPathFailed_get_payment_hash(ptr); this.payment_failed_permanently = bindings.LDKEvent_PaymentPathFailed_get_payment_failed_permanently(ptr); - long network_update = bindings.LDKEvent_PaymentPathFailed_get_network_update(ptr); - org.ldk.structs.Option_NetworkUpdateZ network_update_hu_conv = org.ldk.structs.Option_NetworkUpdateZ.constr_from_ptr(network_update); - if (network_update_hu_conv != null) { network_update_hu_conv.ptrs_to.AddLast(this); }; - this.network_update = network_update_hu_conv; - this.all_paths_failed = bindings.LDKEvent_PaymentPathFailed_get_all_paths_failed(ptr); - long[] path = bindings.LDKEvent_PaymentPathFailed_get_path(ptr); - int path_conv_10_len = path.Length; - RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len]; - for (int k = 0; k < path_conv_10_len; k++) { - long path_conv_10 = path[k]; - 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); } - if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.AddLast(this); }; - path_conv_10_arr[k] = path_conv_10_hu_conv; - } - this.path = path_conv_10_arr; + long failure = bindings.LDKEvent_PaymentPathFailed_get_failure(ptr); + org.ldk.structs.PathFailure failure_hu_conv = org.ldk.structs.PathFailure.constr_from_ptr(failure); + if (failure_hu_conv != null) { failure_hu_conv.ptrs_to.AddLast(this); }; + this.failure = failure_hu_conv; + long path = bindings.LDKEvent_PaymentPathFailed_get_path(ptr); + org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); } + if (path_hu_conv != null) { path_hu_conv.ptrs_to.AddLast(this); }; + this.path = path_hu_conv; long short_channel_id = bindings.LDKEvent_PaymentPathFailed_get_short_channel_id(ptr); org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id); if (short_channel_id_hu_conv != null) { short_channel_id_hu_conv.ptrs_to.AddLast(this); }; this.short_channel_id = short_channel_id_hu_conv; - long retry = bindings.LDKEvent_PaymentPathFailed_get_retry(ptr); - org.ldk.structs.RouteParameters retry_hu_conv = null; if (retry < 0 || retry > 4096) { retry_hu_conv = new org.ldk.structs.RouteParameters(null, retry); } - if (retry_hu_conv != null) { retry_hu_conv.ptrs_to.AddLast(this); }; - this.retry = retry_hu_conv; } } /** A Event of type ProbeSuccessful */ @@ -409,20 +415,14 @@ public class Event : CommonBase { /** * The payment path that was successful. */ - public RouteHop[] path; + public Path path; internal Event_ProbeSuccessful(long ptr) : base(null, ptr) { this.payment_id = bindings.LDKEvent_ProbeSuccessful_get_payment_id(ptr); this.payment_hash = bindings.LDKEvent_ProbeSuccessful_get_payment_hash(ptr); - long[] path = bindings.LDKEvent_ProbeSuccessful_get_path(ptr); - int path_conv_10_len = path.Length; - RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len]; - for (int k = 0; k < path_conv_10_len; k++) { - long path_conv_10 = path[k]; - 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); } - if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.AddLast(this); }; - path_conv_10_arr[k] = path_conv_10_hu_conv; - } - this.path = path_conv_10_arr; + long path = bindings.LDKEvent_ProbeSuccessful_get_path(ptr); + org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); } + if (path_hu_conv != null) { path_hu_conv.ptrs_to.AddLast(this); }; + this.path = path_hu_conv; } } /** A Event of type ProbeFailed */ @@ -442,7 +442,7 @@ public class Event : CommonBase { /** * The payment path that failed. */ - public RouteHop[] path; + public Path path; /** * The channel responsible for the failed probe. * @@ -454,16 +454,10 @@ public class Event : CommonBase { internal Event_ProbeFailed(long ptr) : base(null, ptr) { this.payment_id = bindings.LDKEvent_ProbeFailed_get_payment_id(ptr); this.payment_hash = bindings.LDKEvent_ProbeFailed_get_payment_hash(ptr); - long[] path = bindings.LDKEvent_ProbeFailed_get_path(ptr); - int path_conv_10_len = path.Length; - RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len]; - for (int k = 0; k < path_conv_10_len; k++) { - long path_conv_10 = path[k]; - 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); } - if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.AddLast(this); }; - path_conv_10_arr[k] = path_conv_10_hu_conv; - } - this.path = path_conv_10_arr; + long path = bindings.LDKEvent_ProbeFailed_get_path(ptr); + org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); } + if (path_hu_conv != null) { path_hu_conv.ptrs_to.AddLast(this); }; + this.path = path_hu_conv; long short_channel_id = bindings.LDKEvent_ProbeFailed_get_short_channel_id(ptr); org.ldk.structs.Option_u64Z short_channel_id_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(short_channel_id); if (short_channel_id_hu_conv != null) { short_channel_id_hu_conv.ptrs_to.AddLast(this); }; @@ -507,6 +501,7 @@ public class Event : CommonBase { /** * How many msats the payer intended to route to the next node. Depending on the reason you are * intercepting this payment, you might take a fee by forwarding less than this amount. + * Forwarding less than this amount may break compatibility with LDK versions prior to 0.0.116. * * Note that LDK will NOT check that expected fees were factored into this value. You MUST * check that whatever fee you want has been included here or subtract it as required. Further, @@ -577,6 +572,12 @@ public class Event : CommonBase { * transaction. */ public bool claim_from_onchain_tx; + /** + * The final amount forwarded, in milli-satoshis, after the fee is deducted. + * + * The caveat described above the `fee_earned_msat` field applies here as well. + */ + public Option_u64Z outbound_amount_forwarded_msat; internal Event_PaymentForwarded(long ptr) : base(null, ptr) { this.prev_channel_id = bindings.LDKEvent_PaymentForwarded_get_prev_channel_id(ptr); this.next_channel_id = bindings.LDKEvent_PaymentForwarded_get_next_channel_id(ptr); @@ -585,12 +586,62 @@ public class Event : CommonBase { if (fee_earned_msat_hu_conv != null) { fee_earned_msat_hu_conv.ptrs_to.AddLast(this); }; this.fee_earned_msat = fee_earned_msat_hu_conv; this.claim_from_onchain_tx = bindings.LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(ptr); + long outbound_amount_forwarded_msat = bindings.LDKEvent_PaymentForwarded_get_outbound_amount_forwarded_msat(ptr); + org.ldk.structs.Option_u64Z outbound_amount_forwarded_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(outbound_amount_forwarded_msat); + if (outbound_amount_forwarded_msat_hu_conv != null) { outbound_amount_forwarded_msat_hu_conv.ptrs_to.AddLast(this); }; + this.outbound_amount_forwarded_msat = outbound_amount_forwarded_msat_hu_conv; + } + } + /** A Event of type ChannelPending */ + public class Event_ChannelPending : Event { + /** + * The `channel_id` of the channel that is pending confirmation. + */ + public byte[] channel_id; + /** + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + */ + public UInt128 user_channel_id; + /** + * The `temporary_channel_id` this channel used to be known by during channel establishment. + * + * Will be `None` for channels created prior to LDK version 0.0.115. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + public byte[] former_temporary_channel_id; + /** + * The `node_id` of the channel counterparty. + */ + public byte[] counterparty_node_id; + /** + * The outpoint of the channel's funding transaction. + */ + public OutPoint funding_txo; + internal Event_ChannelPending(long ptr) : base(null, ptr) { + this.channel_id = bindings.LDKEvent_ChannelPending_get_channel_id(ptr); + byte[] user_channel_id = bindings.LDKEvent_ChannelPending_get_user_channel_id(ptr); + org.ldk.util.UInt128 user_channel_id_conv = new org.ldk.util.UInt128(user_channel_id); + this.user_channel_id = user_channel_id_conv; + this.former_temporary_channel_id = bindings.LDKEvent_ChannelPending_get_former_temporary_channel_id(ptr); + this.counterparty_node_id = bindings.LDKEvent_ChannelPending_get_counterparty_node_id(ptr); + long funding_txo = bindings.LDKEvent_ChannelPending_get_funding_txo(ptr); + org.ldk.structs.OutPoint funding_txo_hu_conv = null; if (funding_txo < 0 || funding_txo > 4096) { funding_txo_hu_conv = new org.ldk.structs.OutPoint(null, funding_txo); } + if (funding_txo_hu_conv != null) { funding_txo_hu_conv.ptrs_to.AddLast(this); }; + this.funding_txo = funding_txo_hu_conv; } } /** A Event of type ChannelReady */ public class Event_ChannelReady : Event { /** - * The channel_id of the channel that is ready. + * The `channel_id` of the channel that is ready. */ public byte[] channel_id; /** @@ -605,7 +656,7 @@ public class Event : CommonBase { */ public UInt128 user_channel_id; /** - * The node_id of the channel counterparty. + * The `node_id` of the channel counterparty. */ public byte[] counterparty_node_id; /** @@ -627,7 +678,7 @@ public class Event : CommonBase { /** A Event of type ChannelClosed */ public class Event_ChannelClosed : Event { /** - * The channel_id of the channel which has been closed. Note that on-chain transactions + * The `channel_id` of the channel which has been closed. Note that on-chain transactions * resolving the channel are likely still awaiting confirmation. */ public byte[] channel_id; @@ -754,6 +805,16 @@ public class Event : CommonBase { this.failed_next_destination = failed_next_destination_hu_conv; } } + /** A Event of type BumpTransaction */ + public class Event_BumpTransaction : Event { + public BumpTransactionEvent bump_transaction; + internal Event_BumpTransaction(long ptr) : base(null, ptr) { + long bump_transaction = bindings.LDKEvent_BumpTransaction_get_bump_transaction(ptr); + org.ldk.structs.BumpTransactionEvent bump_transaction_hu_conv = org.ldk.structs.BumpTransactionEvent.constr_from_ptr(bump_transaction); + if (bump_transaction_hu_conv != null) { bump_transaction_hu_conv.ptrs_to.AddLast(this); }; + this.bump_transaction = bump_transaction_hu_conv; + } + } internal long clone_ptr() { long ret = bindings.Event_clone_ptr(this.ptr); GC.KeepAlive(this); @@ -791,17 +852,24 @@ public class Event : CommonBase { /** * Utility method to constructs a new PaymentClaimable-variant Event */ - 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) { - 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); + public static Event payment_claimable(byte[] receiver_node_id, byte[] payment_hash, org.ldk.structs.RecipientOnionFields onion_fields, long amount_msat, long counterparty_skimmed_fee_msat, org.ldk.structs.PaymentPurpose purpose, byte[] via_channel_id, org.ldk.structs.Option_u128Z via_user_channel_id, org.ldk.structs.Option_u32Z claim_deadline) { + long ret = bindings.Event_payment_claimable(InternalUtils.check_arr_len(receiver_node_id, 33), InternalUtils.check_arr_len(payment_hash, 32), onion_fields == null ? 0 : onion_fields.ptr, amount_msat, counterparty_skimmed_fee_msat, purpose.ptr, InternalUtils.check_arr_len(via_channel_id, 32), via_user_channel_id.ptr, claim_deadline.ptr); GC.KeepAlive(receiver_node_id); GC.KeepAlive(payment_hash); + GC.KeepAlive(onion_fields); GC.KeepAlive(amount_msat); + GC.KeepAlive(counterparty_skimmed_fee_msat); GC.KeepAlive(purpose); GC.KeepAlive(via_channel_id); GC.KeepAlive(via_user_channel_id); + GC.KeepAlive(claim_deadline); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(onion_fields); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(purpose); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(via_user_channel_id); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(claim_deadline); }; return ret_hu_conv; } @@ -817,14 +885,15 @@ public class Event : CommonBase { if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(purpose); }; 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, org.ldk.structs.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); + public static Event payment_sent(org.ldk.structs.Option_PaymentIdZ payment_id, byte[] payment_preimage, byte[] payment_hash, org.ldk.structs.Option_u64Z fee_paid_msat) { + long ret = bindings.Event_payment_sent(payment_id.ptr, InternalUtils.check_arr_len(payment_preimage, 32), InternalUtils.check_arr_len(payment_hash, 32), fee_paid_msat.ptr); GC.KeepAlive(payment_id); GC.KeepAlive(payment_preimage); GC.KeepAlive(payment_hash); @@ -832,78 +901,83 @@ public class Event : CommonBase { if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_id); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_paid_msat); }; return ret_hu_conv; } /** * Utility method to constructs a new PaymentFailed-variant Event */ - public static Event payment_failed(byte[] payment_id, byte[] payment_hash) { - long ret = bindings.Event_payment_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32)); + public static Event payment_failed(byte[] payment_id, byte[] payment_hash, org.ldk.structs.Option_PaymentFailureReasonZ reason) { + long ret = bindings.Event_payment_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), reason.ptr); GC.KeepAlive(payment_id); GC.KeepAlive(payment_hash); + GC.KeepAlive(reason); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(reason); }; return ret_hu_conv; } /** * Utility method to constructs a new PaymentPathSuccessful-variant Event */ - public static Event payment_path_successful(byte[] payment_id, byte[] payment_hash, RouteHop[] path) { - long ret = bindings.Event_payment_path_successful(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path != null ? InternalUtils.mapArray(path, path_conv_10 => path_conv_10 == null ? 0 : path_conv_10.ptr) : null); + public static Event payment_path_successful(byte[] payment_id, org.ldk.structs.Option_PaymentHashZ payment_hash, org.ldk.structs.Path path) { + long ret = bindings.Event_payment_path_successful(InternalUtils.check_arr_len(payment_id, 32), payment_hash.ptr, path == null ? 0 : path.ptr); GC.KeepAlive(payment_id); GC.KeepAlive(payment_hash); GC.KeepAlive(path); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; - foreach (RouteHop path_conv_10 in path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path_conv_10); }; }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_hash); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); }; 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, bool payment_failed_permanently, org.ldk.structs.Option_NetworkUpdateZ network_update, bool all_paths_failed, RouteHop[] path, org.ldk.structs.Option_u64Z short_channel_id, org.ldk.structs.RouteParameters retry) { - long ret = bindings.Event_payment_path_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), payment_failed_permanently, network_update.ptr, all_paths_failed, path != null ? InternalUtils.mapArray(path, path_conv_10 => path_conv_10 == null ? 0 : path_conv_10.ptr) : null, short_channel_id.ptr, retry == null ? 0 : retry.ptr); + public static Event payment_path_failed(org.ldk.structs.Option_PaymentIdZ payment_id, byte[] payment_hash, bool payment_failed_permanently, org.ldk.structs.PathFailure failure, org.ldk.structs.Path path, org.ldk.structs.Option_u64Z short_channel_id) { + long ret = bindings.Event_payment_path_failed(payment_id.ptr, InternalUtils.check_arr_len(payment_hash, 32), payment_failed_permanently, failure.ptr, path == null ? 0 : path.ptr, short_channel_id.ptr); GC.KeepAlive(payment_id); GC.KeepAlive(payment_hash); GC.KeepAlive(payment_failed_permanently); - GC.KeepAlive(network_update); - GC.KeepAlive(all_paths_failed); + GC.KeepAlive(failure); GC.KeepAlive(path); GC.KeepAlive(short_channel_id); - GC.KeepAlive(retry); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; - foreach (RouteHop path_conv_10 in path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path_conv_10); }; }; - if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(retry); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_id); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(failure); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(short_channel_id); }; return ret_hu_conv; } /** * Utility method to constructs a new ProbeSuccessful-variant Event */ - public static Event probe_successful(byte[] payment_id, byte[] payment_hash, RouteHop[] path) { - long ret = bindings.Event_probe_successful(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path != null ? InternalUtils.mapArray(path, path_conv_10 => path_conv_10 == null ? 0 : path_conv_10.ptr) : null); + public static Event probe_successful(byte[] payment_id, byte[] payment_hash, org.ldk.structs.Path path) { + long ret = bindings.Event_probe_successful(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path == null ? 0 : path.ptr); GC.KeepAlive(payment_id); GC.KeepAlive(payment_hash); GC.KeepAlive(path); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; - foreach (RouteHop path_conv_10 in path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path_conv_10); }; }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); }; return ret_hu_conv; } /** * Utility method to constructs a new ProbeFailed-variant Event */ - public static Event probe_failed(byte[] payment_id, byte[] payment_hash, RouteHop[] path, org.ldk.structs.Option_u64Z short_channel_id) { - long ret = bindings.Event_probe_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path != null ? InternalUtils.mapArray(path, path_conv_10 => path_conv_10 == null ? 0 : path_conv_10.ptr) : null, short_channel_id.ptr); + public static Event probe_failed(byte[] payment_id, byte[] payment_hash, org.ldk.structs.Path path, org.ldk.structs.Option_u64Z short_channel_id) { + long ret = bindings.Event_probe_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path == null ? 0 : path.ptr, short_channel_id.ptr); GC.KeepAlive(payment_id); GC.KeepAlive(payment_hash); GC.KeepAlive(path); @@ -911,7 +985,8 @@ public class Event : CommonBase { if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; - foreach (RouteHop path_conv_10 in path) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path_conv_10); }; }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(short_channel_id); }; return ret_hu_conv; } @@ -952,21 +1027,42 @@ public class Event : CommonBase { if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + foreach (SpendableOutputDescriptor outputs_conv_27 in outputs) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outputs_conv_27); }; }; return ret_hu_conv; } /** * Utility method to constructs a new PaymentForwarded-variant Event */ - public static Event payment_forwarded(byte[] prev_channel_id, byte[] next_channel_id, org.ldk.structs.Option_u64Z fee_earned_msat, bool claim_from_onchain_tx) { - 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); + public static Event payment_forwarded(byte[] prev_channel_id, byte[] next_channel_id, org.ldk.structs.Option_u64Z fee_earned_msat, bool claim_from_onchain_tx, org.ldk.structs.Option_u64Z outbound_amount_forwarded_msat) { + long ret = bindings.Event_payment_forwarded(InternalUtils.check_arr_len(prev_channel_id, 32), InternalUtils.check_arr_len(next_channel_id, 32), fee_earned_msat.ptr, claim_from_onchain_tx, outbound_amount_forwarded_msat.ptr); GC.KeepAlive(prev_channel_id); GC.KeepAlive(next_channel_id); GC.KeepAlive(fee_earned_msat); GC.KeepAlive(claim_from_onchain_tx); + GC.KeepAlive(outbound_amount_forwarded_msat); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_earned_msat); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outbound_amount_forwarded_msat); }; + return ret_hu_conv; + } + + /** + * Utility method to constructs a new ChannelPending-variant Event + */ + public static Event channel_pending(byte[] channel_id, org.ldk.util.UInt128 user_channel_id, byte[] former_temporary_channel_id, byte[] counterparty_node_id, org.ldk.structs.OutPoint funding_txo) { + long ret = bindings.Event_channel_pending(InternalUtils.check_arr_len(channel_id, 32), user_channel_id.getLEBytes(), InternalUtils.check_arr_len(former_temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), funding_txo == null ? 0 : funding_txo.ptr); + GC.KeepAlive(channel_id); + GC.KeepAlive(user_channel_id); + GC.KeepAlive(former_temporary_channel_id); + GC.KeepAlive(counterparty_node_id); + GC.KeepAlive(funding_txo); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(funding_txo); }; return ret_hu_conv; } @@ -997,6 +1093,7 @@ public class Event : CommonBase { if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(reason); }; return ret_hu_conv; } @@ -1040,9 +1137,38 @@ public class Event : CommonBase { if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(failed_next_destination); }; return ret_hu_conv; } + /** + * Utility method to constructs a new BumpTransaction-variant Event + */ + public static Event bump_transaction(org.ldk.structs.BumpTransactionEvent a) { + long ret = bindings.Event_bump_transaction(a.ptr); + GC.KeepAlive(a); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Event ret_hu_conv = org.ldk.structs.Event.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); }; + return ret_hu_conv; + } + + /** + * Checks if two Events contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ + public bool eq(org.ldk.structs.Event b) { + bool ret = bindings.Event_eq(this.ptr, b == null ? 0 : b.ptr); + GC.KeepAlive(this); + GC.KeepAlive(b); + return ret; + } + + public override bool Equals(object o) { + if (!(o is Event)) return false; + return this.eq((Event)o); + } /** * Serialize the Event object into a byte array which can be read by Event_read */