+ /// Set the counterparty static channel data, including basepoints,
+ /// `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint.
+ ///
+ /// This data is static, and will never change for a channel once set. For a given [`ChannelSigner`]
+ /// instance, LDK will call this method exactly once - either immediately after construction
+ /// (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding
+ /// information has been generated.
+ ///
+ /// channel_parameters.is_populated() MUST be true.
+ pub provide_channel_parameters: extern "C" fn (this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters),
+ /// Frees any resources associated with this object given its this_arg pointer.
+ /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for ChannelSigner {}
+unsafe impl Sync for ChannelSigner {}
+#[no_mangle]
+pub(crate) extern "C" fn ChannelSigner_clone_fields(orig: &ChannelSigner) -> ChannelSigner {
+ ChannelSigner {
+ this_arg: orig.this_arg,
+ get_per_commitment_point: Clone::clone(&orig.get_per_commitment_point),
+ release_commitment_secret: Clone::clone(&orig.release_commitment_secret),
+ validate_holder_commitment: Clone::clone(&orig.validate_holder_commitment),
+ pubkeys: Clone::clone(unsafe { &*core::cell::UnsafeCell::get(&orig.pubkeys)}).into(),
+ set_pubkeys: Clone::clone(&orig.set_pubkeys),
+ channel_keys_id: Clone::clone(&orig.channel_keys_id),
+ provide_channel_parameters: Clone::clone(&orig.provide_channel_parameters),
+ free: Clone::clone(&orig.free),
+ }
+}
+
+use lightning::chain::keysinterface::ChannelSigner as rustChannelSigner;
+impl rustChannelSigner for ChannelSigner {
+ fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> bitcoin::secp256k1::PublicKey {
+ let mut ret = (self.get_per_commitment_point)(self.this_arg, idx);
+ ret.into_rust()
+ }
+ fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] {
+ let mut ret = (self.release_commitment_secret)(self.this_arg, idx);
+ ret.data
+ }
+ fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec<lightning::ln::PaymentPreimage>) -> Result<(), ()> {
+ let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); };
+ let mut ret = (self.validate_holder_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into());
+ let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
+ local_ret
+ }
+ fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys {
+ if let Some(f) = self.set_pubkeys {
+ (f)(&self);
+ }
+ unsafe { &*self.pubkeys.get() }.get_native_ref()
+ }
+ fn channel_keys_id(&self) -> [u8; 32] {
+ let mut ret = (self.channel_keys_id)(self.this_arg);
+ ret.data
+ }
+ fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) {
+ (self.provide_channel_parameters)(self.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false })
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl core::ops::Deref for ChannelSigner {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn ChannelSigner_free(this_ptr: ChannelSigner) { }
+impl Drop for ChannelSigner {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+/// A trait to sign Lightning channel transactions as described in
+/// [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md).
+///
+/// Signing services could be implemented on a hardware wallet and should implement signing
+/// policies in order to be secure. Please refer to the [VLS Policy
+/// Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md)
+/// for an example of such policies.
+#[repr(C)]
+pub struct EcdsaChannelSigner {
+ /// An opaque pointer which is passed to your function implementations as an argument.
+ /// This has no meaning in the LDK, and can be NULL or any other value.
+ pub this_arg: *mut c_void,