Merge pull request #68 from jkczyz/2022-03-ldk-0-0-106
[ldk-c-bindings] / lightning-c-bindings / src / lightning / ln / channelmanager.rs
index ddf271c3c4f875b731e741870d0b9076de1cbde9..2b91ced5d4596b9e84b55599087b27578ec02708 100644 (file)
 //! imply it needs to fail HTLCs/payments/channels it manages).
 //!
 
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
 use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
 
 mod inbound_payment {
 
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
 use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
 
 }
 
@@ -114,7 +118,7 @@ impl ChannelManager {
        pub(crate) fn take_inner(mut self) -> *mut nativeChannelManager {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -169,7 +173,7 @@ impl ChainParameters {
        pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -211,7 +215,7 @@ pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network::
 impl Clone for ChainParameters {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeChainParameters>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeChainParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -298,7 +302,7 @@ impl CounterpartyForwardingInfo {
        pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyForwardingInfo {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -352,7 +356,7 @@ pub extern "C" fn CounterpartyForwardingInfo_new(mut fee_base_msat_arg: u32, mut
 impl Clone for CounterpartyForwardingInfo {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -416,7 +420,7 @@ impl ChannelCounterparty {
        pub(crate) fn take_inner(mut self) -> *mut nativeChannelCounterparty {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -476,7 +480,7 @@ pub extern "C" fn ChannelCounterparty_set_unspendable_punishment_reserve(this_pt
 #[no_mangle]
 pub extern "C" fn ChannelCounterparty_get_forwarding_info(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::channelmanager::CounterpartyForwardingInfo {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_info;
-       let mut local_inner_val = crate::lightning::ln::channelmanager::CounterpartyForwardingInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::channelmanager::CounterpartyForwardingInfo<>) as *mut _ }, is_owned: false };
+       let mut local_inner_val = crate::lightning::ln::channelmanager::CounterpartyForwardingInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::channelmanager::CounterpartyForwardingInfo<>) as *mut _ }, is_owned: false };
        local_inner_val
 }
 /// Information on the fees and requirements that the counterparty requires when forwarding
@@ -503,7 +507,7 @@ pub extern "C" fn ChannelCounterparty_new(mut node_id_arg: crate::c_types::Publi
 impl Clone for ChannelCounterparty {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -566,7 +570,7 @@ impl ChannelDetails {
        pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -608,7 +612,7 @@ pub extern "C" fn ChannelDetails_set_counterparty(this_ptr: &mut ChannelDetails,
 #[no_mangle]
 pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txo;
-       let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false };
+       let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false };
        local_inner_val
 }
 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
@@ -623,8 +627,35 @@ pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails,
        let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txo = local_val;
 }
+/// The features which this channel operates with. See individual features for more info.
+///
+/// `None` until negotiation completes and the channel type is finalized.
+///
+/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::ChannelTypeFeatures {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
+       let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
+       local_inner_val
+}
+/// The features which this channel operates with. See individual features for more info.
+///
+/// `None` until negotiation completes and the channel type is finalized.
+///
+/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
+       let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
+}
 /// The position of the funding transaction in the chain. None if the funding transaction has
 /// not yet been confirmed and the channel fully opened.
+///
+/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
+/// payments instead of this. See [`get_inbound_payment_scid`].
+///
+/// [`inbound_scid_alias`]: Self::inbound_scid_alias
+/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
 #[no_mangle]
 pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
@@ -633,11 +664,46 @@ pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails)
 }
 /// The position of the funding transaction in the chain. None if the funding transaction has
 /// not yet been confirmed and the channel fully opened.
+///
+/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
+/// payments instead of this. See [`get_inbound_payment_scid`].
+///
+/// [`inbound_scid_alias`]: Self::inbound_scid_alias
+/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
 #[no_mangle]
 pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
        let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = local_val;
 }
+/// An optional [`short_channel_id`] alias for this channel, randomly generated by our
+/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
+/// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
+/// when they see a payment to be routed to us.
+///
+/// Our counterparty may choose to rotate this value at any time, though will always recognize
+/// previous values for inbound payment forwarding.
+///
+/// [`short_channel_id`]: Self::short_channel_id
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_inbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_scid_alias;
+       let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+       local_inner_val
+}
+/// An optional [`short_channel_id`] alias for this channel, randomly generated by our
+/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
+/// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
+/// when they see a payment to be routed to us.
+///
+/// Our counterparty may choose to rotate this value at any time, though will always recognize
+/// previous values for inbound payment forwarding.
+///
+/// [`short_channel_id`]: Self::short_channel_id
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_inbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
+       let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_scid_alias = local_val;
+}
 /// The value, in satoshis, of this channel as appears in the funding output
 #[no_mangle]
 pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 {
@@ -897,9 +963,11 @@ pub extern "C" fn ChannelDetails_set_is_public(this_ptr: &mut ChannelDetails, mu
 /// Constructs a new ChannelDetails given each field
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: u64, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_funding_locked_arg: bool, mut is_usable_arg: bool, mut is_public_arg: bool) -> ChannelDetails {
+pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: u64, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_funding_locked_arg: bool, mut is_usable_arg: bool, mut is_public_arg: bool) -> ChannelDetails {
        let mut local_funding_txo_arg = if funding_txo_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_txo_arg.take_inner()) } }) };
