Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / util / config.rs
index 5e042c83ed74d0c740fdbfb09d747de24fffa553..e8c7546afa5f46d2d3a98e4594d5399d755d0287 100644 (file)
@@ -9,14 +9,17 @@
 //! Various user-configurable channel limits and settings which ChannelManager
 //! applies for you.
 
-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};
 
 
 use lightning::util::config::ChannelHandshakeConfig as nativeChannelHandshakeConfigImport;
-type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport;
+pub(crate) type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport;
 
 /// Configuration we set when applicable.
 ///
@@ -48,7 +51,7 @@ impl Drop for ChannelHandshakeConfig {
 pub extern "C" fn ChannelHandshakeConfig_free(this_obj: ChannelHandshakeConfig) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ChannelHandshakeConfig_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn ChannelHandshakeConfig_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeConfig); }
 }
 #[allow(unused)]
@@ -63,7 +66,7 @@ impl ChannelHandshakeConfig {
        pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeConfig {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -161,7 +164,7 @@ pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our
 impl Clone for ChannelHandshakeConfig {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -185,7 +188,7 @@ pub extern "C" fn ChannelHandshakeConfig_default() -> ChannelHandshakeConfig {
 }
 
 use lightning::util::config::ChannelHandshakeLimits as nativeChannelHandshakeLimitsImport;
-type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
+pub(crate) type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
 
 /// Optional channel limits which are applied during channel creation.
 ///
@@ -225,7 +228,7 @@ impl Drop for ChannelHandshakeLimits {
 pub extern "C" fn ChannelHandshakeLimits_free(this_obj: ChannelHandshakeLimits) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeLimits); }
 }
 #[allow(unused)]
@@ -240,7 +243,7 @@ impl ChannelHandshakeLimits {
        pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeLimits {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -418,7 +421,7 @@ pub extern "C" fn ChannelHandshakeLimits_new(mut min_funding_satoshis_arg: u64,
 impl Clone for ChannelHandshakeLimits {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -442,7 +445,7 @@ pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits {
 }
 
 use lightning::util::config::ChannelConfig as nativeChannelConfigImport;
-type nativeChannelConfig = nativeChannelConfigImport;
+pub(crate) type nativeChannelConfig = nativeChannelConfigImport;
 
 /// Options which apply on a per-channel basis and may change at runtime or based on negotiation
 /// with our counterparty.
@@ -473,7 +476,7 @@ impl Drop for ChannelConfig {
 pub extern "C" fn ChannelConfig_free(this_obj: ChannelConfig) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelConfig); }
 }
 #[allow(unused)]
@@ -488,7 +491,7 @@ impl ChannelConfig {
        pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfig {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -764,7 +767,7 @@ pub extern "C" fn ChannelConfig_new(mut forwarding_fee_proportional_millionths_a
 impl Clone for ChannelConfig {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeChannelConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeChannelConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -798,13 +801,13 @@ pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::
 #[no_mangle]
 /// Read a ChannelConfig from a byte array, created by ChannelConfig_write
 pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelConfigDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
+       let res: Result<lightning::util::config::ChannelConfig, 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::util::config::ChannelConfig { 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
 }
 
 use lightning::util::config::UserConfig as nativeUserConfigImport;
-type nativeUserConfig = nativeUserConfigImport;
+pub(crate) type nativeUserConfig = nativeUserConfigImport;
 
 /// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
 ///
@@ -837,7 +840,7 @@ impl Drop for UserConfig {
 pub extern "C" fn UserConfig_free(this_obj: UserConfig) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUserConfig); }
 }
 #[allow(unused)]
@@ -852,7 +855,7 @@ impl UserConfig {
        pub(crate) fn take_inner(mut self) -> *mut nativeUserConfig {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -860,7 +863,7 @@ impl UserConfig {
 #[no_mangle]
 pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeConfig {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().own_channel_config;
-       crate::lightning::util::config::ChannelHandshakeConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
+       crate::lightning::util::config::ChannelHandshakeConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::config::ChannelHandshakeConfig<>) as *mut _) }, is_owned: false }
 }
 /// Channel config that we propose to our counterparty.
 #[no_mangle]
@@ -871,7 +874,7 @@ pub extern "C" fn UserConfig_set_own_channel_config(this_ptr: &mut UserConfig, m
 #[no_mangle]
 pub extern "C" fn UserConfig_get_peer_channel_config_limits(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeLimits {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().peer_channel_config_limits;
-       crate::lightning::util::config::ChannelHandshakeLimits { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
+       crate::lightning::util::config::ChannelHandshakeLimits { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::config::ChannelHandshakeLimits<>) as *mut _) }, is_owned: false }
 }
 /// Limits applied to our counterparty's proposed channel config settings.
 #[no_mangle]
@@ -882,7 +885,7 @@ pub extern "C" fn UserConfig_set_peer_channel_config_limits(this_ptr: &mut UserC
 #[no_mangle]
 pub extern "C" fn UserConfig_get_channel_options(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelConfig {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_options;
-       crate::lightning::util::config::ChannelConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
+       crate::lightning::util::config::ChannelConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::config::ChannelConfig<>) as *mut _) }, is_owned: false }
 }
 /// Channel config which affects behavior during channel lifetime.
 #[no_mangle]
@@ -930,21 +933,35 @@ pub extern "C" fn UserConfig_get_accept_forwards_to_priv_channels(this_ptr: &Use
 pub extern "C" fn UserConfig_set_accept_forwards_to_priv_channels(this_ptr: &mut UserConfig, mut val: bool) {
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_forwards_to_priv_channels = val;
 }
+/// If this is set to false, we do not accept inbound requests to open a new channel.
+/// Default value: true.
+#[no_mangle]
+pub extern "C" fn UserConfig_get_accept_inbound_channels(this_ptr: &UserConfig) -> bool {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_inbound_channels;
+       *inner_val
+}
+/// If this is set to false, we do not accept inbound requests to open a new channel.
+/// Default value: true.
+#[no_mangle]
+pub extern "C" fn UserConfig_set_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) {
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_inbound_channels = val;
+}
 /// Constructs a new UserConfig given each field
 #[must_use]
 #[no_mangle]
-pub extern "C" fn UserConfig_new(mut own_channel_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut peer_channel_config_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_options_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool) -> UserConfig {
+pub extern "C" fn UserConfig_new(mut own_channel_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut peer_channel_config_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_options_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool) -> UserConfig {
        UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig {
                own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_inner()) },
                peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_inner()) },
                channel_options: *unsafe { Box::from_raw(channel_options_arg.take_inner()) },
                accept_forwards_to_priv_channels: accept_forwards_to_priv_channels_arg,
+               accept_inbound_channels: accept_inbound_channels_arg,
        }), is_owned: true }
 }
 impl Clone for UserConfig {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeUserConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeUserConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }