Merge pull request #46 from TheBlueMatt/main
[ldk-c-bindings] / lightning-c-bindings / src / lightning / util / events.rs
index 491812dc9e5dabf86ee8d4828b64ab8ddc7acede..47f4465fd7bbcf900cac2241c03115b5ed34c267 100644 (file)
@@ -15,6 +15,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -165,6 +166,183 @@ pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_type
 pub extern "C" fn PaymentPurpose_spontaneous_payment(a: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose {
        PaymentPurpose::SpontaneousPayment(a, )
 }
+/// The reason the channel was closed. See individual variants more details.
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum ClosureReason {
+       /// Closure generated from receiving a peer error message.
+       ///
+       /// Our counterparty may have broadcasted their latest commitment state, and we have
+       /// as well.
+       CounterpartyForceClosed {
+               /// The error which the peer sent us.
+               ///
+               /// The string should be sanitized before it is used (e.g emitted to logs
+               /// or printed to stdout). Otherwise, a well crafted error message may exploit
+               /// a security vulnerability in the terminal emulator or the logging subsystem.
+               peer_msg: crate::c_types::Str,
+       },
+       /// Closure generated from [`ChannelManager::force_close_channel`], called by the user.
+       ///
+       /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
+       HolderForceClosed,
+       /// The channel was closed after negotiating a cooperative close and we've now broadcasted
+       /// the cooperative close transaction. Note the shutdown may have been initiated by us.
+       CooperativeClosure,
+       /// A commitment transaction was confirmed on chain, closing the channel. Most likely this
+       /// commitment transaction came from our counterparty, but it may also have come from
+       /// a copy of our own `ChannelMonitor`.
+       CommitmentTxConfirmed,
+       /// Closure generated from processing an event, likely a HTLC forward/relay/reception.
+       ProcessingError {
+               /// A developer-readable error message which we generated.
+               err: crate::c_types::Str,
+       },
+       /// The `PeerManager` informed us that we've disconnected from the peer. We close channels
+       /// if the `PeerManager` informed us that it is unlikely we'll be able to connect to the
+       /// peer again in the future or if the peer disconnected before we finished negotiating
+       /// the channel open. The first case may be caused by incompatible features which our
+       /// counterparty, or we, require.
+       DisconnectedPeer,
+       /// Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than
+       /// the ChannelManager deserialized.
+       OutdatedChannelManager,
+}
+use lightning::util::events::ClosureReason as nativeClosureReason;
+impl ClosureReason {
+       #[allow(unused)]
+       pub(crate) fn to_native(&self) -> nativeClosureReason {
+               match self {
+                       ClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
+                               let mut peer_msg_nonref = (*peer_msg).clone();
+                               nativeClosureReason::CounterpartyForceClosed {
+                                       peer_msg: peer_msg_nonref.into_string(),
+                               }
+                       },
+                       ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
+                       ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
+                       ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
+                       ClosureReason::ProcessingError {ref err, } => {
+                               let mut err_nonref = (*err).clone();
+                               nativeClosureReason::ProcessingError {
+                                       err: err_nonref.into_string(),
+                               }
+                       },
+                       ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
+                       ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn into_native(self) -> nativeClosureReason {
+               match self {
+                       ClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
+                               nativeClosureReason::CounterpartyForceClosed {
+                                       peer_msg: peer_msg.into_string(),
+                               }
+                       },
+                       ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
+                       ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
+                       ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
+                       ClosureReason::ProcessingError {mut err, } => {
+                               nativeClosureReason::ProcessingError {
+                                       err: err.into_string(),
+                               }
+                       },
+                       ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
+                       ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn from_native(native: &nativeClosureReason) -> Self {
+               match native {
+                       nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
+                               let mut peer_msg_nonref = (*peer_msg).clone();
+                               ClosureReason::CounterpartyForceClosed {
+                                       peer_msg: peer_msg_nonref.into(),
+                               }
+                       },
+                       nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
+                       nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
+                       nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
+                       nativeClosureReason::ProcessingError {ref err, } => {
+                               let mut err_nonref = (*err).clone();
+                               ClosureReason::ProcessingError {
+                                       err: err_nonref.into(),
+                               }
+                       },
+                       nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
+                       nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn native_into(native: nativeClosureReason) -> Self {
+               match native {
+                       nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
+                               ClosureReason::CounterpartyForceClosed {
+                                       peer_msg: peer_msg.into(),
+                               }
+                       },
+                       nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
+                       nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
+                       nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
+                       nativeClosureReason::ProcessingError {mut err, } => {
+                               ClosureReason::ProcessingError {
+                                       err: err.into(),
+                               }
+                       },
+                       nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
+                       nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
+               }
+       }
+}
+/// Frees any resources used by the ClosureReason
+#[no_mangle]
+pub extern "C" fn ClosureReason_free(this_ptr: ClosureReason) { }
+/// Creates a copy of the ClosureReason
+#[no_mangle]
+pub extern "C" fn ClosureReason_clone(orig: &ClosureReason) -> ClosureReason {
+       orig.clone()
+}
+#[no_mangle]
+/// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
+pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::c_types::Str) -> ClosureReason {
+       ClosureReason::CounterpartyForceClosed {
+               peer_msg,
+       }
+}
+#[no_mangle]
+/// Utility method to constructs a new HolderForceClosed-variant ClosureReason
+pub extern "C" fn ClosureReason_holder_force_closed() -> ClosureReason {
+       ClosureReason::HolderForceClosed}
+#[no_mangle]
+/// Utility method to constructs a new CooperativeClosure-variant ClosureReason
+pub extern "C" fn ClosureReason_cooperative_closure() -> ClosureReason {
+       ClosureReason::CooperativeClosure}
+#[no_mangle]
+/// Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
+pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason {
+       ClosureReason::CommitmentTxConfirmed}
+#[no_mangle]
+/// Utility method to constructs a new ProcessingError-variant ClosureReason
+pub extern "C" fn ClosureReason_processing_error(err: crate::c_types::Str) -> ClosureReason {
+       ClosureReason::ProcessingError {
+               err,
+       }
+}
+#[no_mangle]
+/// Utility method to constructs a new DisconnectedPeer-variant ClosureReason
+pub extern "C" fn ClosureReason_disconnected_peer() -> ClosureReason {
+       ClosureReason::DisconnectedPeer}
+#[no_mangle]
+/// Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
+pub extern "C" fn ClosureReason_outdated_channel_manager() -> ClosureReason {
+       ClosureReason::OutdatedChannelManager}
+#[no_mangle]
+/// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
+pub extern "C" fn ClosureReason_write(obj: &ClosureReason) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
+}
 /// An Event which you should probably take some action in response to.
 ///
 /// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
@@ -187,47 +365,76 @@ pub enum Event {
                channel_value_satoshis: u64,
                /// The script which should be used in the transaction output.
                output_script: crate::c_types::derived::CVec_u8Z,
-               /// The value passed in to ChannelManager::create_channel
+               /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
+               /// an inbound channel.
+               ///
+               /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
                user_channel_id: u64,
        },
        /// Indicates we've received money! Just gotta dig out that payment preimage and feed it to
-       /// ChannelManager::claim_funds to get it....
-       /// Note that if the preimage is not known or the amount paid is incorrect, you should call
-       /// ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
+       /// [`ChannelManager::claim_funds`] to get it....
+       /// Note that if the preimage is not known, you should call
+       /// [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid
        /// network congestion.
-       /// The amount paid should be considered 'incorrect' when it is less than or more than twice
-       /// the amount expected.
-       /// If you fail to call either ChannelManager::claim_funds or
-       /// ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
+       /// If you fail to call either [`ChannelManager::claim_funds`] or
+       /// [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be
        /// automatically failed.
+       ///
+       /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
+       /// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
        PaymentReceived {
                /// The hash for which the preimage should be handed to the ChannelManager.
                payment_hash: crate::c_types::ThirtyTwoBytes,
-               /// The value, in thousandths of a satoshi, that this payment is for. Note that you must
-               /// compare this to the expected value before accepting the payment (as otherwise you are
-               /// providing proof-of-payment for less than the value you expected!).
+               /// The value, in thousandths of a satoshi, that this payment is for.
                amt: u64,
                /// 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.
                purpose: crate::lightning::util::events::PaymentPurpose,
        },
-       /// Indicates an outbound payment we made succeeded (ie it made it all the way to its target
+       /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
        /// and we got back the payment preimage for it).
+       ///
+       /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
+       /// event. In this situation, you SHOULD treat this payment as having succeeded.
        PaymentSent {
                /// 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
                /// store it somehow!
                payment_preimage: crate::c_types::ThirtyTwoBytes,
+               /// The hash which was given to [`ChannelManager::send_payment`].
+               ///
+               /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+               payment_hash: crate::c_types::ThirtyTwoBytes,
        },
        /// Indicates an outbound payment we made failed. Probably some intermediary node dropped
        /// something. You may wish to retry with a different route.
-       PaymentFailed {
+       PaymentPathFailed {
                /// The hash which was given to ChannelManager::send_payment.
                payment_hash: crate::c_types::ThirtyTwoBytes,
                /// 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.
                rejected_by_dest: bool,
+               /// 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. [`NetGraphMsgHandler`] is capable of doing this.
+               ///
+               /// [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph
+               /// [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
+               network_update: crate::c_types::derived::COption_NetworkUpdateZ,
+               /// 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.
+               all_paths_failed: bool,
+               /// The payment path that failed.
+               path: crate::c_types::derived::CVec_RouteHopZ,
+               /// The channel responsible for the failed payment path.
+               ///
+               /// If this is `Some`, then the corresponding channel should be avoided when the payment is
+               /// retried. May be `None` for older [`Event`] serializations.
+               short_channel_id: crate::c_types::derived::COption_u64Z,
        },
        /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
        /// time in the future.
@@ -268,6 +475,28 @@ pub enum Event {
                /// transaction.
                claim_from_onchain_tx: bool,
        },
+       /// Used to indicate that a channel with the given `channel_id` is in the process of closure.
+       ChannelClosed {
+               /// The channel_id of the channel which has been closed. Note that on-chain transactions
+               /// resolving the channel are likely still awaiting confirmation.
+               channel_id: crate::c_types::ThirtyTwoBytes,
+               /// 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
+               user_channel_id: u64,
+               /// The reason the channel was closed.
+               reason: crate::lightning::util::events::ClosureReason,
+       },
+       /// Used to indicate to the user that they can abandon the funding transaction and recycle the
+       /// inputs for another purpose.
+       DiscardFunding {
+               /// The channel_id of the channel which has been closed.
+               channel_id: crate::c_types::ThirtyTwoBytes,
+               /// The full transaction received from the user
+               transaction: crate::c_types::Transaction,
+       },
 }
 use lightning::util::events::Event as nativeEvent;
 impl Event {
@@ -296,18 +525,31 @@ impl Event {
                                        purpose: purpose_nonref.into_native(),
                                }
                        },
-                       Event::PaymentSent {ref payment_preimage, } => {
+                       Event::PaymentSent {ref payment_preimage, ref payment_hash, } => {
                                let mut payment_preimage_nonref = (*payment_preimage).clone();
+                               let mut payment_hash_nonref = (*payment_hash).clone();
                                nativeEvent::PaymentSent {
                                        payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data),
+                                       payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
                                }
                        },
-                       Event::PaymentFailed {ref payment_hash, ref rejected_by_dest, } => {
+                       Event::PaymentPathFailed {ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, } => {
                                let mut payment_hash_nonref = (*payment_hash).clone();
                                let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
-                               nativeEvent::PaymentFailed {
+                               let mut network_update_nonref = (*network_update).clone();
+                               let mut local_network_update_nonref = { /* network_update_nonref*/ let network_update_nonref_opt = network_update_nonref; { } if network_update_nonref_opt.is_none() { None } else { Some({ network_update_nonref_opt.take().into_native() }) } };
+                               let mut all_paths_failed_nonref = (*all_paths_failed).clone();
+                               let mut path_nonref = (*path).clone();
+                               let mut local_path_nonref = Vec::new(); for mut item in path_nonref.into_rust().drain(..) { local_path_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+                               let mut short_channel_id_nonref = (*short_channel_id).clone();
+                               let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None };
+                               nativeEvent::PaymentPathFailed {
                                        payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
                                        rejected_by_dest: rejected_by_dest_nonref,
+                                       network_update: local_network_update_nonref,
+                                       all_paths_failed: all_paths_failed_nonref,
+                                       path: local_path_nonref,
+                                       short_channel_id: local_short_channel_id_nonref,
                                }
                        },
                        Event::PendingHTLCsForwardable {ref time_forwardable, } => {
@@ -332,6 +574,24 @@ impl Event {
                                        claim_from_onchain_tx: claim_from_onchain_tx_nonref,
                                }
                        },
+                       Event::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => {
+                               let mut channel_id_nonref = (*channel_id).clone();
+                               let mut user_channel_id_nonref = (*user_channel_id).clone();
+                               let mut reason_nonref = (*reason).clone();
+                               nativeEvent::ChannelClosed {
+                                       channel_id: channel_id_nonref.data,
+                                       user_channel_id: user_channel_id_nonref,
+                                       reason: reason_nonref.into_native(),
+                               }
+                       },
+                       Event::DiscardFunding {ref channel_id, ref transaction, } => {
+                               let mut channel_id_nonref = (*channel_id).clone();
+                               let mut transaction_nonref = (*transaction).clone();
+                               nativeEvent::DiscardFunding {
+                                       channel_id: channel_id_nonref.data,
+                                       transaction: transaction_nonref.into_bitcoin(),
+                               }
+                       },
                }
        }
        #[allow(unused)]
@@ -352,15 +612,23 @@ impl Event {
                                        purpose: purpose.into_native(),
                                }
                        },
