+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)
+}
+
+
+use lightning::ln::chan_utils::HolderCommitmentTransaction as nativeHolderCommitmentTransactionImport;
+type nativeHolderCommitmentTransaction = nativeHolderCommitmentTransactionImport;
+
+/// Information needed to build and sign a holder's commitment transaction.
+///
+/// The transaction is only signed once we are ready to broadcast.
+#[must_use]
+#[repr(C)]
+pub struct HolderCommitmentTransaction {
+ /// 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 nativeHolderCommitmentTransaction,
+ pub is_owned: bool,
+}
+
+impl Drop for HolderCommitmentTransaction {
+ 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 HolderCommitmentTransaction_free(this_ptr: HolderCommitmentTransaction) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn HolderCommitmentTransaction_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHolderCommitmentTransaction); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl HolderCommitmentTransaction {
+ pub(crate) fn take_inner(mut self) -> *mut nativeHolderCommitmentTransaction {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Our counterparty's signature for the transaction
+#[no_mangle]
+pub extern "C" fn HolderCommitmentTransaction_get_counterparty_sig(this_ptr: &HolderCommitmentTransaction) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_sig;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// Our counterparty's signature for the transaction
+#[no_mangle]
+pub extern "C" fn HolderCommitmentTransaction_set_counterparty_sig(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.counterparty_sig = val.into_rust();
+}
+/// All non-dust counterparty HTLC signatures, in the order they appear in the transaction
+#[no_mangle]
+pub extern "C" fn HolderCommitmentTransaction_set_counterparty_htlc_sigs(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::derived::CVec_SignatureZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
+ unsafe { &mut *this_ptr.inner }.counterparty_htlc_sigs = local_val;
+}
+impl Clone for HolderCommitmentTransaction {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if self.inner.is_null() { std::ptr::null_mut() } else {
+ 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 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 {
+ orig.clone()
+}
+#[no_mangle]
+pub extern "C" fn HolderCommitmentTransaction_write(obj: &HolderCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
+}
+#[no_mangle]
+pub(crate) extern "C" fn HolderCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHolderCommitmentTransaction) })
+}
+#[no_mangle]
+pub extern "C" fn HolderCommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HolderCommitmentTransactionDecodeErrorZ {
+ let res = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::HolderCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
+ local_res
+}
+/// Create a new holder transaction with the given counterparty signatures.
+/// The funding keys are used to figure out which signature should go first when building the transaction for broadcast.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn HolderCommitmentTransaction_new(mut commitment_tx: crate::ln::chan_utils::CommitmentTransaction, mut counterparty_sig: crate::c_types::Signature, mut counterparty_htlc_sigs: crate::c_types::derived::CVec_SignatureZ, mut holder_funding_key: crate::c_types::PublicKey, mut counterparty_funding_key: crate::c_types::PublicKey) -> HolderCommitmentTransaction {
+ let mut local_counterparty_htlc_sigs = Vec::new(); for mut item in counterparty_htlc_sigs.into_rust().drain(..) { local_counterparty_htlc_sigs.push( { item.into_rust() }); };
+ let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new(*unsafe { Box::from_raw(commitment_tx.take_inner()) }, counterparty_sig.into_rust(), local_counterparty_htlc_sigs, &holder_funding_key.into_rust(), &counterparty_funding_key.into_rust());
+ HolderCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+
+use lightning::ln::chan_utils::BuiltCommitmentTransaction as nativeBuiltCommitmentTransactionImport;
+type nativeBuiltCommitmentTransaction = nativeBuiltCommitmentTransactionImport;
+
+/// A pre-built Bitcoin commitment transaction and its txid.
+#[must_use]
+#[repr(C)]
+pub struct BuiltCommitmentTransaction {
+ /// 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 nativeBuiltCommitmentTransaction,
+ pub is_owned: bool,
+}
+
+impl Drop for BuiltCommitmentTransaction {
+ 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 BuiltCommitmentTransaction_free(this_ptr: BuiltCommitmentTransaction) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn BuiltCommitmentTransaction_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBuiltCommitmentTransaction); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl BuiltCommitmentTransaction {
+ pub(crate) fn take_inner(mut self) -> *mut nativeBuiltCommitmentTransaction {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// The commitment transaction
+#[no_mangle]
+pub extern "C" fn BuiltCommitmentTransaction_get_transaction(this_ptr: &BuiltCommitmentTransaction) -> crate::c_types::Transaction {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.transaction;
+ let mut local_inner_val = ::bitcoin::consensus::encode::serialize(inner_val);
+ crate::c_types::Transaction::from_vec(local_inner_val)
+}
+/// The commitment transaction
+#[no_mangle]
+pub extern "C" fn BuiltCommitmentTransaction_set_transaction(this_ptr: &mut BuiltCommitmentTransaction, mut val: crate::c_types::Transaction) {
+ unsafe { &mut *this_ptr.inner }.transaction = val.into_bitcoin();
+}
+/// The txid for the commitment transaction.
+///
+/// This is provided as a performance optimization, instead of calling transaction.txid()
+/// multiple times.
+#[no_mangle]
+pub extern "C" fn BuiltCommitmentTransaction_get_txid(this_ptr: &BuiltCommitmentTransaction) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.txid;
+ (*inner_val).as_inner()
+}
+/// The txid for the commitment transaction.
+///
+/// This is provided as a performance optimization, instead of calling transaction.txid()
+/// multiple times.
+#[no_mangle]
+pub extern "C" fn BuiltCommitmentTransaction_set_txid(this_ptr: &mut BuiltCommitmentTransaction, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn BuiltCommitmentTransaction_new(mut transaction_arg: crate::c_types::Transaction, mut txid_arg: crate::c_types::ThirtyTwoBytes) -> BuiltCommitmentTransaction {
+ BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(nativeBuiltCommitmentTransaction {
+ transaction: transaction_arg.into_bitcoin(),
+ txid: ::bitcoin::hash_types::Txid::from_slice(&txid_arg.data[..]).unwrap(),
+ })), is_owned: true }
+}
+impl Clone for BuiltCommitmentTransaction {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if self.inner.is_null() { std::ptr::null_mut() } else {
+ 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 BuiltCommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBuiltCommitmentTransaction)).clone() })) as *mut c_void
+}
+#[no_mangle]
+pub extern "C" fn BuiltCommitmentTransaction_clone(orig: &BuiltCommitmentTransaction) -> BuiltCommitmentTransaction {
+ orig.clone()
+}
+#[no_mangle]
+pub extern "C" fn BuiltCommitmentTransaction_write(obj: &BuiltCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
+}
+#[no_mangle]
+pub(crate) extern "C" fn BuiltCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBuiltCommitmentTransaction) })
+}
+#[no_mangle]
+pub extern "C" fn BuiltCommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BuiltCommitmentTransactionDecodeErrorZ {
+ let res = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
+ local_res
+}
+/// Get the SIGHASH_ALL sighash value of the transaction.
+///
+/// This can be used to verify a signature.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn BuiltCommitmentTransaction_get_sighash_all(this_arg: &BuiltCommitmentTransaction, mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ThirtyTwoBytes {
+ let mut ret = unsafe { &*this_arg.inner }.get_sighash_all(&::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis);
+ crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() }
+}
+
+/// Sign a transaction, either because we are counter-signing the counterparty's transaction or
+/// because we are about to broadcast a holder transaction.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn BuiltCommitmentTransaction_sign(this_arg: &BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::Signature {
+ let mut ret = unsafe { &*this_arg.inner }.sign(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, &bitcoin::secp256k1::Secp256k1::new());