+       let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
        let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None };
+       let mut local_inbound_scid_alias_arg = if inbound_scid_alias_arg.is_some() { Some( { inbound_scid_alias_arg.take() }) } else { None };
        let mut local_unspendable_punishment_reserve_arg = if unspendable_punishment_reserve_arg.is_some() { Some( { unspendable_punishment_reserve_arg.take() }) } else { None };
        let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None };
        let mut local_force_close_spend_delay_arg = if force_close_spend_delay_arg.is_some() { Some( { force_close_spend_delay_arg.take() }) } else { None };
@@ -907,7 +975,9 @@ pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyT
                channel_id: channel_id_arg.data,
                counterparty: *unsafe { Box::from_raw(counterparty_arg.take_inner()) },
                funding_txo: local_funding_txo_arg,
+               channel_type: local_channel_type_arg,
                short_channel_id: local_short_channel_id_arg,
+               inbound_scid_alias: local_inbound_scid_alias_arg,
                channel_value_satoshis: channel_value_satoshis_arg,
                unspendable_punishment_reserve: local_unspendable_punishment_reserve_arg,
                user_channel_id: user_channel_id_arg,
@@ -925,7 +995,7 @@ pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyT
 impl Clone for ChannelDetails {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeChannelDetails>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeChannelDetails>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -941,6 +1011,20 @@ pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *
 pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails {
        orig.clone()
 }
+/// Gets the current SCID which should be used to identify this channel for inbound payments.
+/// This should be used for providing invoice hints or in any other context where our
+/// counterparty will forward a payment to us.
+///
+/// This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the
+/// [`ChannelDetails::short_channel_id`]. See those for more information.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_inbound_payment_scid(this_arg: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_inbound_payment_scid();
+       let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
+       local_ret
+}
+
 /// If a payment fails to send, it can be in one of several states. This enum is returned as the
 /// Err() type describing which state the payment is in, see the description of individual enum
 /// states for more.
@@ -1086,7 +1170,7 @@ impl PaymentSendFailure {
                                let mut results_nonref = (*results).clone();
                                let mut local_results_nonref = Vec::new(); for mut item in results_nonref.drain(..) { local_results_nonref.push( { let mut local_results_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_results_nonref_0 }); };
                                let mut failed_paths_retry_nonref = (*failed_paths_retry).clone();
-                               let mut local_failed_paths_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry_nonref.is_none() { std::ptr::null_mut() } else {  { ObjOps::heap_alloc((failed_paths_retry_nonref.unwrap())) } }, is_owned: true };
+                               let mut local_failed_paths_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry_nonref.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((failed_paths_retry_nonref.unwrap())) } }, is_owned: true };
                                let mut payment_id_nonref = (*payment_id).clone();
                                PaymentSendFailure::PartialFailure {
                                        results: local_results_nonref.into(),
@@ -1118,7 +1202,7 @@ impl PaymentSendFailure {
                        },
                        nativePaymentSendFailure::PartialFailure {mut results, mut failed_paths_retry, mut payment_id, } => {
                                let mut local_results = Vec::new(); for mut item in results.drain(..) { local_results.push( { let mut local_results_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_results_0 }); };
-                               let mut local_failed_paths_retry = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry.is_none() { std::ptr::null_mut() } else {  { ObjOps::heap_alloc((failed_paths_retry.unwrap())) } }, is_owned: true };
+                               let mut local_failed_paths_retry = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((failed_paths_retry.unwrap())) } }, is_owned: true };
                                PaymentSendFailure::PartialFailure {
                                        results: local_results.into(),
                                        failed_paths_retry: local_failed_paths_retry,
@@ -1160,6 +1244,126 @@ pub extern "C" fn PaymentSendFailure_partial_failure(results: crate::c_types::de
                payment_id,
        }
 }