-                       Event::PaymentSent {mut payment_preimage, } => {
+                       Event::PaymentSent {mut payment_preimage, mut payment_hash, } => {
                                nativeEvent::PaymentSent {
                                        payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data),
+                                       payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
                                }
                        },
-                       Event::PaymentFailed {mut payment_hash, mut rejected_by_dest, } => {
-                               nativeEvent::PaymentFailed {
+                       Event::PaymentPathFailed {mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, } => {
+                               let mut local_network_update = { /* network_update*/ let network_update_opt = network_update; { } if network_update_opt.is_none() { None } else { Some({ network_update_opt.take().into_native() }) } };
+                               let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+                               let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None };
+                               nativeEvent::PaymentPathFailed {
                                        payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
                                        rejected_by_dest: rejected_by_dest,
+                                       network_update: local_network_update,
+                                       all_paths_failed: all_paths_failed,
+                                       path: local_path,
+                                       short_channel_id: local_short_channel_id,
                                }
                        },
                        Event::PendingHTLCsForwardable {mut time_forwardable, } => {
@@ -381,6 +649,19 @@ impl Event {
                                        claim_from_onchain_tx: claim_from_onchain_tx,
                                }
                        },
+                       Event::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => {
+                               nativeEvent::ChannelClosed {
+                                       channel_id: channel_id.data,
+                                       user_channel_id: user_channel_id,
+                                       reason: reason.into_native(),
+                               }
+                       },
+                       Event::DiscardFunding {mut channel_id, mut transaction, } => {
+                               nativeEvent::DiscardFunding {
+                                       channel_id: channel_id.data,
+                                       transaction: transaction.into_bitcoin(),
+                               }
+                       },
                }
        }
        #[allow(unused)]
