+ crate::c_types::Transaction::from_vec(local_ret)
+}
+
+
+use lightning::ln::chan_utils::ChannelTransactionParameters as nativeChannelTransactionParametersImport;
+type nativeChannelTransactionParameters = nativeChannelTransactionParametersImport;
+
+/// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
+/// The fields are organized by holder/counterparty.
+///
+/// Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
+/// before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
+#[must_use]
+#[repr(C)]
+pub struct ChannelTransactionParameters {
+ /// 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 nativeChannelTransactionParameters,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelTransactionParameters {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_free(this_ptr: ChannelTransactionParameters) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelTransactionParameters_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelTransactionParameters); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelTransactionParameters {
+ pub(crate) fn take_inner(mut self) -> *mut nativeChannelTransactionParameters {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ChannelTransactionParameters {
+ 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 ChannelTransactionParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelTransactionParameters)).clone() })) as *mut c_void
+}
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_clone(orig: &ChannelTransactionParameters) -> ChannelTransactionParameters {
+ ChannelTransactionParameters { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
+}
+/// Holder public keys
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_get_holder_pubkeys(this_ptr: &ChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_pubkeys;
+ crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// Holder public keys
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_set_holder_pubkeys(this_ptr: &mut ChannelTransactionParameters, mut val: crate::ln::chan_utils::ChannelPublicKeys) {
+ unsafe { &mut *this_ptr.inner }.holder_pubkeys = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The contest delay selected by the holder, which applies to counterparty-broadcast transactions
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_get_holder_selected_contest_delay(this_ptr: &ChannelTransactionParameters) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_selected_contest_delay;
+ (*inner_val)
+}
+/// The contest delay selected by the holder, which applies to counterparty-broadcast transactions
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_set_holder_selected_contest_delay(this_ptr: &mut ChannelTransactionParameters, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.holder_selected_contest_delay = val;
+}
+/// Whether the holder is the initiator of this channel.
+/// This is an input to the commitment number obscure factor computation.
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_get_is_outbound_from_holder(this_ptr: &ChannelTransactionParameters) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_outbound_from_holder;
+ (*inner_val)
+}
+/// Whether the holder is the initiator of this channel.
+/// This is an input to the commitment number obscure factor computation.
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_set_is_outbound_from_holder(this_ptr: &mut ChannelTransactionParameters, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.is_outbound_from_holder = val;
+}
+/// The late-bound counterparty channel transaction parameters.
+/// These parameters are populated at the point in the protocol where the counterparty provides them.
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_get_counterparty_parameters(this_ptr: &ChannelTransactionParameters) -> crate::ln::chan_utils::CounterpartyChannelTransactionParameters {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_parameters;
+ let mut local_inner_val = crate::ln::chan_utils::CounterpartyChannelTransactionParameters { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// The late-bound counterparty channel transaction parameters.
+/// These parameters are populated at the point in the protocol where the counterparty provides them.
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_set_counterparty_parameters(this_ptr: &mut ChannelTransactionParameters, mut val: crate::ln::chan_utils::CounterpartyChannelTransactionParameters) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *this_ptr.inner }.counterparty_parameters = local_val;
+}
+/// The late-bound funding outpoint
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_get_funding_outpoint(this_ptr: &ChannelTransactionParameters) -> crate::chain::transaction::OutPoint {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_outpoint;
+ let mut local_inner_val = crate::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// The late-bound funding outpoint
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_set_funding_outpoint(this_ptr: &mut ChannelTransactionParameters, mut val: crate::chain::transaction::OutPoint) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *this_ptr.inner }.funding_outpoint = local_val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::chain::transaction::OutPoint) -> ChannelTransactionParameters {
+ let mut local_counterparty_parameters_arg = if counterparty_parameters_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(counterparty_parameters_arg.take_inner()) } }) };
+ let mut local_funding_outpoint_arg = if funding_outpoint_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_outpoint_arg.take_inner()) } }) };
+ ChannelTransactionParameters { inner: Box::into_raw(Box::new(nativeChannelTransactionParameters {
+ holder_pubkeys: *unsafe { Box::from_raw(holder_pubkeys_arg.take_inner()) },
+ holder_selected_contest_delay: holder_selected_contest_delay_arg,
+ is_outbound_from_holder: is_outbound_from_holder_arg,
+ counterparty_parameters: local_counterparty_parameters_arg,
+ funding_outpoint: local_funding_outpoint_arg,
+ })), is_owned: true }
+}
+
+use lightning::ln::chan_utils::CounterpartyChannelTransactionParameters as nativeCounterpartyChannelTransactionParametersImport;
+type nativeCounterpartyChannelTransactionParameters = nativeCounterpartyChannelTransactionParametersImport;
+
+/// Late-bound per-channel counterparty data used to build transactions.
+#[must_use]
+#[repr(C)]
+pub struct CounterpartyChannelTransactionParameters {
+ /// 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 nativeCounterpartyChannelTransactionParameters,
+ pub is_owned: bool,
+}
+
+impl Drop for CounterpartyChannelTransactionParameters {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn CounterpartyChannelTransactionParameters_free(this_ptr: CounterpartyChannelTransactionParameters) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn CounterpartyChannelTransactionParameters_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCounterpartyChannelTransactionParameters); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl CounterpartyChannelTransactionParameters {
+ pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyChannelTransactionParameters {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for CounterpartyChannelTransactionParameters {
+ 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 CounterpartyChannelTransactionParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCounterpartyChannelTransactionParameters)).clone() })) as *mut c_void
+}
+#[no_mangle]
+pub extern "C" fn CounterpartyChannelTransactionParameters_clone(orig: &CounterpartyChannelTransactionParameters) -> CounterpartyChannelTransactionParameters {
+ CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
+}
+/// Counter-party public keys
+#[no_mangle]
+pub extern "C" fn CounterpartyChannelTransactionParameters_get_pubkeys(this_ptr: &CounterpartyChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.pubkeys;
+ crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// Counter-party public keys
+#[no_mangle]
+pub extern "C" fn CounterpartyChannelTransactionParameters_set_pubkeys(this_ptr: &mut CounterpartyChannelTransactionParameters, mut val: crate::ln::chan_utils::ChannelPublicKeys) {
+ unsafe { &mut *this_ptr.inner }.pubkeys = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The contest delay selected by the counterparty, which applies to holder-broadcast transactions
+#[no_mangle]
+pub extern "C" fn CounterpartyChannelTransactionParameters_get_selected_contest_delay(this_ptr: &CounterpartyChannelTransactionParameters) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.selected_contest_delay;
+ (*inner_val)
+}
+/// The contest delay selected by the counterparty, which applies to holder-broadcast transactions
+#[no_mangle]
+pub extern "C" fn CounterpartyChannelTransactionParameters_set_selected_contest_delay(this_ptr: &mut CounterpartyChannelTransactionParameters, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.selected_contest_delay = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn CounterpartyChannelTransactionParameters_new(mut pubkeys_arg: crate::ln::chan_utils::ChannelPublicKeys, mut selected_contest_delay_arg: u16) -> CounterpartyChannelTransactionParameters {
+ CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(nativeCounterpartyChannelTransactionParameters {
+ pubkeys: *unsafe { Box::from_raw(pubkeys_arg.take_inner()) },
+ selected_contest_delay: selected_contest_delay_arg,
+ })), is_owned: true }
+}
+/// Whether the late bound parameters are populated.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_is_populated(this_arg: &ChannelTransactionParameters) -> bool {
+ let mut ret = unsafe { &*this_arg.inner }.is_populated();
+ ret
+}
+
+/// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
+/// given that the holder is the broadcaster.
+///
+/// self.is_populated() must be true before calling this function.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_as_holder_broadcastable(this_arg: &ChannelTransactionParameters) -> crate::ln::chan_utils::DirectedChannelTransactionParameters {
+ let mut ret = unsafe { &*this_arg.inner }.as_holder_broadcastable();
+ crate::ln::chan_utils::DirectedChannelTransactionParameters { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
+/// given that the counterparty is the broadcaster.
+///
+/// self.is_populated() must be true before calling this function.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_as_counterparty_broadcastable(this_arg: &ChannelTransactionParameters) -> crate::ln::chan_utils::DirectedChannelTransactionParameters {
+ let mut ret = unsafe { &*this_arg.inner }.as_counterparty_broadcastable();
+ crate::ln::chan_utils::DirectedChannelTransactionParameters { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+#[no_mangle]
+pub extern "C" fn CounterpartyChannelTransactionParameters_write(obj: *const CounterpartyChannelTransactionParameters) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyChannelTransactionParameters) })
+}
+#[no_mangle]
+pub extern "C" fn CounterpartyChannelTransactionParameters_read(ser: crate::c_types::u8slice) -> CounterpartyChannelTransactionParameters {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ CounterpartyChannelTransactionParameters { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_write(obj: *const ChannelTransactionParameters) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub(crate) extern "C" fn ChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelTransactionParameters) })
+}
+#[no_mangle]
+pub extern "C" fn ChannelTransactionParameters_read(ser: crate::c_types::u8slice) -> ChannelTransactionParameters {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ ChannelTransactionParameters { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ ChannelTransactionParameters { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+
+use lightning::ln::chan_utils::DirectedChannelTransactionParameters as nativeDirectedChannelTransactionParametersImport;
+type nativeDirectedChannelTransactionParameters = nativeDirectedChannelTransactionParametersImport<'static>;
+
+/// Static channel fields used to build transactions given per-commitment fields, organized by
+/// broadcaster/countersignatory.
+///
+/// This is derived from the holder/counterparty-organized ChannelTransactionParameters via the
+/// as_holder_broadcastable and as_counterparty_broadcastable functions.
+#[must_use]
+#[repr(C)]
+pub struct DirectedChannelTransactionParameters {
+ /// 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 nativeDirectedChannelTransactionParameters,
+ pub is_owned: bool,
+}
+
+impl Drop for DirectedChannelTransactionParameters {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn DirectedChannelTransactionParameters_free(this_ptr: DirectedChannelTransactionParameters) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn DirectedChannelTransactionParameters_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectedChannelTransactionParameters); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl DirectedChannelTransactionParameters {
+ pub(crate) fn take_inner(mut self) -> *mut nativeDirectedChannelTransactionParameters {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Get the channel pubkeys for the broadcaster
+#[must_use]
+#[no_mangle]
+pub extern "C" fn DirectedChannelTransactionParameters_broadcaster_pubkeys(this_arg: &DirectedChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys {
+ let mut ret = unsafe { &*this_arg.inner }.broadcaster_pubkeys();
+ crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
+}
+
+/// Get the channel pubkeys for the countersignatory
+#[must_use]
+#[no_mangle]
+pub extern "C" fn DirectedChannelTransactionParameters_countersignatory_pubkeys(this_arg: &DirectedChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys {
+ let mut ret = unsafe { &*this_arg.inner }.countersignatory_pubkeys();
+ crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
+}
+
+/// Get the contest delay applicable to the transactions.
+/// Note that the contest delay was selected by the countersignatory.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn DirectedChannelTransactionParameters_contest_delay(this_arg: &DirectedChannelTransactionParameters) -> u16 {
+ let mut ret = unsafe { &*this_arg.inner }.contest_delay();
+ ret
+}
+
+/// Whether the channel is outbound from the broadcaster.
+///
+/// The boolean representing the side that initiated the channel is
+/// an input to the commitment number obscure factor computation.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn DirectedChannelTransactionParameters_is_outbound(this_arg: &DirectedChannelTransactionParameters) -> bool {
+ let mut ret = unsafe { &*this_arg.inner }.is_outbound();
+ ret
+}
+
+/// The funding outpoint
+#[must_use]
+#[no_mangle]
+pub extern "C" fn DirectedChannelTransactionParameters_funding_outpoint(this_arg: &DirectedChannelTransactionParameters) -> crate::chain::transaction::OutPoint {
+ let mut ret = unsafe { &*this_arg.inner }.funding_outpoint();
+ crate::c_types::bitcoin_to_C_outpoint(ret)