X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Futil%2Fconfig.rs;h=346ddc344a1a70f174cabc29c0e6b63767dc9f74;hb=cb83cfe366aaa07179cac1079694e9ea5c6cc9c6;hp=53a7d940248953725d128faf78a901551a46fab3;hpb=343aacc50c73e18ddb1ec52570c5050bdccd09ca;p=rust-lightning diff --git a/lightning-c-bindings/src/util/config.rs b/lightning-c-bindings/src/util/config.rs index 53a7d940..346ddc34 100644 --- a/lightning-c-bindings/src/util/config.rs +++ b/lightning-c-bindings/src/util/config.rs @@ -15,7 +15,7 @@ type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport; #[must_use] #[repr(C)] pub struct ChannelHandshakeConfig { - /// Nearly everyhwere, inner must be non-null, however in places where + /// 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 nativeChannelHandshakeConfig, pub is_owned: bool, @@ -58,6 +58,10 @@ impl Clone for ChannelHandshakeConfig { pub(crate) extern "C" fn ChannelHandshakeConfig_clone_void(this_ptr: *const c_void) -> *mut c_void { Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeConfig)).clone() })) as *mut c_void } +#[no_mangle] +pub extern "C" fn ChannelHandshakeConfig_clone(orig: &ChannelHandshakeConfig) -> ChannelHandshakeConfig { + ChannelHandshakeConfig { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} /// Confirmations we will wait for before considering the channel locked in. /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the /// equivalent limit applied to outbound channels). @@ -165,7 +169,7 @@ type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport; #[must_use] #[repr(C)] pub struct ChannelHandshakeLimits { - /// Nearly everyhwere, inner must be non-null, however in places where + /// 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 nativeChannelHandshakeLimits, pub is_owned: bool, @@ -208,6 +212,10 @@ impl Clone for ChannelHandshakeLimits { pub(crate) extern "C" fn ChannelHandshakeLimits_clone_void(this_ptr: *const c_void) -> *mut c_void { Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeLimits)).clone() })) as *mut c_void } +#[no_mangle] +pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> ChannelHandshakeLimits { + ChannelHandshakeLimits { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so /// only applies to inbound channels. /// @@ -434,7 +442,7 @@ type nativeChannelConfig = nativeChannelConfigImport; #[must_use] #[repr(C)] pub struct ChannelConfig { - /// Nearly everyhwere, inner must be non-null, however in places where + /// 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 nativeChannelConfig, pub is_owned: bool, @@ -477,6 +485,10 @@ impl Clone for ChannelConfig { pub(crate) extern "C" fn ChannelConfig_clone_void(this_ptr: *const c_void) -> *mut c_void { Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelConfig)).clone() })) as *mut c_void } +#[no_mangle] +pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig { + ChannelConfig { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} /// Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. /// This may be allowed to change at runtime in a later update, however doing so must result in /// update messages sent to notify all nodes of our updated relay fee. @@ -595,7 +607,7 @@ type nativeUserConfig = nativeUserConfigImport; #[must_use] #[repr(C)] pub struct UserConfig { - /// Nearly everyhwere, inner must be non-null, however in places where + /// 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 nativeUserConfig, pub is_owned: bool, @@ -638,6 +650,10 @@ impl Clone for UserConfig { pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut c_void { Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUserConfig)).clone() })) as *mut c_void } +#[no_mangle] +pub extern "C" fn UserConfig_clone(orig: &UserConfig) -> UserConfig { + UserConfig { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} /// Channel config that we propose to our counterparty. #[no_mangle] pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> crate::util::config::ChannelHandshakeConfig {