@@ -408,18 +689,31 @@ impl Event {
                                        purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose_nonref),
                                }
                        },
-                       nativeEvent::PaymentSent {ref payment_preimage, } => {
+                       nativeEvent::PaymentSent {ref payment_preimage, ref payment_hash, } => {
                                let mut payment_preimage_nonref = (*payment_preimage).clone();
+                               let mut payment_hash_nonref = (*payment_hash).clone();
                                Event::PaymentSent {
                                        payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
+                                       payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
                                }
                        },
-                       nativeEvent::PaymentFailed {ref payment_hash, ref rejected_by_dest, } => {
+                       nativeEvent::PaymentPathFailed {ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, } => {
                                let mut payment_hash_nonref = (*payment_hash).clone();
                                let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
-                               Event::PaymentFailed {
+                               let mut network_update_nonref = (*network_update).clone();
+                               let mut local_network_update_nonref = if network_update_nonref.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::network_graph::NetworkUpdate::native_into(network_update_nonref.unwrap()) }) };
+                               let mut all_paths_failed_nonref = (*all_paths_failed).clone();
+                               let mut path_nonref = (*path).clone();
+                               let mut local_path_nonref = Vec::new(); for mut item in path_nonref.drain(..) { local_path_nonref.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+                               let mut short_channel_id_nonref = (*short_channel_id).clone();
+                               let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) };
+                               Event::PaymentPathFailed {
                                        payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
                                        rejected_by_dest: rejected_by_dest_nonref,
+                                       network_update: local_network_update_nonref,
+                                       all_paths_failed: all_paths_failed_nonref,
+                                       path: local_path_nonref.into(),
+                                       short_channel_id: local_short_channel_id_nonref,
                                }
                        },
                        nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
@@ -437,13 +731,31 @@ impl Event {
                        },
                        nativeEvent::PaymentForwarded {ref fee_earned_msat, ref claim_from_onchain_tx, } => {
                                let mut fee_earned_msat_nonref = (*fee_earned_msat).clone();
-                               let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else {  { crate::c_types::derived::COption_u64Z::Some(fee_earned_msat_nonref.unwrap()) } };
+                               let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat_nonref.unwrap() }) };
                                let mut claim_from_onchain_tx_nonref = (*claim_from_onchain_tx).clone();
                                Event::PaymentForwarded {
                                        fee_earned_msat: local_fee_earned_msat_nonref,
                                        claim_from_onchain_tx: claim_from_onchain_tx_nonref,
                                }
                        },
+                       nativeEvent::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => {
+                               let mut channel_id_nonref = (*channel_id).clone();
+                               let mut user_channel_id_nonref = (*user_channel_id).clone();
+                               let mut reason_nonref = (*reason).clone();
+                               Event::ChannelClosed {
+                                       channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
+                                       user_channel_id: user_channel_id_nonref,
+                                       reason: crate::lightning::util::events::ClosureReason::native_into(reason_nonref),
+                               }
+                       },
+                       nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => {
+                               let mut channel_id_nonref = (*channel_id).clone();
+                               let mut transaction_nonref = (*transaction).clone();
+                               Event::DiscardFunding {
+                                       channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
+                                       transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref),
+                               }
+                       },
                }
        }
        #[allow(unused)]