+
+use lightning::ln::channelmanager::PhantomRouteHints as nativePhantomRouteHintsImport;
+pub(crate) type nativePhantomRouteHints = nativePhantomRouteHintsImport;
+
+/// Route hints used in constructing invoices for [phantom node payents].
+///
+/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
+#[must_use]
+#[repr(C)]
+pub struct PhantomRouteHints {
+       /// A pointer to the opaque Rust object.
+
+       /// Nearly everywhere, inner must be non-null, however in places where
+       /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+       pub inner: *mut nativePhantomRouteHints,
+       /// Indicates that this is the only struct which contains the same pointer.
+
+       /// Rust functions which take ownership of an object provided via an argument require
+       /// this to be true and invalidate the object pointed to by inner.
+       pub is_owned: bool,
+}
+
+impl Drop for PhantomRouteHints {
+       fn drop(&mut self) {
+               if self.is_owned && !<*mut nativePhantomRouteHints>::is_null(self.inner) {
+                       let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+               }
+       }
+}
+/// Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_free(this_obj: PhantomRouteHints) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn PhantomRouteHints_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = Box::from_raw(this_ptr as *mut nativePhantomRouteHints); }
+}
+#[allow(unused)]
+impl PhantomRouteHints {
+       pub(crate) fn get_native_ref(&self) -> &'static nativePhantomRouteHints {
+               unsafe { &*ObjOps::untweak_ptr(self.inner) }
+       }
+       pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePhantomRouteHints {
+               unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+       }
+       /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+       pub(crate) fn take_inner(mut self) -> *mut nativePhantomRouteHints {
+               assert!(self.is_owned);
+               let ret = ObjOps::untweak_ptr(self.inner);
+               self.inner = core::ptr::null_mut();
+               ret
+       }
+}
+/// The list of channels to be included in the invoice route hints.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_get_channels(this_ptr: &PhantomRouteHints) -> crate::c_types::derived::CVec_ChannelDetailsZ {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().channels;
+       let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); };
+       local_inner_val.into()
+}
+/// The list of channels to be included in the invoice route hints.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_set_channels(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::derived::CVec_ChannelDetailsZ) {
+       let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channels = local_val;
+}
+/// A fake scid used for representing the phantom node's fake channel in generating the invoice
+/// route hints.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_get_phantom_scid(this_ptr: &PhantomRouteHints) -> u64 {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().phantom_scid;
+       *inner_val
+}
+/// A fake scid used for representing the phantom node's fake channel in generating the invoice
+/// route hints.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_set_phantom_scid(this_ptr: &mut PhantomRouteHints, mut val: u64) {
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.phantom_scid = val;
+}
+/// The pubkey of the real backing node that would ultimately receive the payment.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_get_real_node_pubkey(this_ptr: &PhantomRouteHints) -> crate::c_types::PublicKey {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().real_node_pubkey;
+       crate::c_types::PublicKey::from_rust(&inner_val)
+}
+/// The pubkey of the real backing node that would ultimately receive the payment.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_set_real_node_pubkey(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::PublicKey) {
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.real_node_pubkey = val.into_rust();
+}
+/// Constructs a new PhantomRouteHints given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_new(mut channels_arg: crate::c_types::derived::CVec_ChannelDetailsZ, mut phantom_scid_arg: u64, mut real_node_pubkey_arg: crate::c_types::PublicKey) -> PhantomRouteHints {
+       let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+       PhantomRouteHints { inner: ObjOps::heap_alloc(nativePhantomRouteHints {
+               channels: local_channels_arg,
+               phantom_scid: phantom_scid_arg,
+               real_node_pubkey: real_node_pubkey_arg.into_rust(),
+       }), is_owned: true }
+}
+impl Clone for PhantomRouteHints {
+       fn clone(&self) -> Self {
+               Self {
+                       inner: if <*mut nativePhantomRouteHints>::is_null(self.inner) { core::ptr::null_mut() } else {
+                               ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+                       is_owned: true,
+               }
+       }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn PhantomRouteHints_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePhantomRouteHints)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the PhantomRouteHints
+pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRouteHints {
+       orig.clone()
+}
 /// Constructs a new ChannelManager to hold several channels and route between them.
 ///
 /// This is the main \"logic hub\" for all channel-related actions, and implements
@@ -1549,6 +1753,25 @@ pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &ChannelManager) -> c
        crate::c_types::PublicKey::from_rust(&ret)
 }
 
