X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning-c-bindings%2Fsrc%2Fln%2Fchan_utils.rs;h=f9e6c407ef036df18c28e437c1d18ea2bec19543;hb=3c4a0c1fb30452d77177edc09b2f321e6502ac08;hp=038ad71c051d27f53e36f683ea4bcf3d70c0e2f3;hpb=5988789a2d0bc5121e6e56c1707396b8188027e1;p=rust-lightning diff --git a/lightning-c-bindings/src/ln/chan_utils.rs b/lightning-c-bindings/src/ln/chan_utils.rs index 038ad71c..f9e6c407 100644 --- a/lightning-c-bindings/src/ln/chan_utils.rs +++ b/lightning-c-bindings/src/ln/chan_utils.rs @@ -133,6 +133,10 @@ impl Clone for TxCreationKeys { pub(crate) extern "C" fn TxCreationKeys_clone_void(this_ptr: *const c_void) -> *mut c_void { Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxCreationKeys)).clone() })) as *mut c_void } +#[no_mangle] +pub extern "C" fn TxCreationKeys_clone(orig: &TxCreationKeys) -> TxCreationKeys { + TxCreationKeys { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} /// The broadcaster's per-commitment public key which was used to derive the other keys. #[no_mangle] pub extern "C" fn TxCreationKeys_get_per_commitment_point(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { @@ -256,6 +260,23 @@ impl PreCalculatedTxCreationKeys { ret } } +impl Clone for PreCalculatedTxCreationKeys { + fn clone(&self) -> Self { + Self { + inner: Box::into_raw(Box::new(unsafe { &*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 PreCalculatedTxCreationKeys_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePreCalculatedTxCreationKeys)).clone() })) as *mut c_void +} +#[no_mangle] +pub extern "C" fn PreCalculatedTxCreationKeys_clone(orig: &PreCalculatedTxCreationKeys) -> PreCalculatedTxCreationKeys { + PreCalculatedTxCreationKeys { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} /// Create a new PreCalculatedTxCreationKeys from TxCreationKeys #[must_use] #[no_mangle] @@ -332,6 +353,10 @@ impl Clone for ChannelPublicKeys { pub(crate) extern "C" fn ChannelPublicKeys_clone_void(this_ptr: *const c_void) -> *mut c_void { Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelPublicKeys)).clone() })) as *mut c_void } +#[no_mangle] +pub extern "C" fn ChannelPublicKeys_clone(orig: &ChannelPublicKeys) -> ChannelPublicKeys { + ChannelPublicKeys { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} /// The public key which is used to sign all commitment transactions, as it appears in the /// on-chain channel lock-in 2-of-2 multisig output. #[no_mangle] @@ -497,6 +522,10 @@ impl Clone for HTLCOutputInCommitment { pub(crate) extern "C" fn HTLCOutputInCommitment_clone_void(this_ptr: *const c_void) -> *mut c_void { Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCOutputInCommitment)).clone() })) as *mut c_void } +#[no_mangle] +pub extern "C" fn HTLCOutputInCommitment_clone(orig: &HTLCOutputInCommitment) -> HTLCOutputInCommitment { + HTLCOutputInCommitment { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} /// Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). /// Note that this is not the same as whether it is ountbound *from us*. To determine that you /// need to compare this value to whether the commitment transaction in question is that of @@ -638,6 +667,10 @@ impl Clone for HolderCommitmentTransaction { pub(crate) extern "C" fn HolderCommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void { Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHolderCommitmentTransaction)).clone() })) as *mut c_void } +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_clone(orig: &HolderCommitmentTransaction) -> HolderCommitmentTransaction { + HolderCommitmentTransaction { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} /// The commitment transaction itself, in unsigned form. #[no_mangle] pub extern "C" fn HolderCommitmentTransaction_get_unsigned_tx(this_ptr: &HolderCommitmentTransaction) -> crate::c_types::Transaction {