@@ -464,15 +776,23 @@ impl Event {
                                        purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose),
                                }
                        },
-                       nativeEvent::PaymentSent {mut payment_preimage, } => {
+                       nativeEvent::PaymentSent {mut payment_preimage, mut payment_hash, } => {
                                Event::PaymentSent {
                                        payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
+                                       payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
                                }
                        },
-                       nativeEvent::PaymentFailed {mut payment_hash, mut rejected_by_dest, } => {
-                               Event::PaymentFailed {
+                       nativeEvent::PaymentPathFailed {mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, } => {
+                               let mut local_network_update = if network_update.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::network_graph::NetworkUpdate::native_into(network_update.unwrap()) }) };
+                               let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+                               let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) };
+                               Event::PaymentPathFailed {
                                        payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
                                        rejected_by_dest: rejected_by_dest,
+                                       network_update: local_network_update,
+                                       all_paths_failed: all_paths_failed,
+                                       path: local_path.into(),
+                                       short_channel_id: local_short_channel_id,
                                }
                        },
                        nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
@@ -487,12 +807,25 @@ impl Event {
                                }
                        },
                        nativeEvent::PaymentForwarded {mut fee_earned_msat, mut claim_from_onchain_tx, } => {
-                               let mut local_fee_earned_msat = if fee_earned_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else {  { crate::c_types::derived::COption_u64Z::Some(fee_earned_msat.unwrap()) } };
+                               let mut local_fee_earned_msat = if fee_earned_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat.unwrap() }) };
                                Event::PaymentForwarded {
                                        fee_earned_msat: local_fee_earned_msat,
                                        claim_from_onchain_tx: claim_from_onchain_tx,
                                }
                        },