+/// Called to accept a request to open a channel after [`Event::OpenChannelRequest`] has been
+/// triggered.
+///
+/// The `temporary_channel_id` parameter indicates which inbound channel should be accepted.
+///
+/// For inbound channels, the `user_channel_id` parameter will be provided back in
+/// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
+/// with which `accept_inbound_channel` call.
+///
+/// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
+/// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_accept_inbound_channel(this_arg: &ChannelManager, temporary_channel_id: *const [u8; 32], mut user_channel_id: u64) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel(unsafe { &*temporary_channel_id}, user_channel_id);
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
+       local_ret
+}
+
 /// Gets a payment secret and payment hash for use in an invoice given to a third party wishing
 /// to pay us.
 ///
@@ -1587,6 +1810,8 @@ pub extern "C" fn ChannelManager_create_inbound_payment(this_arg: &ChannelManage
 /// Legacy version of [`create_inbound_payment`]. Use this method if you wish to share
 /// serialized state with LDK node(s) running 0.0.103 and earlier.
 ///
+/// May panic if `invoice_expiry_delta_secs` is greater than one year.
+///
 /// # Note
 /// This method is deprecated and will be removed soon.
 ///
@@ -1628,8 +1853,6 @@ pub extern "C" fn ChannelManager_create_inbound_payment_legacy(this_arg: &Channe
 /// If you need exact expiry semantics, you should enforce them upon receipt of
 /// [`PaymentReceived`].
 ///
-/// May panic if `invoice_expiry_delta_secs` is greater than one year.
-///
 /// Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
 /// set to at least [`MIN_FINAL_CLTV_EXPIRY`].
 ///
@@ -1657,6 +1880,8 @@ pub extern "C" fn ChannelManager_create_inbound_payment_for_hash(this_arg: &Chan
 /// Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share
 /// serialized state with LDK node(s) running 0.0.103 and earlier.
 ///
+/// May panic if `invoice_expiry_delta_secs` is greater than one year.
+///
 /// # Note
 /// This method is deprecated and will be removed soon.
 ///
@@ -1682,12 +1907,33 @@ pub extern "C" fn ChannelManager_get_payment_preimage(this_arg: &ChannelManager,
        local_ret
 }
 
+/// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
+/// are used when constructing the phantom invoice's route hints.
+///
+/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_get_phantom_scid(this_arg: &ChannelManager) -> u64 {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_scid();
+       ret
+}
+
+/// Gets route hints for use in receiving [phantom node payments].
+///
+/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_get_phantom_route_hints(this_arg: &ChannelManager) -> crate::lightning::ln::channelmanager::PhantomRouteHints {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_route_hints();
+       crate::lightning::ln::channelmanager::PhantomRouteHints { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
 impl From<nativeChannelManager> for crate::lightning::util::events::MessageSendEventsProvider {
        fn from(obj: nativeChannelManager) -> Self {
                let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = ChannelManager_as_MessageSendEventsProvider(&rust_obj);
                // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
-               rust_obj.inner = std::ptr::null_mut();
+               rust_obj.inner = core::ptr::null_mut();
                ret.free = Some(ChannelManager_free_void);
                ret
        }
@@ -1715,7 +1961,7 @@ impl From<nativeChannelManager> for crate::lightning::util::events::EventsProvid
                let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = ChannelManager_as_EventsProvider(&rust_obj);
                // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
-               rust_obj.inner = std::ptr::null_mut();
+               rust_obj.inner = core::ptr::null_mut();
                ret.free = Some(ChannelManager_free_void);
                ret
        }
@@ -1740,7 +1986,7 @@ impl From<nativeChannelManager> for crate::lightning::chain::Listen {
                let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = ChannelManager_as_Listen(&rust_obj);
                // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
-               rust_obj.inner = std::ptr::null_mut();
+               rust_obj.inner = core::ptr::null_mut();
                ret.free = Some(ChannelManager_free_void);
                ret
        }
@@ -1769,7 +2015,7 @@ impl From<nativeChannelManager> for crate::lightning::chain::Confirm {
                let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = ChannelManager_as_Confirm(&rust_obj);
                // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
-               rust_obj.inner = std::ptr::null_mut();
+               rust_obj.inner = core::ptr::null_mut();
                ret.free = Some(ChannelManager_free_void);
                ret
        }
@@ -1814,7 +2060,7 @@ extern "C" fn ChannelManager_Confirm_transaction_unconfirmed(this_arg: *const c_
 #[must_use]
 #[no_mangle]
 pub extern "C" fn ChannelManager_await_persistable_update_timeout(this_arg: &ChannelManager, mut max_wait: u64) -> bool {
-       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.await_persistable_update_timeout(std::time::Duration::from_secs(max_wait));
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.await_persistable_update_timeout(core::time::Duration::from_secs(max_wait));
        ret
 }
 
@@ -1840,7 +2086,7 @@ impl From<nativeChannelManager> for crate::lightning::ln::msgs::ChannelMessageHa
                let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = ChannelManager_as_ChannelMessageHandler(&rust_obj);
                // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
-               rust_obj.inner = std::ptr::null_mut();
+               rust_obj.inner = core::ptr::null_mut();
                ret.free = Some(ChannelManager_free_void);
                ret
        }
@@ -1941,6 +2187,70 @@ extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const
        <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
 }
 
+#[no_mangle]
+/// Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read
+pub extern "C" fn CounterpartyForwardingInfo_write(obj: &CounterpartyForwardingInfo) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn CounterpartyForwardingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyForwardingInfo) })
+}
+#[no_mangle]
+/// Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write
+pub extern "C" fn CounterpartyForwardingInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyForwardingInfoDecodeErrorZ {
+       let res: Result<lightning::ln::channelmanager::CounterpartyForwardingInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+       local_res
+}
+#[no_mangle]
+/// Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read
+pub extern "C" fn ChannelCounterparty_write(obj: &ChannelCounterparty) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn ChannelCounterparty_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelCounterparty) })
+}
+#[no_mangle]
+/// Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write
+pub extern "C" fn ChannelCounterparty_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelCounterpartyDecodeErrorZ {
+       let res: Result<lightning::ln::channelmanager::ChannelCounterparty, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::ChannelCounterparty { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+       local_res
+}
+#[no_mangle]
+/// Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read
+pub extern "C" fn ChannelDetails_write(obj: &ChannelDetails) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn ChannelDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDetails) })
+}
+#[no_mangle]
+/// Read a ChannelDetails from a byte array, created by ChannelDetails_write
+pub extern "C" fn ChannelDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelDetailsDecodeErrorZ {
+       let res: Result<lightning::ln::channelmanager::ChannelDetails, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+       local_res
+}
+#[no_mangle]
+/// Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read
+pub extern "C" fn PhantomRouteHints_write(obj: &PhantomRouteHints) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn PhantomRouteHints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePhantomRouteHints) })
+}
+#[no_mangle]
+/// Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write
+pub extern "C" fn PhantomRouteHints_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PhantomRouteHintsDecodeErrorZ {
+       let res: Result<lightning::ln::channelmanager::PhantomRouteHints, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::PhantomRouteHints { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+       local_res
+}
 #[no_mangle]
 /// Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
 pub extern "C" fn ChannelManager_write(obj: &ChannelManager) -> crate::c_types::derived::CVec_u8Z {
@@ -2028,7 +2338,7 @@ impl ChannelManagerReadArgs {
        pub(crate) fn take_inner(mut self) -> *mut nativeChannelManagerReadArgs {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }