-pub extern "C" fn AnchorDescriptor_derive_channel_signer(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::WriteableEcdsaChannelSigner {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider);
- Into::into(ret)
-}
-
-
-use lightning::events::bump_transaction::HTLCDescriptor as nativeHTLCDescriptorImport;
-pub(crate) type nativeHTLCDescriptor = nativeHTLCDescriptorImport;
-
-/// A descriptor used to sign for a commitment transaction's HTLC output.
-#[must_use]
-#[repr(C)]
-pub struct HTLCDescriptor {
- /// A pointer to the opaque Rust object.
-
- /// 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 nativeHTLCDescriptor,
- /// Indicates that this is the only struct which contains the same pointer.
-
- /// Rust functions which take ownership of an object provided via an argument require
- /// this to be true and invalidate the object pointed to by inner.
- pub is_owned: bool,
-}
-
-impl Drop for HTLCDescriptor {
- fn drop(&mut self) {
- if self.is_owned && !<*mut nativeHTLCDescriptor>::is_null(self.inner) {
- let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
- }
- }
-}
-/// Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_free(this_obj: HTLCDescriptor) { }
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-pub(crate) extern "C" fn HTLCDescriptor_free_void(this_ptr: *mut c_void) {
- let _ = unsafe { Box::from_raw(this_ptr as *mut nativeHTLCDescriptor) };
-}
-#[allow(unused)]
-impl HTLCDescriptor {
- pub(crate) fn get_native_ref(&self) -> &'static nativeHTLCDescriptor {
- unsafe { &*ObjOps::untweak_ptr(self.inner) }
- }
- pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeHTLCDescriptor {
- unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
- }
- /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
- pub(crate) fn take_inner(mut self) -> *mut nativeHTLCDescriptor {
- assert!(self.is_owned);
- let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = core::ptr::null_mut();
- ret
- }
-}
-/// The parameters required to derive the signer for the HTLC input.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_get_channel_derivation_parameters(this_ptr: &HTLCDescriptor) -> crate::lightning::events::bump_transaction::ChannelDerivationParameters {
- let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_derivation_parameters;
- crate::lightning::events::bump_transaction::ChannelDerivationParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::events::bump_transaction::ChannelDerivationParameters<>) as *mut _) }, is_owned: false }
-}
-/// The parameters required to derive the signer for the HTLC input.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_set_channel_derivation_parameters(this_ptr: &mut HTLCDescriptor, mut val: crate::lightning::events::bump_transaction::ChannelDerivationParameters) {
- unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_derivation_parameters = *unsafe { Box::from_raw(val.take_inner()) };
-}
-/// The number of the commitment transaction in which the HTLC output lives.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_get_per_commitment_number(this_ptr: &HTLCDescriptor) -> u64 {
- let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_number;
- *inner_val
-}
-/// The number of the commitment transaction in which the HTLC output lives.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_set_per_commitment_number(this_ptr: &mut HTLCDescriptor, mut val: u64) {
- unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_number = val;
-}
-/// The key tweak corresponding to the number of the commitment transaction in which the HTLC
-/// output lives. This tweak is applied to all the basepoints for both parties in the channel to
-/// arrive at unique keys per commitment.
-///
-/// See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_get_per_commitment_point(this_ptr: &HTLCDescriptor) -> crate::c_types::PublicKey {
- let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_point;
- crate::c_types::PublicKey::from_rust(&inner_val)
-}
-/// The key tweak corresponding to the number of the commitment transaction in which the HTLC
-/// output lives. This tweak is applied to all the basepoints for both parties in the channel to
-/// arrive at unique keys per commitment.
-///
-/// See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_set_per_commitment_point(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::PublicKey) {
- unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_point = val.into_rust();
-}
-/// The details of the HTLC as it appears in the commitment transaction.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_get_htlc(this_ptr: &HTLCDescriptor) -> crate::lightning::ln::chan_utils::HTLCOutputInCommitment {
- let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc;
- crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }
-}
-/// The details of the HTLC as it appears in the commitment transaction.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_set_htlc(this_ptr: &mut HTLCDescriptor, mut val: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) {
- unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc = *unsafe { Box::from_raw(val.take_inner()) };
-}
-/// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
-/// taken.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_get_preimage(this_ptr: &HTLCDescriptor) -> crate::c_types::derived::COption_PaymentPreimageZ {
- let mut inner_val = &mut this_ptr.get_native_mut_ref().preimage;
- let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_PaymentPreimageZ::None } else { crate::c_types::derived::COption_PaymentPreimageZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().0 } }) };
- local_inner_val
-}
-/// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
-/// taken.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_set_preimage(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::derived::COption_PaymentPreimageZ) {
- let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ val_opt.take() }.data) }})} };
- unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.preimage = local_val;
-}
-/// The counterparty's signature required to spend the HTLC output.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_get_counterparty_sig(this_ptr: &HTLCDescriptor) -> crate::c_types::Signature {
- let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty_sig;
- crate::c_types::Signature::from_rust(&inner_val)
-}
-/// The counterparty's signature required to spend the HTLC output.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_set_counterparty_sig(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::Signature) {
- unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty_sig = val.into_rust();
-}
-impl Clone for HTLCDescriptor {
- fn clone(&self) -> Self {
- Self {
- inner: if <*mut nativeHTLCDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else {
- ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(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 HTLCDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
- Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCDescriptor)).clone() })) as *mut c_void
-}
-#[no_mangle]
-/// Creates a copy of the HTLCDescriptor
-pub extern "C" fn HTLCDescriptor_clone(orig: &HTLCDescriptor) -> HTLCDescriptor {
- orig.clone()
-}
-/// Checks if two HTLCDescriptors contain equal inner contents.
-/// This ignores pointers and is_owned flags and looks at the values in fields.
-/// Two objects with NULL inner values will be considered "equal" here.
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_eq(a: &HTLCDescriptor, b: &HTLCDescriptor) -> bool {
- if a.inner == b.inner { return true; }
- if a.inner.is_null() || b.inner.is_null() { return false; }
- if a.get_native_ref() == b.get_native_ref() { true } else { false }
-}
-/// Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint
-/// being spent by the HTLC input in the HTLC transaction.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_outpoint(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::lightning::chain::transaction::OutPoint {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.outpoint();
- crate::c_types::bitcoin_to_C_outpoint(&ret)
-}
-
-/// Returns the UTXO to be spent by the HTLC input, which can be obtained via
-/// [`Self::unsigned_tx_input`].
-#[must_use]
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_previous_utxo(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxOut {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.previous_utxo(secp256k1::global::SECP256K1);
- crate::c_types::TxOut::from_rust(&ret)
-}
-
-/// Returns the unsigned transaction input spending the HTLC output in the commitment
-/// transaction.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_unsigned_tx_input(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxIn {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.unsigned_tx_input();
- crate::c_types::TxIn::from_rust(&ret)
-}
-
-/// Returns the delayed output created as a result of spending the HTLC output in the commitment
-/// transaction.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_tx_output(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxOut {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_output(secp256k1::global::SECP256K1);
- crate::c_types::TxOut::from_rust(&ret)
-}
-
-/// Returns the witness script of the HTLC output in the commitment transaction.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_witness_script(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::derived::CVec_u8Z {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.witness_script(secp256k1::global::SECP256K1);
- ret.into_bytes().into()
-}
-
-/// Returns the fully signed witness required to spend the HTLC output in the commitment
-/// transaction.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_tx_input_witness(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor, mut signature: crate::c_types::Signature, mut witness_script: crate::c_types::u8slice) -> crate::c_types::Witness {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust(), &::bitcoin::blockdata::script::Script::from(Vec::from(witness_script.to_slice())));
- crate::c_types::Witness::from_bitcoin(&ret)
-}
-
-/// Derives the channel signer required to sign the HTLC input.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn HTLCDescriptor_derive_channel_signer(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::WriteableEcdsaChannelSigner {