+                       nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => {
+                               Event::ChannelClosed {
+                                       channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
+                                       user_channel_id: user_channel_id,
+                                       reason: crate::lightning::util::events::ClosureReason::native_into(reason),
+                               }
+                       },
+                       nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => {
+                               Event::DiscardFunding {
+                                       channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
+                                       transaction: crate::c_types::Transaction::from_bitcoin(&transaction),
+                               }
+                       },
                }
        }
 }
@@ -525,17 +858,22 @@ pub extern "C" fn Event_payment_received(payment_hash: crate::c_types::ThirtyTwo
 }
 #[no_mangle]
 /// Utility method to constructs a new PaymentSent-variant Event
-pub extern "C" fn Event_payment_sent(payment_preimage: crate::c_types::ThirtyTwoBytes) -> Event {
+pub extern "C" fn Event_payment_sent(payment_preimage: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes) -> Event {
        Event::PaymentSent {
                payment_preimage,
+               payment_hash,
        }
 }
 #[no_mangle]
-/// Utility method to constructs a new PaymentFailed-variant Event
-pub extern "C" fn Event_payment_failed(payment_hash: crate::c_types::ThirtyTwoBytes, rejected_by_dest: bool) -> Event {
-       Event::PaymentFailed {
+/// Utility method to constructs a new PaymentPathFailed-variant Event
+pub extern "C" fn Event_payment_path_failed(payment_hash: crate::c_types::ThirtyTwoBytes, rejected_by_dest: bool, network_update: crate::c_types::derived::COption_NetworkUpdateZ, all_paths_failed: bool, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event {
+       Event::PaymentPathFailed {
                payment_hash,
                rejected_by_dest,
+               network_update,
+               all_paths_failed,
+               path,
+               short_channel_id,
        }
 }
 #[no_mangle]
@@ -561,6 +899,23 @@ pub extern "C" fn Event_payment_forwarded(fee_earned_msat: crate::c_types::deriv
        }
 }
 #[no_mangle]
+/// Utility method to constructs a new ChannelClosed-variant Event
+pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: u64, reason: crate::lightning::util::events::ClosureReason) -> Event {
+       Event::ChannelClosed {
+               channel_id,
+               user_channel_id,
+               reason,
+       }
+}
+#[no_mangle]
+/// Utility method to constructs a new DiscardFunding-variant Event
+pub extern "C" fn Event_discard_funding(channel_id: crate::c_types::ThirtyTwoBytes, transaction: crate::c_types::Transaction) -> Event {
+       Event::DiscardFunding {
+               channel_id,
+               transaction,
+       }
+}
+#[no_mangle]
 /// Serialize the Event object into a byte array which can be read by Event_read
 pub extern "C" fn Event_write(obj: &Event) -> crate::c_types::derived::CVec_u8Z {
        crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
@@ -692,12 +1047,6 @@ pub enum MessageSendEvent {
                /// The action which should be taken.
                action: crate::lightning::ln::msgs::ErrorAction,
        },
-       /// When a payment fails we may receive updates back from the hop where it failed. In such
-       /// cases this event is generated so that we can inform the network graph of this information.
-       PaymentFailureNetworkUpdate {
-               /// The channel/node update which should be sent to NetGraphMsgHandler
-               update: crate::lightning::ln::msgs::HTLCFailChannelUpdate,
-       },
        /// Query a peer for channels with funding transaction UTXOs in a block range.
        SendChannelRangeQuery {
                /// The node_id of this message recipient
@@ -851,12 +1200,6 @@ impl MessageSendEvent {
                                        action: action_nonref.into_native(),
                                }
                        },
-                       MessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
-                               let mut update_nonref = (*update).clone();
-                               nativeMessageSendEvent::PaymentFailureNetworkUpdate {
-                                       update: update_nonref.into_native(),
-                               }
-                       },
                        MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
                                let mut node_id_nonref = (*node_id).clone();
                                let mut msg_nonref = (*msg).clone();
@@ -980,11 +1323,6 @@ impl MessageSendEvent {
                                        action: action.into_native(),
                                }
                        },
-                       MessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
-                               nativeMessageSendEvent::PaymentFailureNetworkUpdate {
-                                       update: update.into_native(),
-                               }
-                       },
                        MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
                                nativeMessageSendEvent::SendChannelRangeQuery {
                                        node_id: node_id.into_rust(),
@@ -1013,7 +1351,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendAcceptChannel {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
@@ -1021,7 +1359,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendOpenChannel {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
@@ -1029,7 +1367,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendFundingCreated {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
@@ -1037,7 +1375,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendFundingSigned {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendFundingLocked {ref node_id, ref msg, } => {
@@ -1045,7 +1383,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendFundingLocked {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::FundingLocked { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
@@ -1053,7 +1391,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendAnnouncementSignatures {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
@@ -1061,7 +1399,7 @@ impl MessageSendEvent {
                                let mut updates_nonref = (*updates).clone();
                                MessageSendEvent::UpdateHTLCs {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: Box::into_raw(Box::new(updates_nonref)), is_owned: true },
+                                       updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
@@ -1069,7 +1407,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendRevokeAndACK {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
@@ -1077,7 +1415,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendClosingSigned {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
@@ -1085,7 +1423,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendShutdown {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
@@ -1093,27 +1431,27 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendChannelReestablish {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
                                let mut msg_nonref = (*msg).clone();
                                let mut update_msg_nonref = (*update_msg).clone();
                                MessageSendEvent::BroadcastChannelAnnouncement {
-                                       msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
-                                       update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(update_msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+                                       update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::BroadcastNodeAnnouncement {
-                                       msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::BroadcastChannelUpdate {
-                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => {
@@ -1121,7 +1459,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendChannelUpdate {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::HandleError {ref node_id, ref action, } => {
@@ -1132,18 +1470,12 @@ impl MessageSendEvent {
                                        action: crate::lightning::ln::msgs::ErrorAction::native_into(action_nonref),
                                }
                        },
-                       nativeMessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
-                               let mut update_nonref = (*update).clone();
-                               MessageSendEvent::PaymentFailureNetworkUpdate {
-                                       update: crate::lightning::ln::msgs::HTLCFailChannelUpdate::native_into(update_nonref),
-                               }
-                       },
                        nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
                                let mut node_id_nonref = (*node_id).clone();
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendChannelRangeQuery {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
@@ -1151,7 +1483,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendShortIdsQuery {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
@@ -1159,7 +1491,7 @@ impl MessageSendEvent {
                                let mut msg_nonref = (*msg).clone();
                                MessageSendEvent::SendReplyChannelRange {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                }
@@ -1170,89 +1502,89 @@ impl MessageSendEvent {
                        nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
                                MessageSendEvent::SendAcceptChannel {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
                                MessageSendEvent::SendOpenChannel {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
                                MessageSendEvent::SendFundingCreated {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
                                MessageSendEvent::SendFundingSigned {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendFundingLocked {mut node_id, mut msg, } => {
                                MessageSendEvent::SendFundingLocked {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::FundingLocked { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
                                MessageSendEvent::SendAnnouncementSignatures {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
                                MessageSendEvent::UpdateHTLCs {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: Box::into_raw(Box::new(updates)), is_owned: true },
+                                       updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
                                MessageSendEvent::SendRevokeAndACK {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
                                MessageSendEvent::SendClosingSigned {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
                                MessageSendEvent::SendShutdown {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
                                MessageSendEvent::SendChannelReestablish {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
                                MessageSendEvent::BroadcastChannelAnnouncement {
-                                       msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true },
-                                       update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(update_msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
+                                       update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
                                MessageSendEvent::BroadcastNodeAnnouncement {
-                                       msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
                                MessageSendEvent::BroadcastChannelUpdate {
-                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => {
                                MessageSendEvent::SendChannelUpdate {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::HandleError {mut node_id, mut action, } => {
@@ -1261,27 +1593,22 @@ impl MessageSendEvent {
                                        action: crate::lightning::ln::msgs::ErrorAction::native_into(action),
                                }
                        },
-                       nativeMessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
-                               MessageSendEvent::PaymentFailureNetworkUpdate {
-                                       update: crate::lightning::ln::msgs::HTLCFailChannelUpdate::native_into(update),
-                               }
-                       },
                        nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
                                MessageSendEvent::SendChannelRangeQuery {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
                                MessageSendEvent::SendShortIdsQuery {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                        nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
                                MessageSendEvent::SendReplyChannelRange {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+                                       msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
                }
@@ -1422,13 +1749,6 @@ pub extern "C" fn MessageSendEvent_handle_error(node_id: crate::c_types::PublicK
        }
 }
 #[no_mangle]
-/// Utility method to constructs a new PaymentFailureNetworkUpdate-variant MessageSendEvent
-pub extern "C" fn MessageSendEvent_payment_failure_network_update(update: crate::lightning::ln::msgs::HTLCFailChannelUpdate) -> MessageSendEvent {
-       MessageSendEvent::PaymentFailureNetworkUpdate {
-               update,
-       }
-}
-#[no_mangle]
 /// Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent
 pub extern "C" fn MessageSendEvent_send_channel_range_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> MessageSendEvent {
        MessageSendEvent::SendChannelRangeQuery {
@@ -1574,7 +1894,7 @@ pub struct EventHandler {
        /// Handles the given [`Event`].
        ///
        /// See [`EventsProvider`] for details that must be considered when implementing this method.
-       pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::util::events::Event),
+       pub handle_event: extern "C" fn (this_arg: *const c_void, event: &crate::lightning::util::events::Event),
        /// Frees any resources associated with this object given its this_arg pointer.
        /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
        pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
@@ -1592,8 +1912,8 @@ pub(crate) extern "C" fn EventHandler_clone_fields(orig: &EventHandler) -> Event
 
 use lightning::util::events::EventHandler as rustEventHandler;
 impl rustEventHandler for EventHandler {
-       fn handle_event(&self, mut event: lightning::util::events::Event) {
-               (self.handle_event)(self.this_arg, crate::lightning::util::events::Event::native_into(event))
+       fn handle_event(&self, mut event: &lightning::util::events::Event) {
+               (self.handle_event)(self.this_arg, &crate::lightning::util::events::Event::from_native(event))
        }
 }