Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / sign.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Provides keys to LDK and defines some useful objects describing spendable on-chain outputs.
10 //!
11 //! The provided output descriptors follow a custom LDK data format and are currently not fully
12 //! compatible with Bitcoin Core output descriptors.
13
14 use alloc::str::FromStr;
15 use alloc::string::String;
16 use core::ffi::c_void;
17 use core::convert::Infallible;
18 use bitcoin::hashes::Hash;
19 use crate::c_types::*;
20 #[cfg(feature="no-std")]
21 use alloc::{vec::Vec, boxed::Box};
22
23 mod type_resolver {
24
25 use alloc::str::FromStr;
26 use alloc::string::String;
27 use core::ffi::c_void;
28 use core::convert::Infallible;
29 use bitcoin::hashes::Hash;
30 use crate::c_types::*;
31 #[cfg(feature="no-std")]
32 use alloc::{vec::Vec, boxed::Box};
33
34 }
35
36 use lightning::sign::DelayedPaymentOutputDescriptor as nativeDelayedPaymentOutputDescriptorImport;
37 pub(crate) type nativeDelayedPaymentOutputDescriptor = nativeDelayedPaymentOutputDescriptorImport;
38
39 /// Information about a spendable output to a P2WSH script.
40 ///
41 /// See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this.
42 #[must_use]
43 #[repr(C)]
44 pub struct DelayedPaymentOutputDescriptor {
45         /// A pointer to the opaque Rust object.
46
47         /// Nearly everywhere, inner must be non-null, however in places where
48         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
49         pub inner: *mut nativeDelayedPaymentOutputDescriptor,
50         /// Indicates that this is the only struct which contains the same pointer.
51
52         /// Rust functions which take ownership of an object provided via an argument require
53         /// this to be true and invalidate the object pointed to by inner.
54         pub is_owned: bool,
55 }
56
57 impl Drop for DelayedPaymentOutputDescriptor {
58         fn drop(&mut self) {
59                 if self.is_owned && !<*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) {
60                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
61                 }
62         }
63 }
64 /// Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL.
65 #[no_mangle]
66 pub extern "C" fn DelayedPaymentOutputDescriptor_free(this_obj: DelayedPaymentOutputDescriptor) { }
67 #[allow(unused)]
68 /// Used only if an object of this type is returned as a trait impl by a method
69 pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) {
70         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDelayedPaymentOutputDescriptor) };
71 }
72 #[allow(unused)]
73 impl DelayedPaymentOutputDescriptor {
74         pub(crate) fn get_native_ref(&self) -> &'static nativeDelayedPaymentOutputDescriptor {
75                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
76         }
77         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDelayedPaymentOutputDescriptor {
78                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
79         }
80         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
81         pub(crate) fn take_inner(mut self) -> *mut nativeDelayedPaymentOutputDescriptor {
82                 assert!(self.is_owned);
83                 let ret = ObjOps::untweak_ptr(self.inner);
84                 self.inner = core::ptr::null_mut();
85                 ret
86         }
87 }
88 /// The outpoint which is spendable.
89 #[no_mangle]
90 pub extern "C" fn DelayedPaymentOutputDescriptor_get_outpoint(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint {
91         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
92         crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false }
93 }
94 /// The outpoint which is spendable.
95 #[no_mangle]
96 pub extern "C" fn DelayedPaymentOutputDescriptor_set_outpoint(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) {
97         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = *unsafe { Box::from_raw(val.take_inner()) };
98 }
99 /// Per commitment point to derive the delayed payment key by key holder.
100 #[no_mangle]
101 pub extern "C" fn DelayedPaymentOutputDescriptor_get_per_commitment_point(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey {
102         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_point;
103         crate::c_types::PublicKey::from_rust(&inner_val)
104 }
105 /// Per commitment point to derive the delayed payment key by key holder.
106 #[no_mangle]
107 pub extern "C" fn DelayedPaymentOutputDescriptor_set_per_commitment_point(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) {
108         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_point = val.into_rust();
109 }
110 /// The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in
111 /// the witness_script.
112 #[no_mangle]
113 pub extern "C" fn DelayedPaymentOutputDescriptor_get_to_self_delay(this_ptr: &DelayedPaymentOutputDescriptor) -> u16 {
114         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
115         *inner_val
116 }
117 /// The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in
118 /// the witness_script.
119 #[no_mangle]
120 pub extern "C" fn DelayedPaymentOutputDescriptor_set_to_self_delay(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u16) {
121         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
122 }
123 /// The output which is referenced by the given outpoint.
124 #[no_mangle]
125 pub extern "C" fn DelayedPaymentOutputDescriptor_get_output(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::TxOut {
126         let mut inner_val = &mut this_ptr.get_native_mut_ref().output;
127         crate::c_types::TxOut::from_rust(inner_val)
128 }
129 /// The output which is referenced by the given outpoint.
130 #[no_mangle]
131 pub extern "C" fn DelayedPaymentOutputDescriptor_set_output(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::TxOut) {
132         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust();
133 }
134 /// The revocation point specific to the commitment transaction which was broadcast. Used to
135 /// derive the witnessScript for this output.
136 #[no_mangle]
137 pub extern "C" fn DelayedPaymentOutputDescriptor_get_revocation_pubkey(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey {
138         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_pubkey;
139         crate::c_types::PublicKey::from_rust(&inner_val)
140 }
141 /// The revocation point specific to the commitment transaction which was broadcast. Used to
142 /// derive the witnessScript for this output.
143 #[no_mangle]
144 pub extern "C" fn DelayedPaymentOutputDescriptor_set_revocation_pubkey(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) {
145         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_pubkey = val.into_rust();
146 }
147 /// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
148 /// This may be useful in re-deriving keys used in the channel to spend the output.
149 #[no_mangle]
150 pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &DelayedPaymentOutputDescriptor) -> *const [u8; 32] {
151         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_keys_id;
152         inner_val
153 }
154 /// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
155 /// This may be useful in re-deriving keys used in the channel to spend the output.
156 #[no_mangle]
157 pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) {
158         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_keys_id = val.data;
159 }
160 /// The value of the channel which this output originated from, possibly indirectly.
161 #[no_mangle]
162 pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &DelayedPaymentOutputDescriptor) -> u64 {
163         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis;
164         *inner_val
165 }
166 /// The value of the channel which this output originated from, possibly indirectly.
167 #[no_mangle]
168 pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u64) {
169         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val;
170 }
171 /// Constructs a new DelayedPaymentOutputDescriptor given each field
172 #[must_use]
173 #[no_mangle]
174 pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut per_commitment_point_arg: crate::c_types::PublicKey, mut to_self_delay_arg: u16, mut output_arg: crate::c_types::TxOut, mut revocation_pubkey_arg: crate::c_types::PublicKey, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> DelayedPaymentOutputDescriptor {
175         DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(nativeDelayedPaymentOutputDescriptor {
176                 outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) },
177                 per_commitment_point: per_commitment_point_arg.into_rust(),
178                 to_self_delay: to_self_delay_arg,
179                 output: output_arg.into_rust(),
180                 revocation_pubkey: revocation_pubkey_arg.into_rust(),
181                 channel_keys_id: channel_keys_id_arg.data,
182                 channel_value_satoshis: channel_value_satoshis_arg,
183         }), is_owned: true }
184 }
185 impl Clone for DelayedPaymentOutputDescriptor {
186         fn clone(&self) -> Self {
187                 Self {
188                         inner: if <*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else {
189                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
190                         is_owned: true,
191                 }
192         }
193 }
194 #[allow(unused)]
195 /// Used only if an object of this type is returned as a trait impl by a method
196 pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
197         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDelayedPaymentOutputDescriptor)).clone() })) as *mut c_void
198 }
199 #[no_mangle]
200 /// Creates a copy of the DelayedPaymentOutputDescriptor
201 pub extern "C" fn DelayedPaymentOutputDescriptor_clone(orig: &DelayedPaymentOutputDescriptor) -> DelayedPaymentOutputDescriptor {
202         orig.clone()
203 }
204 /// Generates a non-cryptographic 64-bit hash of the DelayedPaymentOutputDescriptor.
205 #[no_mangle]
206 pub extern "C" fn DelayedPaymentOutputDescriptor_hash(o: &DelayedPaymentOutputDescriptor) -> u64 {
207         if o.inner.is_null() { return 0; }
208         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
209         #[allow(deprecated)]
210         let mut hasher = core::hash::SipHasher::new();
211         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
212         core::hash::Hasher::finish(&hasher)
213 }
214 /// Checks if two DelayedPaymentOutputDescriptors contain equal inner contents.
215 /// This ignores pointers and is_owned flags and looks at the values in fields.
216 /// Two objects with NULL inner values will be considered "equal" here.
217 #[no_mangle]
218 pub extern "C" fn DelayedPaymentOutputDescriptor_eq(a: &DelayedPaymentOutputDescriptor, b: &DelayedPaymentOutputDescriptor) -> bool {
219         if a.inner == b.inner { return true; }
220         if a.inner.is_null() || b.inner.is_null() { return false; }
221         if a.get_native_ref() == b.get_native_ref() { true } else { false }
222 }
223 #[no_mangle]
224 /// Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read
225 pub extern "C" fn DelayedPaymentOutputDescriptor_write(obj: &crate::lightning::sign::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CVec_u8Z {
226         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
227 }
228 #[no_mangle]
229 pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
230         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDelayedPaymentOutputDescriptor) })
231 }
232 #[no_mangle]
233 /// Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write
234 pub extern "C" fn DelayedPaymentOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DelayedPaymentOutputDescriptorDecodeErrorZ {
235         let res: Result<lightning::sign::DelayedPaymentOutputDescriptor, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
236         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::sign::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
237         local_res
238 }
239
240 use lightning::sign::StaticPaymentOutputDescriptor as nativeStaticPaymentOutputDescriptorImport;
241 pub(crate) type nativeStaticPaymentOutputDescriptor = nativeStaticPaymentOutputDescriptorImport;
242
243 /// Information about a spendable output to our \"payment key\".
244 ///
245 /// See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this.
246 #[must_use]
247 #[repr(C)]
248 pub struct StaticPaymentOutputDescriptor {
249         /// A pointer to the opaque Rust object.
250
251         /// Nearly everywhere, inner must be non-null, however in places where
252         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
253         pub inner: *mut nativeStaticPaymentOutputDescriptor,
254         /// Indicates that this is the only struct which contains the same pointer.
255
256         /// Rust functions which take ownership of an object provided via an argument require
257         /// this to be true and invalidate the object pointed to by inner.
258         pub is_owned: bool,
259 }
260
261 impl Drop for StaticPaymentOutputDescriptor {
262         fn drop(&mut self) {
263                 if self.is_owned && !<*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) {
264                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
265                 }
266         }
267 }
268 /// Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL.
269 #[no_mangle]
270 pub extern "C" fn StaticPaymentOutputDescriptor_free(this_obj: StaticPaymentOutputDescriptor) { }
271 #[allow(unused)]
272 /// Used only if an object of this type is returned as a trait impl by a method
273 pub(crate) extern "C" fn StaticPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) {
274         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeStaticPaymentOutputDescriptor) };
275 }
276 #[allow(unused)]
277 impl StaticPaymentOutputDescriptor {
278         pub(crate) fn get_native_ref(&self) -> &'static nativeStaticPaymentOutputDescriptor {
279                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
280         }
281         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeStaticPaymentOutputDescriptor {
282                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
283         }
284         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
285         pub(crate) fn take_inner(mut self) -> *mut nativeStaticPaymentOutputDescriptor {
286                 assert!(self.is_owned);
287                 let ret = ObjOps::untweak_ptr(self.inner);
288                 self.inner = core::ptr::null_mut();
289                 ret
290         }
291 }
292 /// The outpoint which is spendable.
293 #[no_mangle]
294 pub extern "C" fn StaticPaymentOutputDescriptor_get_outpoint(this_ptr: &StaticPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint {
295         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
296         crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false }
297 }
298 /// The outpoint which is spendable.
299 #[no_mangle]
300 pub extern "C" fn StaticPaymentOutputDescriptor_set_outpoint(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) {
301         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = *unsafe { Box::from_raw(val.take_inner()) };
302 }
303 /// The output which is referenced by the given outpoint.
304 #[no_mangle]
305 pub extern "C" fn StaticPaymentOutputDescriptor_get_output(this_ptr: &StaticPaymentOutputDescriptor) -> crate::c_types::TxOut {
306         let mut inner_val = &mut this_ptr.get_native_mut_ref().output;
307         crate::c_types::TxOut::from_rust(inner_val)
308 }
309 /// The output which is referenced by the given outpoint.
310 #[no_mangle]
311 pub extern "C" fn StaticPaymentOutputDescriptor_set_output(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::TxOut) {
312         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust();
313 }
314 /// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
315 /// This may be useful in re-deriving keys used in the channel to spend the output.
316 #[no_mangle]
317 pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &StaticPaymentOutputDescriptor) -> *const [u8; 32] {
318         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_keys_id;
319         inner_val
320 }
321 /// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
322 /// This may be useful in re-deriving keys used in the channel to spend the output.
323 #[no_mangle]
324 pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) {
325         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_keys_id = val.data;
326 }
327 /// The value of the channel which this transactions spends.
328 #[no_mangle]
329 pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &StaticPaymentOutputDescriptor) -> u64 {
330         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis;
331         *inner_val
332 }
333 /// The value of the channel which this transactions spends.
334 #[no_mangle]
335 pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: u64) {
336         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val;
337 }
338 /// The necessary channel parameters that need to be provided to the re-derived signer through
339 /// [`ChannelSigner::provide_channel_parameters`].
340 ///
341 /// Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later.
342 ///
343 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
344 #[no_mangle]
345 pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_transaction_parameters(this_ptr: &StaticPaymentOutputDescriptor) -> crate::lightning::ln::chan_utils::ChannelTransactionParameters {
346         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_transaction_parameters;
347         let mut local_inner_val = crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _ }, is_owned: false };
348         local_inner_val
349 }
350 /// The necessary channel parameters that need to be provided to the re-derived signer through
351 /// [`ChannelSigner::provide_channel_parameters`].
352 ///
353 /// Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later.
354 ///
355 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
356 #[no_mangle]
357 pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_transaction_parameters(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::lightning::ln::chan_utils::ChannelTransactionParameters) {
358         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
359         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_transaction_parameters = local_val;
360 }
361 /// Constructs a new StaticPaymentOutputDescriptor given each field
362 ///
363 /// Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
364 #[must_use]
365 #[no_mangle]
366 pub extern "C" fn StaticPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64, mut channel_transaction_parameters_arg: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> StaticPaymentOutputDescriptor {
367         let mut local_channel_transaction_parameters_arg = if channel_transaction_parameters_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_transaction_parameters_arg.take_inner()) } }) };
368         StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(nativeStaticPaymentOutputDescriptor {
369                 outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) },
370                 output: output_arg.into_rust(),
371                 channel_keys_id: channel_keys_id_arg.data,
372                 channel_value_satoshis: channel_value_satoshis_arg,
373                 channel_transaction_parameters: local_channel_transaction_parameters_arg,
374         }), is_owned: true }
375 }
376 impl Clone for StaticPaymentOutputDescriptor {
377         fn clone(&self) -> Self {
378                 Self {
379                         inner: if <*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else {
380                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
381                         is_owned: true,
382                 }
383         }
384 }
385 #[allow(unused)]
386 /// Used only if an object of this type is returned as a trait impl by a method
387 pub(crate) extern "C" fn StaticPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
388         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeStaticPaymentOutputDescriptor)).clone() })) as *mut c_void
389 }
390 #[no_mangle]
391 /// Creates a copy of the StaticPaymentOutputDescriptor
392 pub extern "C" fn StaticPaymentOutputDescriptor_clone(orig: &StaticPaymentOutputDescriptor) -> StaticPaymentOutputDescriptor {
393         orig.clone()
394 }
395 /// Generates a non-cryptographic 64-bit hash of the StaticPaymentOutputDescriptor.
396 #[no_mangle]
397 pub extern "C" fn StaticPaymentOutputDescriptor_hash(o: &StaticPaymentOutputDescriptor) -> u64 {
398         if o.inner.is_null() { return 0; }
399         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
400         #[allow(deprecated)]
401         let mut hasher = core::hash::SipHasher::new();
402         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
403         core::hash::Hasher::finish(&hasher)
404 }
405 /// Checks if two StaticPaymentOutputDescriptors contain equal inner contents.
406 /// This ignores pointers and is_owned flags and looks at the values in fields.
407 /// Two objects with NULL inner values will be considered "equal" here.
408 #[no_mangle]
409 pub extern "C" fn StaticPaymentOutputDescriptor_eq(a: &StaticPaymentOutputDescriptor, b: &StaticPaymentOutputDescriptor) -> bool {
410         if a.inner == b.inner { return true; }
411         if a.inner.is_null() || b.inner.is_null() { return false; }
412         if a.get_native_ref() == b.get_native_ref() { true } else { false }
413 }
414 /// Returns the `witness_script` of the spendable output.
415 ///
416 /// Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that
417 /// originated from an anchor outputs channel, as they take the form of a P2WSH script.
418 #[must_use]
419 #[no_mangle]
420 pub extern "C" fn StaticPaymentOutputDescriptor_witness_script(this_arg: &crate::lightning::sign::StaticPaymentOutputDescriptor) -> crate::c_types::derived::COption_CVec_u8ZZ {
421         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.witness_script();
422         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { ret.unwrap().into_bytes().into() }) };
423         local_ret
424 }
425
426 /// The maximum length a well-formed witness spending one of these should have.
427 /// Note: If you have the grind_signatures feature enabled, this will be at least 1 byte
428 /// shorter.
429 #[must_use]
430 #[no_mangle]
431 pub extern "C" fn StaticPaymentOutputDescriptor_max_witness_length(this_arg: &crate::lightning::sign::StaticPaymentOutputDescriptor) -> usize {
432         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.max_witness_length();
433         ret
434 }
435
436 #[no_mangle]
437 /// Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read
438 pub extern "C" fn StaticPaymentOutputDescriptor_write(obj: &crate::lightning::sign::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CVec_u8Z {
439         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
440 }
441 #[no_mangle]
442 pub(crate) extern "C" fn StaticPaymentOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
443         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStaticPaymentOutputDescriptor) })
444 }
445 #[no_mangle]
446 /// Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write
447 pub extern "C" fn StaticPaymentOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_StaticPaymentOutputDescriptorDecodeErrorZ {
448         let res: Result<lightning::sign::StaticPaymentOutputDescriptor, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
449         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::sign::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
450         local_res
451 }
452 /// Describes the necessary information to spend a spendable output.
453 ///
454 /// When on-chain outputs are created by LDK (which our counterparty is not able to claim at any
455 /// point in the future) a [`SpendableOutputs`] event is generated which you must track and be able
456 /// to spend on-chain. The information needed to do this is provided in this enum, including the
457 /// outpoint describing which `txid` and output `index` is available, the full output which exists
458 /// at that `txid`/`index`, and any keys or other information required to sign.
459 ///
460 /// [`SpendableOutputs`]: crate::events::Event::SpendableOutputs
461 #[derive(Clone)]
462 #[must_use]
463 #[repr(C)]
464 pub enum SpendableOutputDescriptor {
465         /// An output to a script which was provided via [`SignerProvider`] directly, either from
466         /// [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already
467         /// know how to spend it. No secret keys are provided as LDK was never given any key.
468         /// These may include outputs from a transaction punishing our counterparty or claiming an HTLC
469         /// on-chain using the payment preimage or after it has timed out.
470         ///
471         /// [`get_shutdown_scriptpubkey`]: SignerProvider::get_shutdown_scriptpubkey
472         /// [`get_destination_script`]: SignerProvider::get_shutdown_scriptpubkey
473         StaticOutput {
474                 /// The outpoint which is spendable.
475                 outpoint: crate::lightning::chain::transaction::OutPoint,
476                 /// The output which is referenced by the given outpoint.
477                 output: crate::c_types::TxOut,
478         },
479         /// An output to a P2WSH script which can be spent with a single signature after an `OP_CSV`
480         /// delay.
481         ///
482         /// The witness in the spending input should be:
483         /// ```bitcoin
484         /// <BIP 143 signature> <empty vector> (MINIMALIF standard rule) <provided witnessScript>
485         /// ```
486         ///
487         /// Note that the `nSequence` field in the spending input must be set to
488         /// [`DelayedPaymentOutputDescriptor::to_self_delay`] (which means the transaction is not
489         /// broadcastable until at least [`DelayedPaymentOutputDescriptor::to_self_delay`] blocks after
490         /// the outpoint confirms, see [BIP
491         /// 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)). Also note that LDK
492         /// won't generate a [`SpendableOutputDescriptor`] until the corresponding block height
493         /// is reached.
494         ///
495         /// These are generally the result of a \"revocable\" output to us, spendable only by us unless
496         /// it is an output from an old state which we broadcast (which should never happen).
497         ///
498         /// To derive the delayed payment key which is used to sign this input, you must pass the
499         /// holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the
500         /// [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided
501         /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The public key can be
502         /// generated without the secret key using [`chan_utils::derive_public_key`] and only the
503         /// [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`].
504         ///
505         /// To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is
506         /// used in the witness script generation), you must pass the counterparty
507         /// [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to
508         /// [`ChannelSigner::provide_channel_parameters`]) and the provided
509         /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to
510         /// [`chan_utils::derive_public_revocation_key`].
511         ///
512         /// The witness script which is hashed and included in the output `script_pubkey` may be
513         /// regenerated by passing the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] (derived
514         /// as explained above), our delayed payment pubkey (derived as explained above), and the
515         /// [`DelayedPaymentOutputDescriptor::to_self_delay`] contained here to
516         /// [`chan_utils::get_revokeable_redeemscript`].
517         DelayedPaymentOutput(
518                 crate::lightning::sign::DelayedPaymentOutputDescriptor),
519         /// An output spendable exclusively by our payment key (i.e., the private key that corresponds
520         /// to the `payment_point` in [`ChannelSigner::pubkeys`]). The output type depends on the
521         /// channel type negotiated.
522         ///
523         /// On an anchor outputs channel, the witness in the spending input is:
524         /// ```bitcoin
525         /// <BIP 143 signature> <witness script>
526         /// ```
527         ///
528         /// Otherwise, it is:
529         /// ```bitcoin
530         /// <BIP 143 signature> <payment key>
531         /// ```
532         ///
533         /// These are generally the result of our counterparty having broadcast the current state,
534         /// allowing us to claim the non-HTLC-encumbered outputs immediately, or after one confirmation
535         /// in the case of anchor outputs channels.
536         StaticPaymentOutput(
537                 crate::lightning::sign::StaticPaymentOutputDescriptor),
538 }
539 use lightning::sign::SpendableOutputDescriptor as SpendableOutputDescriptorImport;
540 pub(crate) type nativeSpendableOutputDescriptor = SpendableOutputDescriptorImport;
541
542 impl SpendableOutputDescriptor {
543         #[allow(unused)]
544         pub(crate) fn to_native(&self) -> nativeSpendableOutputDescriptor {
545                 match self {
546                         SpendableOutputDescriptor::StaticOutput {ref outpoint, ref output, } => {
547                                 let mut outpoint_nonref = Clone::clone(outpoint);
548                                 let mut output_nonref = Clone::clone(output);
549                                 nativeSpendableOutputDescriptor::StaticOutput {
550                                         outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) },
551                                         output: output_nonref.into_rust(),
552                                 }
553                         },
554                         SpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => {
555                                 let mut a_nonref = Clone::clone(a);
556                                 nativeSpendableOutputDescriptor::DelayedPaymentOutput (
557                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
558                                 )
559                         },
560                         SpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => {
561                                 let mut a_nonref = Clone::clone(a);
562                                 nativeSpendableOutputDescriptor::StaticPaymentOutput (
563                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
564                                 )
565                         },
566                 }
567         }
568         #[allow(unused)]
569         pub(crate) fn into_native(self) -> nativeSpendableOutputDescriptor {
570                 match self {
571                         SpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => {
572                                 nativeSpendableOutputDescriptor::StaticOutput {
573                                         outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) },
574                                         output: output.into_rust(),
575                                 }
576                         },
577                         SpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => {
578                                 nativeSpendableOutputDescriptor::DelayedPaymentOutput (
579                                         *unsafe { Box::from_raw(a.take_inner()) },
580                                 )
581                         },
582                         SpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => {
583                                 nativeSpendableOutputDescriptor::StaticPaymentOutput (
584                                         *unsafe { Box::from_raw(a.take_inner()) },
585                                 )
586                         },
587                 }
588         }
589         #[allow(unused)]
590         pub(crate) fn from_native(native: &nativeSpendableOutputDescriptor) -> Self {
591                 match native {
592                         nativeSpendableOutputDescriptor::StaticOutput {ref outpoint, ref output, } => {
593                                 let mut outpoint_nonref = Clone::clone(outpoint);
594                                 let mut output_nonref = Clone::clone(output);
595                                 SpendableOutputDescriptor::StaticOutput {
596                                         outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint_nonref), is_owned: true },
597                                         output: crate::c_types::TxOut::from_rust(&output_nonref),
598                                 }
599                         },
600                         nativeSpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => {
601                                 let mut a_nonref = Clone::clone(a);
602                                 SpendableOutputDescriptor::DelayedPaymentOutput (
603                                         crate::lightning::sign::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
604                                 )
605                         },
606                         nativeSpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => {
607                                 let mut a_nonref = Clone::clone(a);
608                                 SpendableOutputDescriptor::StaticPaymentOutput (
609                                         crate::lightning::sign::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
610                                 )
611                         },
612                 }
613         }
614         #[allow(unused)]
615         pub(crate) fn native_into(native: nativeSpendableOutputDescriptor) -> Self {
616                 match native {
617                         nativeSpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => {
618                                 SpendableOutputDescriptor::StaticOutput {
619                                         outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint), is_owned: true },
620                                         output: crate::c_types::TxOut::from_rust(&output),
621                                 }
622                         },
623                         nativeSpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => {
624                                 SpendableOutputDescriptor::DelayedPaymentOutput (
625                                         crate::lightning::sign::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a), is_owned: true },
626                                 )
627                         },
628                         nativeSpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => {
629                                 SpendableOutputDescriptor::StaticPaymentOutput (
630                                         crate::lightning::sign::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a), is_owned: true },
631                                 )
632                         },
633                 }
634         }
635 }
636 /// Frees any resources used by the SpendableOutputDescriptor
637 #[no_mangle]
638 pub extern "C" fn SpendableOutputDescriptor_free(this_ptr: SpendableOutputDescriptor) { }
639 /// Creates a copy of the SpendableOutputDescriptor
640 #[no_mangle]
641 pub extern "C" fn SpendableOutputDescriptor_clone(orig: &SpendableOutputDescriptor) -> SpendableOutputDescriptor {
642         orig.clone()
643 }
644 #[no_mangle]
645 /// Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor
646 pub extern "C" fn SpendableOutputDescriptor_static_output(outpoint: crate::lightning::chain::transaction::OutPoint, output: crate::c_types::TxOut) -> SpendableOutputDescriptor {
647         SpendableOutputDescriptor::StaticOutput {
648                 outpoint,
649                 output,
650         }
651 }
652 #[no_mangle]
653 /// Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor
654 pub extern "C" fn SpendableOutputDescriptor_delayed_payment_output(a: crate::lightning::sign::DelayedPaymentOutputDescriptor) -> SpendableOutputDescriptor {
655         SpendableOutputDescriptor::DelayedPaymentOutput(a, )
656 }
657 #[no_mangle]
658 /// Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor
659 pub extern "C" fn SpendableOutputDescriptor_static_payment_output(a: crate::lightning::sign::StaticPaymentOutputDescriptor) -> SpendableOutputDescriptor {
660         SpendableOutputDescriptor::StaticPaymentOutput(a, )
661 }
662 /// Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor.
663 #[no_mangle]
664 pub extern "C" fn SpendableOutputDescriptor_hash(o: &SpendableOutputDescriptor) -> u64 {
665         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
666         #[allow(deprecated)]
667         let mut hasher = core::hash::SipHasher::new();
668         core::hash::Hash::hash(&o.to_native(), &mut hasher);
669         core::hash::Hasher::finish(&hasher)
670 }
671 /// Checks if two SpendableOutputDescriptors contain equal inner contents.
672 /// This ignores pointers and is_owned flags and looks at the values in fields.
673 #[no_mangle]
674 pub extern "C" fn SpendableOutputDescriptor_eq(a: &SpendableOutputDescriptor, b: &SpendableOutputDescriptor) -> bool {
675         if &a.to_native() == &b.to_native() { true } else { false }
676 }
677 #[no_mangle]
678 /// Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read
679 pub extern "C" fn SpendableOutputDescriptor_write(obj: &crate::lightning::sign::SpendableOutputDescriptor) -> crate::c_types::derived::CVec_u8Z {
680         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
681 }
682 #[no_mangle]
683 /// Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write
684 pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpendableOutputDescriptorDecodeErrorZ {
685         let res: Result<lightning::sign::SpendableOutputDescriptor, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
686         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::sign::SpendableOutputDescriptor::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
687         local_res
688 }
689 /// Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to
690 /// the given outputs, plus an output to the given change destination (if sufficient
691 /// change value remains). The PSBT will have a feerate, at least, of the given value.
692 ///
693 /// The `locktime` argument is used to set the transaction's locktime. If `None`, the
694 /// transaction will have a locktime of 0. It it recommended to set this to the current block
695 /// height to avoid fee sniping, unless you have some specific reason to use a different
696 /// locktime.
697 ///
698 /// Returns the PSBT and expected max transaction weight.
699 ///
700 /// Returns `Err(())` if the output value is greater than the input value minus required fee,
701 /// if a descriptor was duplicated, or if an output descriptor `script_pubkey`
702 /// does not match the one we can spend.
703 ///
704 /// We do not enforce that outputs meet the dust limit or that any output scripts are standard.
705 #[must_use]
706 #[no_mangle]
707 pub extern "C" fn SpendableOutputDescriptor_create_spendable_outputs_psbt(mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_u32Z) -> crate::c_types::derived::CResult_C2Tuple_CVec_u8ZusizeZNoneZ {
708         let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); };
709         let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); };
710         let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::PackedLockTime({ locktime_opt.take() }) }})} };
711         let mut ret = lightning::sign::SpendableOutputDescriptor::create_spendable_outputs_psbt(&local_descriptors.iter().collect::<Vec<_>>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime);
712         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (::bitcoin::consensus::encode::serialize(&orig_ret_0_0).into(), orig_ret_0_1).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
713         local_ret
714 }
715
716 /// A trait to handle Lightning channel key material without concretizing the channel type or
717 /// the signature mechanism.
718 #[repr(C)]
719 pub struct ChannelSigner {
720         /// An opaque pointer which is passed to your function implementations as an argument.
721         /// This has no meaning in the LDK, and can be NULL or any other value.
722         pub this_arg: *mut c_void,
723         /// Gets the per-commitment point for a specific commitment number
724         ///
725         /// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
726         pub get_per_commitment_point: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::PublicKey,
727         /// Gets the commitment secret for a specific commitment number as part of the revocation process
728         ///
729         /// An external signer implementation should error here if the commitment was already signed
730         /// and should refuse to sign it in the future.
731         ///
732         /// May be called more than once for the same index.
733         ///
734         /// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
735         pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes,
736         /// Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
737         ///
738         /// This is required in order for the signer to make sure that releasing a commitment
739         /// secret won't leave us without a broadcastable holder transaction.
740         /// Policy checks should be implemented in this function, including checking the amount
741         /// sent to us and checking the HTLCs.
742         ///
743         /// The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
744         /// A validating signer should ensure that an HTLC output is removed only when the matching
745         /// preimage is provided, or when the value to holder is restored.
746         ///
747         /// Note that all the relevant preimages will be provided, but there may also be additional
748         /// irrelevant or duplicate preimages.
749         pub validate_holder_commitment: extern "C" fn (this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, preimages: crate::c_types::derived::CVec_ThirtyTwoBytesZ) -> crate::c_types::derived::CResult_NoneNoneZ,
750         /// Returns the holder's channel public keys and basepoints.
751         pub pubkeys: core::cell::UnsafeCell<crate::lightning::ln::chan_utils::ChannelPublicKeys>,
752         /// Fill in the pubkeys field as a reference to it will be given to Rust after this returns
753         /// Note that this takes a pointer to this object, not the this_ptr like other methods do
754         /// This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating.
755         pub set_pubkeys: Option<extern "C" fn(&ChannelSigner)>,
756         /// Returns an arbitrary identifier describing the set of keys which are provided back to you in
757         /// some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
758         /// [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys.
759         pub channel_keys_id: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes,
760         /// Set the counterparty static channel data, including basepoints,
761         /// `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint.
762         ///
763         /// This data is static, and will never change for a channel once set. For a given [`ChannelSigner`]
764         /// instance, LDK will call this method exactly once - either immediately after construction
765         /// (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding
766         /// information has been generated.
767         ///
768         /// channel_parameters.is_populated() MUST be true.
769         pub provide_channel_parameters: extern "C" fn (this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters),
770         /// Frees any resources associated with this object given its this_arg pointer.
771         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
772         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
773 }
774 unsafe impl Send for ChannelSigner {}
775 unsafe impl Sync for ChannelSigner {}
776 pub(crate) fn ChannelSigner_clone_fields(orig: &ChannelSigner) -> ChannelSigner {
777         ChannelSigner {
778                 this_arg: orig.this_arg,
779                 get_per_commitment_point: Clone::clone(&orig.get_per_commitment_point),
780                 release_commitment_secret: Clone::clone(&orig.release_commitment_secret),
781                 validate_holder_commitment: Clone::clone(&orig.validate_holder_commitment),
782                 pubkeys: Clone::clone(unsafe { &*core::cell::UnsafeCell::get(&orig.pubkeys)}).into(),
783                 set_pubkeys: Clone::clone(&orig.set_pubkeys),
784                 channel_keys_id: Clone::clone(&orig.channel_keys_id),
785                 provide_channel_parameters: Clone::clone(&orig.provide_channel_parameters),
786                 free: Clone::clone(&orig.free),
787         }
788 }
789
790 use lightning::sign::ChannelSigner as rustChannelSigner;
791 impl rustChannelSigner for ChannelSigner {
792         fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> bitcoin::secp256k1::PublicKey {
793                 let mut ret = (self.get_per_commitment_point)(self.this_arg, idx);
794                 ret.into_rust()
795         }
796         fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] {
797                 let mut ret = (self.release_commitment_secret)(self.this_arg, idx);
798                 ret.data
799         }
800         fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec<lightning::ln::PaymentPreimage>) -> Result<(), ()> {
801                 let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); };
802                 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());
803                 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)) })*/ })};
804                 local_ret
805         }
806         fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys {
807                 if let Some(f) = self.set_pubkeys {
808                         (f)(&self);
809                 }
810                 unsafe { &*self.pubkeys.get() }.get_native_ref()
811         }
812         fn channel_keys_id(&self) -> [u8; 32] {
813                 let mut ret = (self.channel_keys_id)(self.this_arg);
814                 ret.data
815         }
816         fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) {
817                 (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 })
818         }
819 }
820
821 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
822 // directly as a Deref trait in higher-level structs:
823 impl core::ops::Deref for ChannelSigner {
824         type Target = Self;
825         fn deref(&self) -> &Self {
826                 self
827         }
828 }
829 impl core::ops::DerefMut for ChannelSigner {
830         fn deref_mut(&mut self) -> &mut Self {
831                 self
832         }
833 }
834 /// Calls the free function if one is set
835 #[no_mangle]
836 pub extern "C" fn ChannelSigner_free(this_ptr: ChannelSigner) { }
837 impl Drop for ChannelSigner {
838         fn drop(&mut self) {
839                 if let Some(f) = self.free {
840                         f(self.this_arg);
841                 }
842         }
843 }
844 /// A trait to sign Lightning channel transactions as described in
845 /// [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md).
846 ///
847 /// Signing services could be implemented on a hardware wallet and should implement signing
848 /// policies in order to be secure. Please refer to the [VLS Policy
849 /// Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md)
850 /// for an example of such policies.
851 #[repr(C)]
852 pub struct EcdsaChannelSigner {
853         /// An opaque pointer which is passed to your function implementations as an argument.
854         /// This has no meaning in the LDK, and can be NULL or any other value.
855         pub this_arg: *mut c_void,
856         /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
857         ///
858         /// Note that if signing fails or is rejected, the channel will be force-closed.
859         ///
860         /// Policy checks should be implemented in this function, including checking the amount
861         /// sent to us and checking the HTLCs.
862         ///
863         /// The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
864         /// A validating signer should ensure that an HTLC output is removed only when the matching
865         /// preimage is provided, or when the value to holder is restored.
866         ///
867         /// Note that all the relevant preimages will be provided, but there may also be additional
868         /// irrelevant or duplicate preimages.
869         pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, preimages: crate::c_types::derived::CVec_ThirtyTwoBytesZ) -> crate::c_types::derived::CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ,
870         /// Validate the counterparty's revocation.
871         ///
872         /// This is required in order for the signer to make sure that the state has moved
873         /// forward and it is safe to sign the next counterparty commitment.
874         pub validate_counterparty_revocation: extern "C" fn (this_arg: *const c_void, idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ,
875         /// Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.
876         ///
877         /// This will be called
878         /// - with a non-revoked `commitment_tx`.
879         /// - with the latest `commitment_tx` when we initiate a force-close.
880         /// - with the previous `commitment_tx`, just to get claiming HTLC
881         ///   signatures, if we are reacting to a [`ChannelMonitor`]
882         ///   [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
883         ///   that decided to broadcast before it had been updated to the latest `commitment_tx`.
884         ///
885         /// This may be called multiple times for the same transaction.
886         ///
887         /// An external signer implementation should check that the commitment has not been revoked.
888         ///
889         /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
890         pub sign_holder_commitment_and_htlcs: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ,
891         /// Create a signature for the given input in a transaction spending an HTLC transaction output
892         /// or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
893         ///
894         /// A justice transaction may claim multiple outputs at the same time if timelocks are
895         /// similar, but only a signature for the input at index `input` should be signed for here.
896         /// It may be called multiple times for same output(s) if a fee-bump is needed with regards
897         /// to an upcoming timelock expiration.
898         ///
899         /// Amount is value of the output spent by this input, committed to in the BIP 143 signature.
900         ///
901         /// `per_commitment_key` is revocation secret which was provided by our counterparty when they
902         /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
903         /// not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
904         /// so).
905         pub sign_justice_revoked_output: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ,
906         /// Create a signature for the given input in a transaction spending a commitment transaction
907         /// HTLC output when our counterparty broadcasts an old state.
908         ///
909         /// A justice transaction may claim multiple outputs at the same time if timelocks are
910         /// similar, but only a signature for the input at index `input` should be signed for here.
911         /// It may be called multiple times for same output(s) if a fee-bump is needed with regards
912         /// to an upcoming timelock expiration.
913         ///
914         /// `amount` is the value of the output spent by this input, committed to in the BIP 143
915         /// signature.
916         ///
917         /// `per_commitment_key` is revocation secret which was provided by our counterparty when they
918         /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
919         /// not allow the spending of any funds by itself (you need our holder revocation_secret to do
920         /// so).
921         ///
922         /// `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
923         /// (which is committed to in the BIP 143 signatures).
924         pub sign_justice_revoked_htlc: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ,
925         /// Computes the signature for a commitment transaction's HTLC output used as an input within
926         /// `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
927         /// must be be computed using [`EcdsaSighashType::All`]. Note that this should only be used to
928         /// sign HTLC transactions from channels supporting anchor outputs after all additional
929         /// inputs/outputs have been added to the transaction.
930         ///
931         /// [`EcdsaSighashType::All`]: bitcoin::blockdata::transaction::EcdsaSighashType::All
932         pub sign_holder_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, htlc_descriptor: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ,
933         /// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
934         /// transaction, either offered or received.
935         ///
936         /// Such a transaction may claim multiples offered outputs at same time if we know the
937         /// preimage for each when we create it, but only the input at index `input` should be
938         /// signed for here. It may be called multiple times for same output(s) if a fee-bump is
939         /// needed with regards to an upcoming timelock expiration.
940         ///
941         /// `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
942         /// outputs.
943         ///
944         /// `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
945         ///
946         /// `per_commitment_point` is the dynamic point corresponding to the channel state
947         /// detected onchain. It has been generated by our counterparty and is used to derive
948         /// channel state keys, which are then included in the witness script and committed to in the
949         /// BIP 143 signature.
950         pub sign_counterparty_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ,
951         /// Create a signature for a (proposed) closing transaction.
952         ///
953         /// Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
954         /// chosen to forgo their output as dust.
955         pub sign_closing_transaction: extern "C" fn (this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ,
956         /// Computes the signature for a commitment transaction's anchor output used as an
957         /// input within `anchor_tx`, which spends the commitment transaction, at index `input`.
958         pub sign_holder_anchor_input: extern "C" fn (this_arg: *const c_void, anchor_tx: crate::c_types::Transaction, input: usize) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ,
959         /// Signs a channel announcement message with our funding key proving it comes from one of the
960         /// channel participants.
961         ///
962         /// Channel announcements also require a signature from each node's network key. Our node
963         /// signature is computed through [`NodeSigner::sign_gossip_message`].
964         ///
965         /// Note that if this fails or is rejected, the channel will not be publicly announced and
966         /// our counterparty may (though likely will not) close the channel on us for violating the
967         /// protocol.
968         pub sign_channel_announcement_with_funding_key: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ,
969         /// Implementation of ChannelSigner for this object.
970         pub ChannelSigner: crate::lightning::sign::ChannelSigner,
971         /// Frees any resources associated with this object given its this_arg pointer.
972         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
973         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
974 }
975 unsafe impl Send for EcdsaChannelSigner {}
976 unsafe impl Sync for EcdsaChannelSigner {}
977 pub(crate) fn EcdsaChannelSigner_clone_fields(orig: &EcdsaChannelSigner) -> EcdsaChannelSigner {
978         EcdsaChannelSigner {
979                 this_arg: orig.this_arg,
980                 sign_counterparty_commitment: Clone::clone(&orig.sign_counterparty_commitment),
981                 validate_counterparty_revocation: Clone::clone(&orig.validate_counterparty_revocation),
982                 sign_holder_commitment_and_htlcs: Clone::clone(&orig.sign_holder_commitment_and_htlcs),
983                 sign_justice_revoked_output: Clone::clone(&orig.sign_justice_revoked_output),
984                 sign_justice_revoked_htlc: Clone::clone(&orig.sign_justice_revoked_htlc),
985                 sign_holder_htlc_transaction: Clone::clone(&orig.sign_holder_htlc_transaction),
986                 sign_counterparty_htlc_transaction: Clone::clone(&orig.sign_counterparty_htlc_transaction),
987                 sign_closing_transaction: Clone::clone(&orig.sign_closing_transaction),
988                 sign_holder_anchor_input: Clone::clone(&orig.sign_holder_anchor_input),
989                 sign_channel_announcement_with_funding_key: Clone::clone(&orig.sign_channel_announcement_with_funding_key),
990                 ChannelSigner: crate::lightning::sign::ChannelSigner_clone_fields(&orig.ChannelSigner),
991                 free: Clone::clone(&orig.free),
992         }
993 }
994 impl lightning::sign::ChannelSigner for EcdsaChannelSigner {
995         fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> bitcoin::secp256k1::PublicKey {
996                 let mut ret = (self.ChannelSigner.get_per_commitment_point)(self.ChannelSigner.this_arg, idx);
997                 ret.into_rust()
998         }
999         fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] {
1000                 let mut ret = (self.ChannelSigner.release_commitment_secret)(self.ChannelSigner.this_arg, idx);
1001                 ret.data
1002         }
1003         fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec<lightning::ln::PaymentPreimage>) -> Result<(), ()> {
1004                 let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); };
1005                 let mut ret = (self.ChannelSigner.validate_holder_commitment)(self.ChannelSigner.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());
1006                 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)) })*/ })};
1007                 local_ret
1008         }
1009         fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys {
1010                 if let Some(f) = self.ChannelSigner.set_pubkeys {
1011                         (f)(&self.ChannelSigner);
1012                 }
1013                 unsafe { &*self.ChannelSigner.pubkeys.get() }.get_native_ref()
1014         }
1015         fn channel_keys_id(&self) -> [u8; 32] {
1016                 let mut ret = (self.ChannelSigner.channel_keys_id)(self.ChannelSigner.this_arg);
1017                 ret.data
1018         }
1019         fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) {
1020                 (self.ChannelSigner.provide_channel_parameters)(self.ChannelSigner.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 })
1021         }
1022 }
1023
1024 use lightning::sign::EcdsaChannelSigner as rustEcdsaChannelSigner;
1025 impl rustEcdsaChannelSigner for EcdsaChannelSigner {
1026         fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut preimages: Vec<lightning::ln::PaymentPreimage>, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec<bitcoin::secp256k1::ecdsa::Signature>), ()> {
1027                 let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); };
1028                 let mut ret = (self.sign_counterparty_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into());
1029                 let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1030                 local_ret
1031         }
1032         fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> {
1033                 let mut ret = (self.validate_counterparty_revocation)(self.this_arg, idx, secret.as_ref());
1034                 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)) })*/ })};
1035                 local_ret
1036         }
1037         fn sign_holder_commitment_and_htlcs(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec<bitcoin::secp256k1::ecdsa::Signature>), ()> {
1038                 let mut ret = (self.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false });
1039                 let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1040                 local_ret
1041         }
1042         fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1043                 let mut ret = (self.sign_justice_revoked_output)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref());
1044                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1045                 local_ret
1046         }
1047         fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1048                 let mut ret = (self.sign_justice_revoked_htlc)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false });
1049                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1050                 local_ret
1051         }
1052         fn sign_holder_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut htlc_descriptor: &lightning::events::bump_transaction::HTLCDescriptor, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1053                 let mut ret = (self.sign_holder_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, &crate::lightning::events::bump_transaction::HTLCDescriptor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc_descriptor as *const lightning::events::bump_transaction::HTLCDescriptor<>) as *mut _) }, is_owned: false });
1054                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1055                 local_ret
1056         }
1057         fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1058                 let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false });
1059                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1060                 local_ret
1061         }
1062         fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1063                 let mut ret = (self.sign_closing_transaction)(self.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const lightning::ln::chan_utils::ClosingTransaction<>) as *mut _) }, is_owned: false });
1064                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1065                 local_ret
1066         }
1067         fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1068                 let mut ret = (self.sign_holder_anchor_input)(self.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input);
1069                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1070                 local_ret
1071         }
1072         fn sign_channel_announcement_with_funding_key(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1073                 let mut ret = (self.sign_channel_announcement_with_funding_key)(self.this_arg, &crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false });
1074                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1075                 local_ret
1076         }
1077 }
1078
1079 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1080 // directly as a Deref trait in higher-level structs:
1081 impl core::ops::Deref for EcdsaChannelSigner {
1082         type Target = Self;
1083         fn deref(&self) -> &Self {
1084                 self
1085         }
1086 }
1087 impl core::ops::DerefMut for EcdsaChannelSigner {
1088         fn deref_mut(&mut self) -> &mut Self {
1089                 self
1090         }
1091 }
1092 /// Calls the free function if one is set
1093 #[no_mangle]
1094 pub extern "C" fn EcdsaChannelSigner_free(this_ptr: EcdsaChannelSigner) { }
1095 impl Drop for EcdsaChannelSigner {
1096         fn drop(&mut self) {
1097                 if let Some(f) = self.free {
1098                         f(self.this_arg);
1099                 }
1100         }
1101 }
1102 /// A writeable signer.
1103 ///
1104 /// There will always be two instances of a signer per channel, one occupied by the
1105 /// [`ChannelManager`] and another by the channel's [`ChannelMonitor`].
1106 ///
1107 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1108 /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
1109 #[repr(C)]
1110 pub struct WriteableEcdsaChannelSigner {
1111         /// An opaque pointer which is passed to your function implementations as an argument.
1112         /// This has no meaning in the LDK, and can be NULL or any other value.
1113         pub this_arg: *mut c_void,
1114         /// Implementation of EcdsaChannelSigner for this object.
1115         pub EcdsaChannelSigner: crate::lightning::sign::EcdsaChannelSigner,
1116         /// Serialize the object into a byte array
1117         pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z,
1118         /// Called, if set, after this WriteableEcdsaChannelSigner has been cloned into a duplicate object.
1119         /// The new WriteableEcdsaChannelSigner is provided, and should be mutated as needed to perform a
1120         /// deep copy of the object pointed to by this_arg or avoid any double-freeing.
1121         pub cloned: Option<extern "C" fn (new_WriteableEcdsaChannelSigner: &mut WriteableEcdsaChannelSigner)>,
1122         /// Frees any resources associated with this object given its this_arg pointer.
1123         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1124         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1125 }
1126 unsafe impl Send for WriteableEcdsaChannelSigner {}
1127 unsafe impl Sync for WriteableEcdsaChannelSigner {}
1128 pub(crate) fn WriteableEcdsaChannelSigner_clone_fields(orig: &WriteableEcdsaChannelSigner) -> WriteableEcdsaChannelSigner {
1129         WriteableEcdsaChannelSigner {
1130                 this_arg: orig.this_arg,
1131                 EcdsaChannelSigner: crate::lightning::sign::EcdsaChannelSigner_clone_fields(&orig.EcdsaChannelSigner),
1132                 write: Clone::clone(&orig.write),
1133                 cloned: Clone::clone(&orig.cloned),
1134                 free: Clone::clone(&orig.free),
1135         }
1136 }
1137 impl lightning::sign::EcdsaChannelSigner for WriteableEcdsaChannelSigner {
1138         fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut preimages: Vec<lightning::ln::PaymentPreimage>, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec<bitcoin::secp256k1::ecdsa::Signature>), ()> {
1139                 let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); };
1140                 let mut ret = (self.EcdsaChannelSigner.sign_counterparty_commitment)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into());
1141                 let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1142                 local_ret
1143         }
1144         fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> {
1145                 let mut ret = (self.EcdsaChannelSigner.validate_counterparty_revocation)(self.EcdsaChannelSigner.this_arg, idx, secret.as_ref());
1146                 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)) })*/ })};
1147                 local_ret
1148         }
1149         fn sign_holder_commitment_and_htlcs(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec<bitcoin::secp256k1::ecdsa::Signature>), ()> {
1150                 let mut ret = (self.EcdsaChannelSigner.sign_holder_commitment_and_htlcs)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false });
1151                 let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1152                 local_ret
1153         }
1154         fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1155                 let mut ret = (self.EcdsaChannelSigner.sign_justice_revoked_output)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref());
1156                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1157                 local_ret
1158         }
1159         fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1160                 let mut ret = (self.EcdsaChannelSigner.sign_justice_revoked_htlc)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false });
1161                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1162                 local_ret
1163         }
1164         fn sign_holder_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut htlc_descriptor: &lightning::events::bump_transaction::HTLCDescriptor, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1165                 let mut ret = (self.EcdsaChannelSigner.sign_holder_htlc_transaction)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, &crate::lightning::events::bump_transaction::HTLCDescriptor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc_descriptor as *const lightning::events::bump_transaction::HTLCDescriptor<>) as *mut _) }, is_owned: false });
1166                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1167                 local_ret
1168         }
1169         fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1170                 let mut ret = (self.EcdsaChannelSigner.sign_counterparty_htlc_transaction)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false });
1171                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1172                 local_ret
1173         }
1174         fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1175                 let mut ret = (self.EcdsaChannelSigner.sign_closing_transaction)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const lightning::ln::chan_utils::ClosingTransaction<>) as *mut _) }, is_owned: false });
1176                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1177                 local_ret
1178         }
1179         fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1180                 let mut ret = (self.EcdsaChannelSigner.sign_holder_anchor_input)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input);
1181                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1182                 local_ret
1183         }
1184         fn sign_channel_announcement_with_funding_key(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1185                 let mut ret = (self.EcdsaChannelSigner.sign_channel_announcement_with_funding_key)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false });
1186                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1187                 local_ret
1188         }
1189 }
1190 impl lightning::sign::ChannelSigner for WriteableEcdsaChannelSigner {
1191         fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> bitcoin::secp256k1::PublicKey {
1192                 let mut ret = (self.EcdsaChannelSigner.ChannelSigner.get_per_commitment_point)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx);
1193                 ret.into_rust()
1194         }
1195         fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] {
1196                 let mut ret = (self.EcdsaChannelSigner.ChannelSigner.release_commitment_secret)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx);
1197                 ret.data
1198         }
1199         fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec<lightning::ln::PaymentPreimage>) -> Result<(), ()> {
1200                 let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); };
1201                 let mut ret = (self.EcdsaChannelSigner.ChannelSigner.validate_holder_commitment)(self.EcdsaChannelSigner.ChannelSigner.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());
1202                 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)) })*/ })};
1203                 local_ret
1204         }
1205         fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys {
1206                 if let Some(f) = self.EcdsaChannelSigner.ChannelSigner.set_pubkeys {
1207                         (f)(&self.EcdsaChannelSigner.ChannelSigner);
1208                 }
1209                 unsafe { &*self.EcdsaChannelSigner.ChannelSigner.pubkeys.get() }.get_native_ref()
1210         }
1211         fn channel_keys_id(&self) -> [u8; 32] {
1212                 let mut ret = (self.EcdsaChannelSigner.ChannelSigner.channel_keys_id)(self.EcdsaChannelSigner.ChannelSigner.this_arg);
1213                 ret.data
1214         }
1215         fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) {
1216                 (self.EcdsaChannelSigner.ChannelSigner.provide_channel_parameters)(self.EcdsaChannelSigner.ChannelSigner.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 })
1217         }
1218 }
1219 impl lightning::util::ser::Writeable for WriteableEcdsaChannelSigner {
1220         fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> {
1221                 let vec = (self.write)(self.this_arg);
1222                 w.write_all(vec.as_slice())
1223         }
1224 }
1225 #[no_mangle]
1226 /// Creates a copy of a WriteableEcdsaChannelSigner
1227 pub extern "C" fn WriteableEcdsaChannelSigner_clone(orig: &WriteableEcdsaChannelSigner) -> WriteableEcdsaChannelSigner {
1228         let mut res = WriteableEcdsaChannelSigner_clone_fields(orig);
1229         if let Some(f) = orig.cloned { (f)(&mut res) };
1230         res
1231 }
1232 impl Clone for WriteableEcdsaChannelSigner {
1233         fn clone(&self) -> Self {
1234                 WriteableEcdsaChannelSigner_clone(self)
1235         }
1236 }
1237
1238 use lightning::sign::WriteableEcdsaChannelSigner as rustWriteableEcdsaChannelSigner;
1239 impl rustWriteableEcdsaChannelSigner for WriteableEcdsaChannelSigner {
1240 }
1241
1242 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1243 // directly as a Deref trait in higher-level structs:
1244 impl core::ops::Deref for WriteableEcdsaChannelSigner {
1245         type Target = Self;
1246         fn deref(&self) -> &Self {
1247                 self
1248         }
1249 }
1250 impl core::ops::DerefMut for WriteableEcdsaChannelSigner {
1251         fn deref_mut(&mut self) -> &mut Self {
1252                 self
1253         }
1254 }
1255 /// Calls the free function if one is set
1256 #[no_mangle]
1257 pub extern "C" fn WriteableEcdsaChannelSigner_free(this_ptr: WriteableEcdsaChannelSigner) { }
1258 impl Drop for WriteableEcdsaChannelSigner {
1259         fn drop(&mut self) {
1260                 if let Some(f) = self.free {
1261                         f(self.this_arg);
1262                 }
1263         }
1264 }
1265 /// Specifies the recipient of an invoice.
1266 ///
1267 /// This indicates to [`NodeSigner::sign_invoice`] what node secret key should be used to sign
1268 /// the invoice.
1269 #[derive(Clone)]
1270 #[must_use]
1271 #[repr(C)]
1272 pub enum Recipient {
1273         /// The invoice should be signed with the local node secret key.
1274         Node,
1275         /// The invoice should be signed with the phantom node secret key. This secret key must be the
1276         /// same for all nodes participating in the [phantom node payment].
1277         ///
1278         /// [phantom node payment]: PhantomKeysManager
1279         PhantomNode,
1280 }
1281 use lightning::sign::Recipient as RecipientImport;
1282 pub(crate) type nativeRecipient = RecipientImport;
1283
1284 impl Recipient {
1285         #[allow(unused)]
1286         pub(crate) fn to_native(&self) -> nativeRecipient {
1287                 match self {
1288                         Recipient::Node => nativeRecipient::Node,
1289                         Recipient::PhantomNode => nativeRecipient::PhantomNode,
1290                 }
1291         }
1292         #[allow(unused)]
1293         pub(crate) fn into_native(self) -> nativeRecipient {
1294                 match self {
1295                         Recipient::Node => nativeRecipient::Node,
1296                         Recipient::PhantomNode => nativeRecipient::PhantomNode,
1297                 }
1298         }
1299         #[allow(unused)]
1300         pub(crate) fn from_native(native: &nativeRecipient) -> Self {
1301                 match native {
1302                         nativeRecipient::Node => Recipient::Node,
1303                         nativeRecipient::PhantomNode => Recipient::PhantomNode,
1304                 }
1305         }
1306         #[allow(unused)]
1307         pub(crate) fn native_into(native: nativeRecipient) -> Self {
1308                 match native {
1309                         nativeRecipient::Node => Recipient::Node,
1310                         nativeRecipient::PhantomNode => Recipient::PhantomNode,
1311                 }
1312         }
1313 }
1314 /// Creates a copy of the Recipient
1315 #[no_mangle]
1316 pub extern "C" fn Recipient_clone(orig: &Recipient) -> Recipient {
1317         orig.clone()
1318 }
1319 #[no_mangle]
1320 /// Utility method to constructs a new Node-variant Recipient
1321 pub extern "C" fn Recipient_node() -> Recipient {
1322         Recipient::Node}
1323 #[no_mangle]
1324 /// Utility method to constructs a new PhantomNode-variant Recipient
1325 pub extern "C" fn Recipient_phantom_node() -> Recipient {
1326         Recipient::PhantomNode}
1327 /// A trait that describes a source of entropy.
1328 #[repr(C)]
1329 pub struct EntropySource {
1330         /// An opaque pointer which is passed to your function implementations as an argument.
1331         /// This has no meaning in the LDK, and can be NULL or any other value.
1332         pub this_arg: *mut c_void,
1333         /// Gets a unique, cryptographically-secure, random 32-byte value. This method must return a
1334         /// different value each time it is called.
1335         pub get_secure_random_bytes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes,
1336         /// Frees any resources associated with this object given its this_arg pointer.
1337         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1338         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1339 }
1340 unsafe impl Send for EntropySource {}
1341 unsafe impl Sync for EntropySource {}
1342 pub(crate) fn EntropySource_clone_fields(orig: &EntropySource) -> EntropySource {
1343         EntropySource {
1344                 this_arg: orig.this_arg,
1345                 get_secure_random_bytes: Clone::clone(&orig.get_secure_random_bytes),
1346                 free: Clone::clone(&orig.free),
1347         }
1348 }
1349
1350 use lightning::sign::EntropySource as rustEntropySource;
1351 impl rustEntropySource for EntropySource {
1352         fn get_secure_random_bytes(&self) -> [u8; 32] {
1353                 let mut ret = (self.get_secure_random_bytes)(self.this_arg);
1354                 ret.data
1355         }
1356 }
1357
1358 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1359 // directly as a Deref trait in higher-level structs:
1360 impl core::ops::Deref for EntropySource {
1361         type Target = Self;
1362         fn deref(&self) -> &Self {
1363                 self
1364         }
1365 }
1366 impl core::ops::DerefMut for EntropySource {
1367         fn deref_mut(&mut self) -> &mut Self {
1368                 self
1369         }
1370 }
1371 /// Calls the free function if one is set
1372 #[no_mangle]
1373 pub extern "C" fn EntropySource_free(this_ptr: EntropySource) { }
1374 impl Drop for EntropySource {
1375         fn drop(&mut self) {
1376                 if let Some(f) = self.free {
1377                         f(self.this_arg);
1378                 }
1379         }
1380 }
1381 /// A trait that can handle cryptographic operations at the scope level of a node.
1382 #[repr(C)]
1383 pub struct NodeSigner {
1384         /// An opaque pointer which is passed to your function implementations as an argument.
1385         /// This has no meaning in the LDK, and can be NULL or any other value.
1386         pub this_arg: *mut c_void,
1387         /// Get secret key material as bytes for use in encrypting and decrypting inbound payment data.
1388         ///
1389         /// If the implementor of this trait supports [phantom node payments], then every node that is
1390         /// intended to be included in the phantom invoice route hints must return the same value from
1391         /// this method.
1392         ///
1393         /// This method must return the same value each time it is called.
1394         ///
1395         /// [phantom node payments]: PhantomKeysManager
1396         pub get_inbound_payment_key_material: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes,
1397         /// Get node id based on the provided [`Recipient`].
1398         ///
1399         /// This method must return the same value each time it is called with a given [`Recipient`]
1400         /// parameter.
1401         ///
1402         /// Errors if the [`Recipient`] variant is not supported by the implementation.
1403         pub get_node_id: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ,
1404         /// Gets the ECDH shared secret of our node secret and `other_key`, multiplying by `tweak` if
1405         /// one is provided. Note that this tweak can be applied to `other_key` instead of our node
1406         /// secret, though this is less efficient.
1407         ///
1408         /// Note that if this fails while attempting to forward an HTLC, LDK will panic. The error
1409         /// should be resolved to allow LDK to resume forwarding HTLCs.
1410         ///
1411         /// Errors if the [`Recipient`] variant is not supported by the implementation.
1412         pub ecdh: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::sign::Recipient, other_key: crate::c_types::PublicKey, tweak: crate::c_types::derived::COption_BigEndianScalarZ) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ,
1413         /// Sign an invoice.
1414         ///
1415         /// By parameterizing by the raw invoice bytes instead of the hash, we allow implementors of
1416         /// this trait to parse the invoice and make sure they're signing what they expect, rather than
1417         /// blindly signing the hash.
1418         ///
1419         /// The `hrp_bytes` are ASCII bytes, while the `invoice_data` is base32.
1420         ///
1421         /// The secret key used to sign the invoice is dependent on the [`Recipient`].
1422         ///
1423         /// Errors if the [`Recipient`] variant is not supported by the implementation.
1424         pub sign_invoice: extern "C" fn (this_arg: *const c_void, hrp_bytes: crate::c_types::u8slice, invoice_data: crate::c_types::derived::CVec_U5Z, recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ,
1425         /// Signs the [`TaggedHash`] of a BOLT 12 invoice request.
1426         ///
1427         /// May be called by a function passed to [`UnsignedInvoiceRequest::sign`] where
1428         /// `invoice_request` is the callee.
1429         ///
1430         /// Implementors may check that the `invoice_request` is expected rather than blindly signing
1431         /// the tagged hash. An `Ok` result should sign `invoice_request.tagged_hash().as_digest()` with
1432         /// the node's signing key or an ephemeral key to preserve privacy, whichever is associated with
1433         /// [`UnsignedInvoiceRequest::payer_id`].
1434         ///
1435         /// [`TaggedHash`]: crate::offers::merkle::TaggedHash
1436         pub sign_bolt12_invoice_request: extern "C" fn (this_arg: *const c_void, invoice_request: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ,
1437         /// Signs the [`TaggedHash`] of a BOLT 12 invoice.
1438         ///
1439         /// May be called by a function passed to [`UnsignedBolt12Invoice::sign`] where `invoice` is the
1440         /// callee.
1441         ///
1442         /// Implementors may check that the `invoice` is expected rather than blindly signing the tagged
1443         /// hash. An `Ok` result should sign `invoice.tagged_hash().as_digest()` with the node's signing
1444         /// key or an ephemeral key to preserve privacy, whichever is associated with
1445         /// [`UnsignedBolt12Invoice::signing_pubkey`].
1446         ///
1447         /// [`TaggedHash`]: crate::offers::merkle::TaggedHash
1448         pub sign_bolt12_invoice: extern "C" fn (this_arg: *const c_void, invoice: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ,
1449         /// Sign a gossip message.
1450         ///
1451         /// Note that if this fails, LDK may panic and the message will not be broadcast to the network
1452         /// or a possible channel counterparty. If LDK panics, the error should be resolved to allow the
1453         /// message to be broadcast, as otherwise it may prevent one from receiving funds over the
1454         /// corresponding channel.
1455         pub sign_gossip_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ,
1456         /// Frees any resources associated with this object given its this_arg pointer.
1457         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1458         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1459 }
1460 unsafe impl Send for NodeSigner {}
1461 unsafe impl Sync for NodeSigner {}
1462 pub(crate) fn NodeSigner_clone_fields(orig: &NodeSigner) -> NodeSigner {
1463         NodeSigner {
1464                 this_arg: orig.this_arg,
1465                 get_inbound_payment_key_material: Clone::clone(&orig.get_inbound_payment_key_material),
1466                 get_node_id: Clone::clone(&orig.get_node_id),
1467                 ecdh: Clone::clone(&orig.ecdh),
1468                 sign_invoice: Clone::clone(&orig.sign_invoice),
1469                 sign_bolt12_invoice_request: Clone::clone(&orig.sign_bolt12_invoice_request),
1470                 sign_bolt12_invoice: Clone::clone(&orig.sign_bolt12_invoice),
1471                 sign_gossip_message: Clone::clone(&orig.sign_gossip_message),
1472                 free: Clone::clone(&orig.free),
1473         }
1474 }
1475
1476 use lightning::sign::NodeSigner as rustNodeSigner;
1477 impl rustNodeSigner for NodeSigner {
1478         fn get_inbound_payment_key_material(&self) -> lightning::sign::KeyMaterial {
1479                 let mut ret = (self.get_inbound_payment_key_material)(self.this_arg);
1480                 ::lightning::sign::KeyMaterial(ret.data)
1481         }
1482         fn get_node_id(&self, mut recipient: lightning::sign::Recipient) -> Result<bitcoin::secp256k1::PublicKey, ()> {
1483                 let mut ret = (self.get_node_id)(self.this_arg, crate::lightning::sign::Recipient::native_into(recipient));
1484                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1485                 local_ret
1486         }
1487         fn ecdh(&self, mut recipient: lightning::sign::Recipient, mut other_key: &bitcoin::secp256k1::PublicKey, mut tweak: Option<&bitcoin::secp256k1::Scalar>) -> Result<bitcoin::secp256k1::ecdh::SharedSecret, ()> {
1488                 let mut local_tweak = if tweak.is_none() { crate::c_types::derived::COption_BigEndianScalarZ::None } else { crate::c_types::derived::COption_BigEndianScalarZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::BigEndianScalar::from_rust(&(*tweak.as_ref().unwrap()).clone()) }) };
1489                 let mut ret = (self.ecdh)(self.this_arg, crate::lightning::sign::Recipient::native_into(recipient), crate::c_types::PublicKey::from_rust(&other_key), local_tweak);
1490                 let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1491                 local_ret
1492         }
1493         fn sign_invoice(&self, mut hrp_bytes: &[u8], mut invoice_data: &[bitcoin::bech32::u5], mut recipient: lightning::sign::Recipient) -> Result<bitcoin::secp256k1::ecdsa::RecoverableSignature, ()> {
1494                 let mut local_hrp_bytes = crate::c_types::u8slice::from_slice(hrp_bytes);
1495                 let mut local_invoice_data_clone = Vec::new(); local_invoice_data_clone.extend_from_slice(invoice_data); let mut invoice_data = local_invoice_data_clone; let mut local_invoice_data = Vec::new(); for mut item in invoice_data.drain(..) { local_invoice_data.push( { item.into() }); };
1496                 let mut ret = (self.sign_invoice)(self.this_arg, local_hrp_bytes, local_invoice_data.into(), crate::lightning::sign::Recipient::native_into(recipient));
1497                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1498                 local_ret
1499         }
1500         fn sign_bolt12_invoice_request(&self, mut invoice_request: &lightning::offers::invoice_request::UnsignedInvoiceRequest) -> Result<bitcoin::secp256k1::schnorr::Signature, ()> {
1501                 let mut ret = (self.sign_bolt12_invoice_request)(self.this_arg, &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest { inner: unsafe { ObjOps::nonnull_ptr_to_inner((invoice_request as *const lightning::offers::invoice_request::UnsignedInvoiceRequest<>) as *mut _) }, is_owned: false });
1502                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1503                 local_ret
1504         }
1505         fn sign_bolt12_invoice(&self, mut invoice: &lightning::offers::invoice::UnsignedBolt12Invoice) -> Result<bitcoin::secp256k1::schnorr::Signature, ()> {
1506                 let mut ret = (self.sign_bolt12_invoice)(self.this_arg, &crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((invoice as *const lightning::offers::invoice::UnsignedBolt12Invoice<>) as *mut _) }, is_owned: false });
1507                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1508                 local_ret
1509         }
1510         fn sign_gossip_message(&self, mut msg: lightning::ln::msgs::UnsignedGossipMessage) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> {
1511                 let mut ret = (self.sign_gossip_message)(self.this_arg, crate::lightning::ln::msgs::UnsignedGossipMessage::native_into(msg));
1512                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1513                 local_ret
1514         }
1515 }
1516
1517 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1518 // directly as a Deref trait in higher-level structs:
1519 impl core::ops::Deref for NodeSigner {
1520         type Target = Self;
1521         fn deref(&self) -> &Self {
1522                 self
1523         }
1524 }
1525 impl core::ops::DerefMut for NodeSigner {
1526         fn deref_mut(&mut self) -> &mut Self {
1527                 self
1528         }
1529 }
1530 /// Calls the free function if one is set
1531 #[no_mangle]
1532 pub extern "C" fn NodeSigner_free(this_ptr: NodeSigner) { }
1533 impl Drop for NodeSigner {
1534         fn drop(&mut self) {
1535                 if let Some(f) = self.free {
1536                         f(self.this_arg);
1537                 }
1538         }
1539 }
1540 /// A trait that can return signer instances for individual channels.
1541 #[repr(C)]
1542 pub struct SignerProvider {
1543         /// An opaque pointer which is passed to your function implementations as an argument.
1544         /// This has no meaning in the LDK, and can be NULL or any other value.
1545         pub this_arg: *mut c_void,
1546         /// Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through
1547         /// [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow
1548         /// implementations of [`SignerProvider`] to maintain a mapping between itself and the generated
1549         /// `channel_keys_id`.
1550         ///
1551         /// This method must return a different value each time it is called.
1552         pub generate_channel_keys_id: extern "C" fn (this_arg: *const c_void, inbound: bool, channel_value_satoshis: u64, user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes,
1553         /// Derives the private key material backing a `Signer`.
1554         ///
1555         /// To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through
1556         /// [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be
1557         /// re-derived from its `channel_keys_id`, which can be obtained through its trait method
1558         /// [`ChannelSigner::channel_keys_id`].
1559         pub derive_channel_signer: extern "C" fn (this_arg: *const c_void, channel_value_satoshis: u64, channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::WriteableEcdsaChannelSigner,
1560         /// Reads a [`Signer`] for this [`SignerProvider`] from the given input stream.
1561         /// This is only called during deserialization of other objects which contain
1562         /// [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s).
1563         /// The bytes are exactly those which `<Self::Signer as Writeable>::write()` writes, and
1564         /// contain no versioning scheme. You may wish to include your own version prefix and ensure
1565         /// you've read all of the provided bytes to ensure no corruption occurred.
1566         ///
1567         /// This method is slowly being phased out -- it will only be called when reading objects
1568         /// written by LDK versions prior to 0.0.113.
1569         ///
1570         /// [`Signer`]: Self::Signer
1571         /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
1572         /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1573         pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ,
1574         /// Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
1575         ///
1576         /// If this function returns an error, this will result in a channel failing to open.
1577         ///
1578         /// This method should return a different value each time it is called, to avoid linking
1579         /// on-chain funds across channels as controlled to the same user.
1580         pub get_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_CVec_u8ZNoneZ,
1581         /// Get a script pubkey which we will send funds to when closing a channel.
1582         ///
1583         /// If this function returns an error, this will result in a channel failing to open or close.
1584         /// In the event of a failure when the counterparty is initiating a close, this can result in a
1585         /// channel force close.
1586         ///
1587         /// This method should return a different value each time it is called, to avoid linking
1588         /// on-chain funds across channels as controlled to the same user.
1589         pub get_shutdown_scriptpubkey: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_ShutdownScriptNoneZ,
1590         /// Frees any resources associated with this object given its this_arg pointer.
1591         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1592         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1593 }
1594 unsafe impl Send for SignerProvider {}
1595 unsafe impl Sync for SignerProvider {}
1596 pub(crate) fn SignerProvider_clone_fields(orig: &SignerProvider) -> SignerProvider {
1597         SignerProvider {
1598                 this_arg: orig.this_arg,
1599                 generate_channel_keys_id: Clone::clone(&orig.generate_channel_keys_id),
1600                 derive_channel_signer: Clone::clone(&orig.derive_channel_signer),
1601                 read_chan_signer: Clone::clone(&orig.read_chan_signer),
1602                 get_destination_script: Clone::clone(&orig.get_destination_script),
1603                 get_shutdown_scriptpubkey: Clone::clone(&orig.get_shutdown_scriptpubkey),
1604                 free: Clone::clone(&orig.free),
1605         }
1606 }
1607
1608 use lightning::sign::SignerProvider as rustSignerProvider;
1609 impl rustSignerProvider for SignerProvider {
1610         type Signer = crate::lightning::sign::WriteableEcdsaChannelSigner;
1611         fn generate_channel_keys_id(&self, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: u128) -> [u8; 32] {
1612                 let mut ret = (self.generate_channel_keys_id)(self.this_arg, inbound, channel_value_satoshis, user_channel_id.into());
1613                 ret.data
1614         }
1615         fn derive_channel_signer(&self, mut channel_value_satoshis: u64, mut channel_keys_id: [u8; 32]) -> crate::lightning::sign::WriteableEcdsaChannelSigner {
1616                 let mut ret = (self.derive_channel_signer)(self.this_arg, channel_value_satoshis, crate::c_types::ThirtyTwoBytes { data: channel_keys_id });
1617                 ret
1618         }
1619         fn read_chan_signer(&self, mut reader: &[u8]) -> Result<crate::lightning::sign::WriteableEcdsaChannelSigner, lightning::ln::msgs::DecodeError> {
1620                 let mut local_reader = crate::c_types::u8slice::from_slice(reader);
1621                 let mut ret = (self.read_chan_signer)(self.this_arg, local_reader);
1622                 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)) }).into_native() })};
1623                 local_ret
1624         }
1625         fn get_destination_script(&self) -> Result<bitcoin::blockdata::script::Script, ()> {
1626                 let mut ret = (self.get_destination_script)(self.this_arg);
1627                 let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::blockdata::script::Script::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1628                 local_ret
1629         }
1630         fn get_shutdown_scriptpubkey(&self) -> Result<lightning::ln::script::ShutdownScript, ()> {
1631                 let mut ret = (self.get_shutdown_scriptpubkey)(self.this_arg);
1632                 let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1633                 local_ret
1634         }
1635 }
1636
1637 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1638 // directly as a Deref trait in higher-level structs:
1639 impl core::ops::Deref for SignerProvider {
1640         type Target = Self;
1641         fn deref(&self) -> &Self {
1642                 self
1643         }
1644 }
1645 impl core::ops::DerefMut for SignerProvider {
1646         fn deref_mut(&mut self) -> &mut Self {
1647                 self
1648         }
1649 }
1650 /// Calls the free function if one is set
1651 #[no_mangle]
1652 pub extern "C" fn SignerProvider_free(this_ptr: SignerProvider) { }
1653 impl Drop for SignerProvider {
1654         fn drop(&mut self) {
1655                 if let Some(f) = self.free {
1656                         f(self.this_arg);
1657                 }
1658         }
1659 }
1660
1661 use lightning::sign::InMemorySigner as nativeInMemorySignerImport;
1662 pub(crate) type nativeInMemorySigner = nativeInMemorySignerImport;
1663
1664 /// A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory.
1665 ///
1666 /// This implementation performs no policy checks and is insufficient by itself as
1667 /// a secure external signer.
1668 #[must_use]
1669 #[repr(C)]
1670 pub struct InMemorySigner {
1671         /// A pointer to the opaque Rust object.
1672
1673         /// Nearly everywhere, inner must be non-null, however in places where
1674         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1675         pub inner: *mut nativeInMemorySigner,
1676         /// Indicates that this is the only struct which contains the same pointer.
1677
1678         /// Rust functions which take ownership of an object provided via an argument require
1679         /// this to be true and invalidate the object pointed to by inner.
1680         pub is_owned: bool,
1681 }
1682
1683 impl Drop for InMemorySigner {
1684         fn drop(&mut self) {
1685                 if self.is_owned && !<*mut nativeInMemorySigner>::is_null(self.inner) {
1686                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1687                 }
1688         }
1689 }
1690 /// Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL.
1691 #[no_mangle]
1692 pub extern "C" fn InMemorySigner_free(this_obj: InMemorySigner) { }
1693 #[allow(unused)]
1694 /// Used only if an object of this type is returned as a trait impl by a method
1695 pub(crate) extern "C" fn InMemorySigner_free_void(this_ptr: *mut c_void) {
1696         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInMemorySigner) };
1697 }
1698 #[allow(unused)]
1699 impl InMemorySigner {
1700         pub(crate) fn get_native_ref(&self) -> &'static nativeInMemorySigner {
1701                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1702         }
1703         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInMemorySigner {
1704                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1705         }
1706         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1707         pub(crate) fn take_inner(mut self) -> *mut nativeInMemorySigner {
1708                 assert!(self.is_owned);
1709                 let ret = ObjOps::untweak_ptr(self.inner);
1710                 self.inner = core::ptr::null_mut();
1711                 ret
1712         }
1713 }
1714 /// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the
1715 /// holder's anchor output in a commitment transaction, if one is present.
1716 #[no_mangle]
1717 pub extern "C" fn InMemorySigner_get_funding_key(this_ptr: &InMemorySigner) -> *const [u8; 32] {
1718         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_key;
1719         inner_val.as_ref()
1720 }
1721 /// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the
1722 /// holder's anchor output in a commitment transaction, if one is present.
1723 #[no_mangle]
1724 pub extern "C" fn InMemorySigner_set_funding_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) {
1725         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_key = val.into_rust();
1726 }
1727 /// Holder secret key for blinded revocation pubkey.
1728 #[no_mangle]
1729 pub extern "C" fn InMemorySigner_get_revocation_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] {
1730         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_base_key;
1731         inner_val.as_ref()
1732 }
1733 /// Holder secret key for blinded revocation pubkey.
1734 #[no_mangle]
1735 pub extern "C" fn InMemorySigner_set_revocation_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) {
1736         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_base_key = val.into_rust();
1737 }
1738 /// Holder secret key used for our balance in counterparty-broadcasted commitment transactions.
1739 #[no_mangle]
1740 pub extern "C" fn InMemorySigner_get_payment_key(this_ptr: &InMemorySigner) -> *const [u8; 32] {
1741         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_key;
1742         inner_val.as_ref()
1743 }
1744 /// Holder secret key used for our balance in counterparty-broadcasted commitment transactions.
1745 #[no_mangle]
1746 pub extern "C" fn InMemorySigner_set_payment_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) {
1747         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_key = val.into_rust();
1748 }
1749 /// Holder secret key used in an HTLC transaction.
1750 #[no_mangle]
1751 pub extern "C" fn InMemorySigner_get_delayed_payment_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] {
1752         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_base_key;
1753         inner_val.as_ref()
1754 }
1755 /// Holder secret key used in an HTLC transaction.
1756 #[no_mangle]
1757 pub extern "C" fn InMemorySigner_set_delayed_payment_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) {
1758         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_base_key = val.into_rust();
1759 }
1760 /// Holder HTLC secret key used in commitment transaction HTLC outputs.
1761 #[no_mangle]
1762 pub extern "C" fn InMemorySigner_get_htlc_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] {
1763         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_base_key;
1764         inner_val.as_ref()
1765 }
1766 /// Holder HTLC secret key used in commitment transaction HTLC outputs.
1767 #[no_mangle]
1768 pub extern "C" fn InMemorySigner_set_htlc_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) {
1769         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_base_key = val.into_rust();
1770 }
1771 /// Commitment seed.
1772 #[no_mangle]
1773 pub extern "C" fn InMemorySigner_get_commitment_seed(this_ptr: &InMemorySigner) -> *const [u8; 32] {
1774         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_seed;
1775         inner_val
1776 }
1777 /// Commitment seed.
1778 #[no_mangle]
1779 pub extern "C" fn InMemorySigner_set_commitment_seed(this_ptr: &mut InMemorySigner, mut val: crate::c_types::ThirtyTwoBytes) {
1780         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_seed = val.data;
1781 }
1782 impl Clone for InMemorySigner {
1783         fn clone(&self) -> Self {
1784                 Self {
1785                         inner: if <*mut nativeInMemorySigner>::is_null(self.inner) { core::ptr::null_mut() } else {
1786                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1787                         is_owned: true,
1788                 }
1789         }
1790 }
1791 #[allow(unused)]
1792 /// Used only if an object of this type is returned as a trait impl by a method
1793 pub(crate) extern "C" fn InMemorySigner_clone_void(this_ptr: *const c_void) -> *mut c_void {
1794         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInMemorySigner)).clone() })) as *mut c_void
1795 }
1796 #[no_mangle]
1797 /// Creates a copy of the InMemorySigner
1798 pub extern "C" fn InMemorySigner_clone(orig: &InMemorySigner) -> InMemorySigner {
1799         orig.clone()
1800 }
1801 /// Creates a new [`InMemorySigner`].
1802 #[must_use]
1803 #[no_mangle]
1804 pub extern "C" fn InMemorySigner_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes, mut rand_bytes_unique_start: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::InMemorySigner {
1805         let mut ret = lightning::sign::InMemorySigner::new(secp256k1::global::SECP256K1, funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, channel_keys_id.data, rand_bytes_unique_start.data);
1806         crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true }
1807 }
1808
1809 /// Returns the counterparty's pubkeys.
1810 ///
1811 /// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
1812 /// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
1813 ///
1814 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1815 #[must_use]
1816 #[no_mangle]
1817 pub extern "C" fn InMemorySigner_counterparty_pubkeys(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning::ln::chan_utils::ChannelPublicKeys {
1818         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.counterparty_pubkeys();
1819         let mut local_ret = crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::chan_utils::ChannelPublicKeys<>) as *mut _ }, is_owned: false };
1820         local_ret
1821 }
1822
1823 /// Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable
1824 /// transactions, i.e., the amount of time that we have to wait to recover our funds if we
1825 /// broadcast a transaction.
1826 ///
1827 /// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
1828 /// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
1829 #[must_use]
1830 #[no_mangle]
1831 pub extern "C" fn InMemorySigner_counterparty_selected_contest_delay(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::c_types::derived::COption_u16Z {
1832         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.counterparty_selected_contest_delay();
1833         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u16Z::None } else { crate::c_types::derived::COption_u16Z::Some( { ret.unwrap() }) };
1834         local_ret
1835 }
1836
1837 /// Returns the `contest_delay` value specified by us and applied on transactions broadcastable
1838 /// by our counterparty, i.e., the amount of time that they have to wait to recover their funds
1839 /// if they broadcast a transaction.
1840 ///
1841 /// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
1842 /// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
1843 #[must_use]
1844 #[no_mangle]
1845 pub extern "C" fn InMemorySigner_holder_selected_contest_delay(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::c_types::derived::COption_u16Z {
1846         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.holder_selected_contest_delay();
1847         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u16Z::None } else { crate::c_types::derived::COption_u16Z::Some( { ret.unwrap() }) };
1848         local_ret
1849 }
1850
1851 /// Returns whether the holder is the initiator.
1852 ///
1853 /// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
1854 /// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
1855 #[must_use]
1856 #[no_mangle]
1857 pub extern "C" fn InMemorySigner_is_outbound(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::c_types::derived::COption_boolZ {
1858         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_outbound();
1859         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_boolZ::None } else { crate::c_types::derived::COption_boolZ::Some( { ret.unwrap() }) };
1860         local_ret
1861 }
1862
1863 /// Funding outpoint
1864 ///
1865 /// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
1866 /// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
1867 ///
1868 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1869 #[must_use]
1870 #[no_mangle]
1871 pub extern "C" fn InMemorySigner_funding_outpoint(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning::chain::transaction::OutPoint {
1872         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_outpoint();
1873         let mut local_ret = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false };
1874         local_ret
1875 }
1876
1877 /// Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or
1878 /// building transactions.
1879 ///
1880 /// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
1881 /// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
1882 ///
1883 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1884 #[must_use]
1885 #[no_mangle]
1886 pub extern "C" fn InMemorySigner_get_channel_parameters(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning::ln::chan_utils::ChannelTransactionParameters {
1887         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_channel_parameters();
1888         let mut local_ret = crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _ }, is_owned: false };
1889         local_ret
1890 }
1891
1892 /// Returns the channel type features of the channel parameters. Should be helpful for
1893 /// determining a channel's category, i. e. legacy/anchors/taproot/etc.
1894 ///
1895 /// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
1896 /// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
1897 ///
1898 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1899 #[must_use]
1900 #[no_mangle]
1901 pub extern "C" fn InMemorySigner_channel_type_features(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning::ln::features::ChannelTypeFeatures {
1902         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features();
1903         let mut local_ret = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1904         local_ret
1905 }
1906
1907 /// Sign the single input of `spend_tx` at index `input_idx`, which spends the output described
1908 /// by `descriptor`, returning the witness stack for the input.
1909 ///
1910 /// Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`,
1911 /// is not spending the outpoint described by [`descriptor.outpoint`],
1912 /// or if an output descriptor `script_pubkey` does not match the one we can spend.
1913 ///
1914 /// [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint
1915 #[must_use]
1916 #[no_mangle]
1917 pub extern "C" fn InMemorySigner_sign_counterparty_payment_input(this_arg: &crate::lightning::sign::InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::lightning::sign::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ {
1918         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_counterparty_payment_input(&spend_tx.into_bitcoin(), input_idx, descriptor.get_native_ref(), secp256k1::global::SECP256K1);
1919         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
1920         local_ret
1921 }
1922
1923 /// Sign the single input of `spend_tx` at index `input_idx` which spends the output
1924 /// described by `descriptor`, returning the witness stack for the input.
1925 ///
1926 /// Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`,
1927 /// is not spending the outpoint described by [`descriptor.outpoint`], does not have a
1928 /// sequence set to [`descriptor.to_self_delay`], or if an output descriptor
1929 /// `script_pubkey` does not match the one we can spend.
1930 ///
1931 /// [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint
1932 /// [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay
1933 #[must_use]
1934 #[no_mangle]
1935 pub extern "C" fn InMemorySigner_sign_dynamic_p2wsh_input(this_arg: &crate::lightning::sign::InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::lightning::sign::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ {
1936         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_dynamic_p2wsh_input(&spend_tx.into_bitcoin(), input_idx, descriptor.get_native_ref(), secp256k1::global::SECP256K1);
1937         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
1938         local_ret
1939 }
1940
1941 impl From<nativeInMemorySigner> for crate::lightning::sign::EntropySource {
1942         fn from(obj: nativeInMemorySigner) -> Self {
1943                 let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true };
1944                 let mut ret = InMemorySigner_as_EntropySource(&rust_obj);
1945                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
1946                 rust_obj.inner = core::ptr::null_mut();
1947                 ret.free = Some(InMemorySigner_free_void);
1948                 ret
1949         }
1950 }
1951 /// Constructs a new EntropySource which calls the relevant methods on this_arg.
1952 /// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is
1953 #[no_mangle]
1954 pub extern "C" fn InMemorySigner_as_EntropySource(this_arg: &InMemorySigner) -> crate::lightning::sign::EntropySource {
1955         crate::lightning::sign::EntropySource {
1956                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
1957                 free: None,
1958                 get_secure_random_bytes: InMemorySigner_EntropySource_get_secure_random_bytes,
1959         }
1960 }
1961
1962 #[must_use]
1963 extern "C" fn InMemorySigner_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes {
1964         let mut ret = <nativeInMemorySigner as lightning::sign::EntropySource<>>::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, );
1965         crate::c_types::ThirtyTwoBytes { data: ret }
1966 }
1967
1968 impl From<nativeInMemorySigner> for crate::lightning::sign::ChannelSigner {
1969         fn from(obj: nativeInMemorySigner) -> Self {
1970                 let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true };
1971                 let mut ret = InMemorySigner_as_ChannelSigner(&rust_obj);
1972                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
1973                 rust_obj.inner = core::ptr::null_mut();
1974                 ret.free = Some(InMemorySigner_free_void);
1975                 ret
1976         }
1977 }
1978 /// Constructs a new ChannelSigner which calls the relevant methods on this_arg.
1979 /// This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is
1980 #[no_mangle]
1981 pub extern "C" fn InMemorySigner_as_ChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::sign::ChannelSigner {
1982         crate::lightning::sign::ChannelSigner {
1983                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
1984                 free: None,
1985                 get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point,
1986                 release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret,
1987                 validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment,
1988
1989                 pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(),
1990                 set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys),
1991                 channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id,
1992                 provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters,
1993         }
1994 }
1995
1996 #[must_use]
1997 extern "C" fn InMemorySigner_ChannelSigner_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey {
1998         let mut ret = <nativeInMemorySigner as lightning::sign::ChannelSigner<>>::get_per_commitment_point(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, secp256k1::global::SECP256K1);
1999         crate::c_types::PublicKey::from_rust(&ret)
2000 }
2001 #[must_use]
2002 extern "C" fn InMemorySigner_ChannelSigner_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes {
2003         let mut ret = <nativeInMemorySigner as lightning::sign::ChannelSigner<>>::release_commitment_secret(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx);
2004         crate::c_types::ThirtyTwoBytes { data: ret }
2005 }
2006 #[must_use]
2007 extern "C" fn InMemorySigner_ChannelSigner_validate_holder_commitment(this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: crate::c_types::derived::CVec_ThirtyTwoBytesZ) -> crate::c_types::derived::CResult_NoneNoneZ {
2008         let mut local_preimages = Vec::new(); for mut item in preimages.into_rust().drain(..) { local_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); };
2009         let mut ret = <nativeInMemorySigner as lightning::sign::ChannelSigner<>>::validate_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, holder_tx.get_native_ref(), local_preimages);
2010         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2011         local_ret
2012 }
2013 #[must_use]
2014 extern "C" fn InMemorySigner_ChannelSigner_pubkeys(this_arg: *const c_void) -> crate::lightning::ln::chan_utils::ChannelPublicKeys {
2015         let mut ret = <nativeInMemorySigner as lightning::sign::ChannelSigner<>>::pubkeys(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, );
2016         crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelPublicKeys<>) as *mut _) }, is_owned: false }
2017 }
2018 extern "C" fn InMemorySigner_ChannelSigner_set_pubkeys(trait_self_arg: &ChannelSigner) {
2019         // This is a bit race-y in the general case, but for our specific use-cases today, we're safe
2020         // Specifically, we must ensure that the first time we're called it can never be in parallel
2021         if unsafe { &*trait_self_arg.pubkeys.get() }.inner.is_null() {
2022                 *unsafe { &mut *(&*(trait_self_arg as *const ChannelSigner)).pubkeys.get() } = InMemorySigner_ChannelSigner_pubkeys(trait_self_arg.this_arg).into();
2023         }
2024 }
2025 #[must_use]
2026 extern "C" fn InMemorySigner_ChannelSigner_channel_keys_id(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes {
2027         let mut ret = <nativeInMemorySigner as lightning::sign::ChannelSigner<>>::channel_keys_id(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, );
2028         crate::c_types::ThirtyTwoBytes { data: ret }
2029 }
2030 extern "C" fn InMemorySigner_ChannelSigner_provide_channel_parameters(this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters) {
2031         <nativeInMemorySigner as lightning::sign::ChannelSigner<>>::provide_channel_parameters(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, channel_parameters.get_native_ref())
2032 }
2033
2034 impl From<nativeInMemorySigner> for crate::lightning::sign::EcdsaChannelSigner {
2035         fn from(obj: nativeInMemorySigner) -> Self {
2036                 let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true };
2037                 let mut ret = InMemorySigner_as_EcdsaChannelSigner(&rust_obj);
2038                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2039                 rust_obj.inner = core::ptr::null_mut();
2040                 ret.free = Some(InMemorySigner_free_void);
2041                 ret
2042         }
2043 }
2044 /// Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg.
2045 /// This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is
2046 #[no_mangle]
2047 pub extern "C" fn InMemorySigner_as_EcdsaChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::sign::EcdsaChannelSigner {
2048         crate::lightning::sign::EcdsaChannelSigner {
2049                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2050                 free: None,
2051                 sign_counterparty_commitment: InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment,
2052                 validate_counterparty_revocation: InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation,
2053                 sign_holder_commitment_and_htlcs: InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs,
2054                 sign_justice_revoked_output: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output,
2055                 sign_justice_revoked_htlc: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc,
2056                 sign_holder_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_holder_htlc_transaction,
2057                 sign_counterparty_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction,
2058                 sign_closing_transaction: InMemorySigner_EcdsaChannelSigner_sign_closing_transaction,
2059                 sign_holder_anchor_input: InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input,
2060                 sign_channel_announcement_with_funding_key: InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key,
2061                 ChannelSigner: crate::lightning::sign::ChannelSigner {
2062                         this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2063                         free: None,
2064                         get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point,
2065                         release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret,
2066                         validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment,
2067
2068                         pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(),
2069                         set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys),
2070                         channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id,
2071                         provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters,
2072                 },
2073         }
2074 }
2075
2076 #[must_use]
2077 extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, mut preimages: crate::c_types::derived::CVec_ThirtyTwoBytesZ) -> crate::c_types::derived::CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ {
2078         let mut local_preimages = Vec::new(); for mut item in preimages.into_rust().drain(..) { local_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); };
2079         let mut ret = <nativeInMemorySigner as lightning::sign::EcdsaChannelSigner<>>::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), local_preimages, secp256k1::global::SECP256K1);
2080         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::ECDSASignature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::ECDSASignature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2081         local_ret
2082 }
2083 #[must_use]
2084 extern "C" fn InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation(this_arg: *const c_void, mut idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ {
2085         let mut ret = <nativeInMemorySigner as lightning::sign::EcdsaChannelSigner<>>::validate_counterparty_revocation(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *secret}[..]).unwrap());
2086         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2087         local_ret
2088 }
2089 #[must_use]
2090 extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ {
2091         let mut ret = <nativeInMemorySigner as lightning::sign::EcdsaChannelSigner<>>::sign_holder_commitment_and_htlcs(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), secp256k1::global::SECP256K1);
2092         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::ECDSASignature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::ECDSASignature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2093         local_ret
2094 }
2095 #[must_use]
2096 extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ {
2097         let mut ret = <nativeInMemorySigner as lightning::sign::EcdsaChannelSigner<>>::sign_justice_revoked_output(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), secp256k1::global::SECP256K1);
2098         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2099         local_ret
2100 }
2101 #[must_use]
2102 extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ {
2103         let mut ret = <nativeInMemorySigner as lightning::sign::EcdsaChannelSigner<>>::sign_justice_revoked_htlc(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), htlc.get_native_ref(), secp256k1::global::SECP256K1);
2104         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2105         local_ret
2106 }
2107 #[must_use]
2108 extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, htlc_descriptor: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ {
2109         let mut ret = <nativeInMemorySigner as lightning::sign::EcdsaChannelSigner<>>::sign_holder_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, htlc_descriptor.get_native_ref(), secp256k1::global::SECP256K1);
2110         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2111         local_ret
2112 }
2113 #[must_use]
2114 extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ {
2115         let mut ret = <nativeInMemorySigner as lightning::sign::EcdsaChannelSigner<>>::sign_counterparty_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), htlc.get_native_ref(), secp256k1::global::SECP256K1);
2116         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2117         local_ret
2118 }
2119 #[must_use]
2120 extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_closing_transaction(this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ {
2121         let mut ret = <nativeInMemorySigner as lightning::sign::EcdsaChannelSigner<>>::sign_closing_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, closing_tx.get_native_ref(), secp256k1::global::SECP256K1);
2122         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2123         local_ret
2124 }
2125 #[must_use]
2126 extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input(this_arg: *const c_void, mut anchor_tx: crate::c_types::Transaction, mut input: usize) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ {
2127         let mut ret = <nativeInMemorySigner as lightning::sign::EcdsaChannelSigner<>>::sign_holder_anchor_input(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &anchor_tx.into_bitcoin(), input, secp256k1::global::SECP256K1);
2128         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2129         local_ret
2130 }
2131 #[must_use]
2132 extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ {
2133         let mut ret = <nativeInMemorySigner as lightning::sign::EcdsaChannelSigner<>>::sign_channel_announcement_with_funding_key(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, msg.get_native_ref(), secp256k1::global::SECP256K1);
2134         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2135         local_ret
2136 }
2137
2138 impl From<nativeInMemorySigner> for crate::lightning::sign::WriteableEcdsaChannelSigner {
2139         fn from(obj: nativeInMemorySigner) -> Self {
2140                 let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true };
2141                 let mut ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&rust_obj);
2142                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2143                 rust_obj.inner = core::ptr::null_mut();
2144                 ret.free = Some(InMemorySigner_free_void);
2145                 ret
2146         }
2147 }
2148 /// Constructs a new WriteableEcdsaChannelSigner which calls the relevant methods on this_arg.
2149 /// This copies the `inner` pointer in this_arg and thus the returned WriteableEcdsaChannelSigner must be freed before this_arg is
2150 #[no_mangle]
2151 pub extern "C" fn InMemorySigner_as_WriteableEcdsaChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::sign::WriteableEcdsaChannelSigner {
2152         crate::lightning::sign::WriteableEcdsaChannelSigner {
2153                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2154                 free: None,
2155                 EcdsaChannelSigner: crate::lightning::sign::EcdsaChannelSigner {
2156                         this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2157                         free: None,
2158                         sign_counterparty_commitment: InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment,
2159                         validate_counterparty_revocation: InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation,
2160                         sign_holder_commitment_and_htlcs: InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs,
2161                         sign_justice_revoked_output: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output,
2162                         sign_justice_revoked_htlc: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc,
2163                         sign_holder_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_holder_htlc_transaction,
2164                         sign_counterparty_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction,
2165                         sign_closing_transaction: InMemorySigner_EcdsaChannelSigner_sign_closing_transaction,
2166                         sign_holder_anchor_input: InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input,
2167                         sign_channel_announcement_with_funding_key: InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key,
2168                         ChannelSigner: crate::lightning::sign::ChannelSigner {
2169                                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2170                                 free: None,
2171                                 get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point,
2172                                 release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret,
2173                                 validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment,
2174
2175                                 pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(),
2176                                 set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys),
2177                                 channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id,
2178                                 provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters,
2179                         },
2180                 },
2181                 write: InMemorySigner_write_void,
2182                 cloned: Some(WriteableEcdsaChannelSigner_InMemorySigner_cloned),
2183         }
2184 }
2185
2186 extern "C" fn WriteableEcdsaChannelSigner_InMemorySigner_cloned(new_obj: &mut crate::lightning::sign::WriteableEcdsaChannelSigner) {
2187         new_obj.this_arg = InMemorySigner_clone_void(new_obj.this_arg);
2188         new_obj.free = Some(InMemorySigner_free_void);
2189         new_obj.EcdsaChannelSigner.this_arg = new_obj.this_arg;
2190         new_obj.EcdsaChannelSigner.free = None;
2191 }
2192
2193 #[no_mangle]
2194 /// Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read
2195 pub extern "C" fn InMemorySigner_write(obj: &crate::lightning::sign::InMemorySigner) -> crate::c_types::derived::CVec_u8Z {
2196         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2197 }
2198 #[no_mangle]
2199 pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2200         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemorySigner) })
2201 }
2202 #[no_mangle]
2203 /// Read a InMemorySigner from a byte array, created by InMemorySigner_write
2204 pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice, arg: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ {
2205         let arg_conv = arg;
2206         let res: Result<lightning::sign::InMemorySigner, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv);
2207         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
2208         local_res
2209 }
2210
2211 use lightning::sign::KeysManager as nativeKeysManagerImport;
2212 pub(crate) type nativeKeysManager = nativeKeysManagerImport;
2213
2214 /// Simple implementation of [`EntropySource`], [`NodeSigner`], and [`SignerProvider`] that takes a
2215 /// 32-byte seed for use as a BIP 32 extended key and derives keys from that.
2216 ///
2217 /// Your `node_id` is seed/0'.
2218 /// Unilateral closes may use seed/1'.
2219 /// Cooperative closes may use seed/2'.
2220 /// The two close keys may be needed to claim on-chain funds!
2221 ///
2222 /// This struct cannot be used for nodes that wish to support receiving phantom payments;
2223 /// [`PhantomKeysManager`] must be used instead.
2224 ///
2225 /// Note that switching between this struct and [`PhantomKeysManager`] will invalidate any
2226 /// previously issued invoices and attempts to pay previous invoices will fail.
2227 #[must_use]
2228 #[repr(C)]
2229 pub struct KeysManager {
2230         /// A pointer to the opaque Rust object.
2231
2232         /// Nearly everywhere, inner must be non-null, however in places where
2233         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2234         pub inner: *mut nativeKeysManager,
2235         /// Indicates that this is the only struct which contains the same pointer.
2236
2237         /// Rust functions which take ownership of an object provided via an argument require
2238         /// this to be true and invalidate the object pointed to by inner.
2239         pub is_owned: bool,
2240 }
2241
2242 impl Drop for KeysManager {
2243         fn drop(&mut self) {
2244                 if self.is_owned && !<*mut nativeKeysManager>::is_null(self.inner) {
2245                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2246                 }
2247         }
2248 }
2249 /// Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL.
2250 #[no_mangle]
2251 pub extern "C" fn KeysManager_free(this_obj: KeysManager) { }
2252 #[allow(unused)]
2253 /// Used only if an object of this type is returned as a trait impl by a method
2254 pub(crate) extern "C" fn KeysManager_free_void(this_ptr: *mut c_void) {
2255         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeKeysManager) };
2256 }
2257 #[allow(unused)]
2258 impl KeysManager {
2259         pub(crate) fn get_native_ref(&self) -> &'static nativeKeysManager {
2260                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2261         }
2262         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeKeysManager {
2263                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2264         }
2265         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2266         pub(crate) fn take_inner(mut self) -> *mut nativeKeysManager {
2267                 assert!(self.is_owned);
2268                 let ret = ObjOps::untweak_ptr(self.inner);
2269                 self.inner = core::ptr::null_mut();
2270                 ret
2271         }
2272 }
2273 /// Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g.,
2274 /// your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds).
2275 /// `starting_time` isn't strictly required to actually be a time, but it must absolutely,
2276 /// without a doubt, be unique to this instance. ie if you start multiple times with the same
2277 /// `seed`, `starting_time` must be unique to each run. Thus, the easiest way to achieve this
2278 /// is to simply use the current time (with very high precision).
2279 ///
2280 /// The `seed` MUST be backed up safely prior to use so that the keys can be re-created, however,
2281 /// obviously, `starting_time` should be unique every time you reload the library - it is only
2282 /// used to generate new ephemeral key data (which will be stored by the individual channel if
2283 /// necessary).
2284 ///
2285 /// Note that the seed is required to recover certain on-chain funds independent of
2286 /// [`ChannelMonitor`] data, though a current copy of [`ChannelMonitor`] data is also required
2287 /// for any channel, and some on-chain during-closing funds.
2288 ///
2289 /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
2290 #[must_use]
2291 #[no_mangle]
2292 pub extern "C" fn KeysManager_new(seed: *const [u8; 32], mut starting_time_secs: u64, mut starting_time_nanos: u32) -> crate::lightning::sign::KeysManager {
2293         let mut ret = lightning::sign::KeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos);
2294         crate::lightning::sign::KeysManager { inner: ObjOps::heap_alloc(ret), is_owned: true }
2295 }
2296
2297 /// Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc.
2298 #[must_use]
2299 #[no_mangle]
2300 pub extern "C" fn KeysManager_get_node_secret_key(this_arg: &crate::lightning::sign::KeysManager) -> crate::c_types::SecretKey {
2301         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_node_secret_key();
2302         crate::c_types::SecretKey::from_rust(ret)
2303 }
2304
2305 /// Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters.
2306 #[must_use]
2307 #[no_mangle]
2308 pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &crate::lightning::sign::KeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::lightning::sign::InMemorySigner {
2309         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_keys(channel_value_satoshis, unsafe { &*params});
2310         crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true }
2311 }
2312
2313 /// Signs the given [`PartiallySignedTransaction`] which spends the given [`SpendableOutputDescriptor`]s.
2314 /// The resulting inputs will be finalized and the PSBT will be ready for broadcast if there
2315 /// are no other inputs that need signing.
2316 ///
2317 /// Returns `Err(())` if the PSBT is missing a descriptor or if we fail to sign.
2318 ///
2319 /// May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used
2320 /// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`].
2321 #[must_use]
2322 #[no_mangle]
2323 pub extern "C" fn KeysManager_sign_spendable_outputs_psbt(this_arg: &crate::lightning::sign::KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut psbt: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_CVec_u8ZNoneZ {
2324         let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); };
2325         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_spendable_outputs_psbt(&local_descriptors.iter().collect::<Vec<_>>()[..], ::bitcoin::consensus::encode::deserialize(psbt.as_slice()).expect("Invalid PSBT format"), secp256k1::global::SECP256K1);
2326         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { ::bitcoin::consensus::encode::serialize(&o).into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2327         local_ret
2328 }
2329
2330 /// Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an
2331 /// output to the given change destination (if sufficient change value remains). The
2332 /// transaction will have a feerate, at least, of the given value.
2333 ///
2334 /// The `locktime` argument is used to set the transaction's locktime. If `None`, the
2335 /// transaction will have a locktime of 0. It it recommended to set this to the current block
2336 /// height to avoid fee sniping, unless you have some specific reason to use a different
2337 /// locktime.
2338 ///
2339 /// Returns `Err(())` if the output value is greater than the input value minus required fee,
2340 /// if a descriptor was duplicated, or if an output descriptor `script_pubkey`
2341 /// does not match the one we can spend.
2342 ///
2343 /// We do not enforce that outputs meet the dust limit or that any output scripts are standard.
2344 ///
2345 /// May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used
2346 /// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`].
2347 #[must_use]
2348 #[no_mangle]
2349 pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &crate::lightning::sign::KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_u32Z) -> crate::c_types::derived::CResult_TransactionNoneZ {
2350         let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); };
2351         let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); };
2352         let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::PackedLockTime({ locktime_opt.take() }) }})} };
2353         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.spend_spendable_outputs(&local_descriptors.iter().collect::<Vec<_>>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime, secp256k1::global::SECP256K1);
2354         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2355         local_ret
2356 }
2357
2358 impl From<nativeKeysManager> for crate::lightning::sign::EntropySource {
2359         fn from(obj: nativeKeysManager) -> Self {
2360                 let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2361                 let mut ret = KeysManager_as_EntropySource(&rust_obj);
2362                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2363                 rust_obj.inner = core::ptr::null_mut();
2364                 ret.free = Some(KeysManager_free_void);
2365                 ret
2366         }
2367 }
2368 /// Constructs a new EntropySource which calls the relevant methods on this_arg.
2369 /// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is
2370 #[no_mangle]
2371 pub extern "C" fn KeysManager_as_EntropySource(this_arg: &KeysManager) -> crate::lightning::sign::EntropySource {
2372         crate::lightning::sign::EntropySource {
2373                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2374                 free: None,
2375                 get_secure_random_bytes: KeysManager_EntropySource_get_secure_random_bytes,
2376         }
2377 }
2378
2379 #[must_use]
2380 extern "C" fn KeysManager_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes {
2381         let mut ret = <nativeKeysManager as lightning::sign::EntropySource<>>::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, );
2382         crate::c_types::ThirtyTwoBytes { data: ret }
2383 }
2384
2385 impl From<nativeKeysManager> for crate::lightning::sign::NodeSigner {
2386         fn from(obj: nativeKeysManager) -> Self {
2387                 let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2388                 let mut ret = KeysManager_as_NodeSigner(&rust_obj);
2389                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2390                 rust_obj.inner = core::ptr::null_mut();
2391                 ret.free = Some(KeysManager_free_void);
2392                 ret
2393         }
2394 }
2395 /// Constructs a new NodeSigner which calls the relevant methods on this_arg.
2396 /// This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is
2397 #[no_mangle]
2398 pub extern "C" fn KeysManager_as_NodeSigner(this_arg: &KeysManager) -> crate::lightning::sign::NodeSigner {
2399         crate::lightning::sign::NodeSigner {
2400                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2401                 free: None,
2402                 get_inbound_payment_key_material: KeysManager_NodeSigner_get_inbound_payment_key_material,
2403                 get_node_id: KeysManager_NodeSigner_get_node_id,
2404                 ecdh: KeysManager_NodeSigner_ecdh,
2405                 sign_invoice: KeysManager_NodeSigner_sign_invoice,
2406                 sign_bolt12_invoice_request: KeysManager_NodeSigner_sign_bolt12_invoice_request,
2407                 sign_bolt12_invoice: KeysManager_NodeSigner_sign_bolt12_invoice,
2408                 sign_gossip_message: KeysManager_NodeSigner_sign_gossip_message,
2409         }
2410 }
2411
2412 #[must_use]
2413 extern "C" fn KeysManager_NodeSigner_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes {
2414         let mut ret = <nativeKeysManager as lightning::sign::NodeSigner<>>::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, );
2415         crate::c_types::ThirtyTwoBytes { data: ret.0 }
2416 }
2417 #[must_use]
2418 extern "C" fn KeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ {
2419         let mut ret = <nativeKeysManager as lightning::sign::NodeSigner<>>::get_node_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native());
2420         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2421         local_ret
2422 }
2423 #[must_use]
2424 extern "C" fn KeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_BigEndianScalarZ) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ {
2425         let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref();
2426         let mut ret = <nativeKeysManager as lightning::sign::NodeSigner<>>::ecdh(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak);
2427         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2428         local_ret
2429 }
2430 #[must_use]
2431 extern "C" fn KeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_U5Z, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ {
2432         let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); };
2433         let mut ret = <nativeKeysManager as lightning::sign::NodeSigner<>>::sign_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native());
2434         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2435         local_ret
2436 }
2437 #[must_use]
2438 extern "C" fn KeysManager_NodeSigner_sign_bolt12_invoice_request(this_arg: *const c_void, invoice_request: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ {
2439         let mut ret = <nativeKeysManager as lightning::sign::NodeSigner<>>::sign_bolt12_invoice_request(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, invoice_request.get_native_ref());
2440         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SchnorrSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2441         local_ret
2442 }
2443 #[must_use]
2444 extern "C" fn KeysManager_NodeSigner_sign_bolt12_invoice(this_arg: *const c_void, invoice: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ {
2445         let mut ret = <nativeKeysManager as lightning::sign::NodeSigner<>>::sign_bolt12_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, invoice.get_native_ref());
2446         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SchnorrSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2447         local_ret
2448 }
2449 #[must_use]
2450 extern "C" fn KeysManager_NodeSigner_sign_gossip_message(this_arg: *const c_void, mut msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ {
2451         let mut ret = <nativeKeysManager as lightning::sign::NodeSigner<>>::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, msg.into_native());
2452         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2453         local_ret
2454 }
2455
2456 impl From<nativeKeysManager> for crate::lightning::sign::SignerProvider {
2457         fn from(obj: nativeKeysManager) -> Self {
2458                 let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2459                 let mut ret = KeysManager_as_SignerProvider(&rust_obj);
2460                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2461                 rust_obj.inner = core::ptr::null_mut();
2462                 ret.free = Some(KeysManager_free_void);
2463                 ret
2464         }
2465 }
2466 /// Constructs a new SignerProvider which calls the relevant methods on this_arg.
2467 /// This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is
2468 #[no_mangle]
2469 pub extern "C" fn KeysManager_as_SignerProvider(this_arg: &KeysManager) -> crate::lightning::sign::SignerProvider {
2470         crate::lightning::sign::SignerProvider {
2471                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2472                 free: None,
2473                 generate_channel_keys_id: KeysManager_SignerProvider_generate_channel_keys_id,
2474                 derive_channel_signer: KeysManager_SignerProvider_derive_channel_signer,
2475                 read_chan_signer: KeysManager_SignerProvider_read_chan_signer,
2476                 get_destination_script: KeysManager_SignerProvider_get_destination_script,
2477                 get_shutdown_scriptpubkey: KeysManager_SignerProvider_get_shutdown_scriptpubkey,
2478         }
2479 }
2480
2481 #[must_use]
2482 extern "C" fn KeysManager_SignerProvider_generate_channel_keys_id(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes {
2483         let mut ret = <nativeKeysManager as lightning::sign::SignerProvider<>>::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into());
2484         crate::c_types::ThirtyTwoBytes { data: ret }
2485 }
2486 #[must_use]
2487 extern "C" fn KeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::WriteableEcdsaChannelSigner {
2488         let mut ret = <nativeKeysManager as lightning::sign::SignerProvider<>>::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, channel_value_satoshis, channel_keys_id.data);
2489         Into::into(ret)
2490 }
2491 #[must_use]
2492 extern "C" fn KeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ {
2493         let mut ret = <nativeKeysManager as lightning::sign::SignerProvider<>>::read_chan_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, reader.to_slice());
2494         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { Into::into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
2495         local_ret
2496 }
2497 #[must_use]
2498 extern "C" fn KeysManager_SignerProvider_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CResult_CVec_u8ZNoneZ {
2499         let mut ret = <nativeKeysManager as lightning::sign::SignerProvider<>>::get_destination_script(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, );
2500         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into_bytes().into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2501         local_ret
2502 }
2503 #[must_use]
2504 extern "C" fn KeysManager_SignerProvider_get_shutdown_scriptpubkey(this_arg: *const c_void) -> crate::c_types::derived::CResult_ShutdownScriptNoneZ {
2505         let mut ret = <nativeKeysManager as lightning::sign::SignerProvider<>>::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, );
2506         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2507         local_ret
2508 }
2509
2510
2511 use lightning::sign::PhantomKeysManager as nativePhantomKeysManagerImport;
2512 pub(crate) type nativePhantomKeysManager = nativePhantomKeysManagerImport;
2513
2514 /// Similar to [`KeysManager`], but allows the node using this struct to receive phantom node
2515 /// payments.
2516 ///
2517 /// A phantom node payment is a payment made to a phantom invoice, which is an invoice that can be
2518 /// paid to one of multiple nodes. This works because we encode the invoice route hints such that
2519 /// LDK will recognize an incoming payment as destined for a phantom node, and collect the payment
2520 /// itself without ever needing to forward to this fake node.
2521 ///
2522 /// Phantom node payments are useful for load balancing between multiple LDK nodes. They also
2523 /// provide some fault tolerance, because payers will automatically retry paying other provided
2524 /// nodes in the case that one node goes down.
2525 ///
2526 /// Note that multi-path payments are not supported in phantom invoices for security reasons.
2527 /// Switching between this struct and [`KeysManager`] will invalidate any previously issued
2528 /// invoices and attempts to pay previous invoices will fail.
2529 #[must_use]
2530 #[repr(C)]
2531 pub struct PhantomKeysManager {
2532         /// A pointer to the opaque Rust object.
2533
2534         /// Nearly everywhere, inner must be non-null, however in places where
2535         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2536         pub inner: *mut nativePhantomKeysManager,
2537         /// Indicates that this is the only struct which contains the same pointer.
2538
2539         /// Rust functions which take ownership of an object provided via an argument require
2540         /// this to be true and invalidate the object pointed to by inner.
2541         pub is_owned: bool,
2542 }
2543
2544 impl Drop for PhantomKeysManager {
2545         fn drop(&mut self) {
2546                 if self.is_owned && !<*mut nativePhantomKeysManager>::is_null(self.inner) {
2547                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2548                 }
2549         }
2550 }
2551 /// Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL.
2552 #[no_mangle]
2553 pub extern "C" fn PhantomKeysManager_free(this_obj: PhantomKeysManager) { }
2554 #[allow(unused)]
2555 /// Used only if an object of this type is returned as a trait impl by a method
2556 pub(crate) extern "C" fn PhantomKeysManager_free_void(this_ptr: *mut c_void) {
2557         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePhantomKeysManager) };
2558 }
2559 #[allow(unused)]
2560 impl PhantomKeysManager {
2561         pub(crate) fn get_native_ref(&self) -> &'static nativePhantomKeysManager {
2562                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2563         }
2564         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePhantomKeysManager {
2565                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2566         }
2567         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2568         pub(crate) fn take_inner(mut self) -> *mut nativePhantomKeysManager {
2569                 assert!(self.is_owned);
2570                 let ret = ObjOps::untweak_ptr(self.inner);
2571                 self.inner = core::ptr::null_mut();
2572                 ret
2573         }
2574 }
2575 impl From<nativePhantomKeysManager> for crate::lightning::sign::EntropySource {
2576         fn from(obj: nativePhantomKeysManager) -> Self {
2577                 let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2578                 let mut ret = PhantomKeysManager_as_EntropySource(&rust_obj);
2579                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2580                 rust_obj.inner = core::ptr::null_mut();
2581                 ret.free = Some(PhantomKeysManager_free_void);
2582                 ret
2583         }
2584 }
2585 /// Constructs a new EntropySource which calls the relevant methods on this_arg.
2586 /// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is
2587 #[no_mangle]
2588 pub extern "C" fn PhantomKeysManager_as_EntropySource(this_arg: &PhantomKeysManager) -> crate::lightning::sign::EntropySource {
2589         crate::lightning::sign::EntropySource {
2590                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2591                 free: None,
2592                 get_secure_random_bytes: PhantomKeysManager_EntropySource_get_secure_random_bytes,
2593         }
2594 }
2595
2596 #[must_use]
2597 extern "C" fn PhantomKeysManager_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes {
2598         let mut ret = <nativePhantomKeysManager as lightning::sign::EntropySource<>>::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, );
2599         crate::c_types::ThirtyTwoBytes { data: ret }
2600 }
2601
2602 impl From<nativePhantomKeysManager> for crate::lightning::sign::NodeSigner {
2603         fn from(obj: nativePhantomKeysManager) -> Self {
2604                 let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2605                 let mut ret = PhantomKeysManager_as_NodeSigner(&rust_obj);
2606                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2607                 rust_obj.inner = core::ptr::null_mut();
2608                 ret.free = Some(PhantomKeysManager_free_void);
2609                 ret
2610         }
2611 }
2612 /// Constructs a new NodeSigner which calls the relevant methods on this_arg.
2613 /// This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is
2614 #[no_mangle]
2615 pub extern "C" fn PhantomKeysManager_as_NodeSigner(this_arg: &PhantomKeysManager) -> crate::lightning::sign::NodeSigner {
2616         crate::lightning::sign::NodeSigner {
2617                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2618                 free: None,
2619                 get_inbound_payment_key_material: PhantomKeysManager_NodeSigner_get_inbound_payment_key_material,
2620                 get_node_id: PhantomKeysManager_NodeSigner_get_node_id,
2621                 ecdh: PhantomKeysManager_NodeSigner_ecdh,
2622                 sign_invoice: PhantomKeysManager_NodeSigner_sign_invoice,
2623                 sign_bolt12_invoice_request: PhantomKeysManager_NodeSigner_sign_bolt12_invoice_request,
2624                 sign_bolt12_invoice: PhantomKeysManager_NodeSigner_sign_bolt12_invoice,
2625                 sign_gossip_message: PhantomKeysManager_NodeSigner_sign_gossip_message,
2626         }
2627 }
2628
2629 #[must_use]
2630 extern "C" fn PhantomKeysManager_NodeSigner_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes {
2631         let mut ret = <nativePhantomKeysManager as lightning::sign::NodeSigner<>>::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, );
2632         crate::c_types::ThirtyTwoBytes { data: ret.0 }
2633 }
2634 #[must_use]
2635 extern "C" fn PhantomKeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ {
2636         let mut ret = <nativePhantomKeysManager as lightning::sign::NodeSigner<>>::get_node_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native());
2637         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2638         local_ret
2639 }
2640 #[must_use]
2641 extern "C" fn PhantomKeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_BigEndianScalarZ) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ {
2642         let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref();
2643         let mut ret = <nativePhantomKeysManager as lightning::sign::NodeSigner<>>::ecdh(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak);
2644         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2645         local_ret
2646 }
2647 #[must_use]
2648 extern "C" fn PhantomKeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_U5Z, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ {
2649         let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); };
2650         let mut ret = <nativePhantomKeysManager as lightning::sign::NodeSigner<>>::sign_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native());
2651         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2652         local_ret
2653 }
2654 #[must_use]
2655 extern "C" fn PhantomKeysManager_NodeSigner_sign_bolt12_invoice_request(this_arg: *const c_void, invoice_request: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ {
2656         let mut ret = <nativePhantomKeysManager as lightning::sign::NodeSigner<>>::sign_bolt12_invoice_request(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, invoice_request.get_native_ref());
2657         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SchnorrSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2658         local_ret
2659 }
2660 #[must_use]
2661 extern "C" fn PhantomKeysManager_NodeSigner_sign_bolt12_invoice(this_arg: *const c_void, invoice: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ {
2662         let mut ret = <nativePhantomKeysManager as lightning::sign::NodeSigner<>>::sign_bolt12_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, invoice.get_native_ref());
2663         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SchnorrSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2664         local_ret
2665 }
2666 #[must_use]
2667 extern "C" fn PhantomKeysManager_NodeSigner_sign_gossip_message(this_arg: *const c_void, mut msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ {
2668         let mut ret = <nativePhantomKeysManager as lightning::sign::NodeSigner<>>::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, msg.into_native());
2669         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2670         local_ret
2671 }
2672
2673 impl From<nativePhantomKeysManager> for crate::lightning::sign::SignerProvider {
2674         fn from(obj: nativePhantomKeysManager) -> Self {
2675                 let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2676                 let mut ret = PhantomKeysManager_as_SignerProvider(&rust_obj);
2677                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2678                 rust_obj.inner = core::ptr::null_mut();
2679                 ret.free = Some(PhantomKeysManager_free_void);
2680                 ret
2681         }
2682 }
2683 /// Constructs a new SignerProvider which calls the relevant methods on this_arg.
2684 /// This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is
2685 #[no_mangle]
2686 pub extern "C" fn PhantomKeysManager_as_SignerProvider(this_arg: &PhantomKeysManager) -> crate::lightning::sign::SignerProvider {
2687         crate::lightning::sign::SignerProvider {
2688                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2689                 free: None,
2690                 generate_channel_keys_id: PhantomKeysManager_SignerProvider_generate_channel_keys_id,
2691                 derive_channel_signer: PhantomKeysManager_SignerProvider_derive_channel_signer,
2692                 read_chan_signer: PhantomKeysManager_SignerProvider_read_chan_signer,
2693                 get_destination_script: PhantomKeysManager_SignerProvider_get_destination_script,
2694                 get_shutdown_scriptpubkey: PhantomKeysManager_SignerProvider_get_shutdown_scriptpubkey,
2695         }
2696 }
2697
2698 #[must_use]
2699 extern "C" fn PhantomKeysManager_SignerProvider_generate_channel_keys_id(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes {
2700         let mut ret = <nativePhantomKeysManager as lightning::sign::SignerProvider<>>::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into());
2701         crate::c_types::ThirtyTwoBytes { data: ret }
2702 }
2703 #[must_use]
2704 extern "C" fn PhantomKeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::WriteableEcdsaChannelSigner {
2705         let mut ret = <nativePhantomKeysManager as lightning::sign::SignerProvider<>>::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, channel_value_satoshis, channel_keys_id.data);
2706         Into::into(ret)
2707 }
2708 #[must_use]
2709 extern "C" fn PhantomKeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ {
2710         let mut ret = <nativePhantomKeysManager as lightning::sign::SignerProvider<>>::read_chan_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, reader.to_slice());
2711         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { Into::into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
2712         local_ret
2713 }
2714 #[must_use]
2715 extern "C" fn PhantomKeysManager_SignerProvider_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CResult_CVec_u8ZNoneZ {
2716         let mut ret = <nativePhantomKeysManager as lightning::sign::SignerProvider<>>::get_destination_script(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, );
2717         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into_bytes().into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2718         local_ret
2719 }
2720 #[must_use]
2721 extern "C" fn PhantomKeysManager_SignerProvider_get_shutdown_scriptpubkey(this_arg: *const c_void) -> crate::c_types::derived::CResult_ShutdownScriptNoneZ {
2722         let mut ret = <nativePhantomKeysManager as lightning::sign::SignerProvider<>>::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, );
2723         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2724         local_ret
2725 }
2726
2727 /// Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed`
2728 /// that is shared across all nodes that intend to participate in [phantom node payments]
2729 /// together.
2730 ///
2731 /// See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and
2732 /// `starting_time_nanos`.
2733 ///
2734 /// `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the
2735 /// same across restarts, or else inbound payments may fail.
2736 ///
2737 /// [phantom node payments]: PhantomKeysManager
2738 #[must_use]
2739 #[no_mangle]
2740 pub extern "C" fn PhantomKeysManager_new(seed: *const [u8; 32], mut starting_time_secs: u64, mut starting_time_nanos: u32, cross_node_seed: *const [u8; 32]) -> crate::lightning::sign::PhantomKeysManager {
2741         let mut ret = lightning::sign::PhantomKeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos, unsafe { &*cross_node_seed});
2742         crate::lightning::sign::PhantomKeysManager { inner: ObjOps::heap_alloc(ret), is_owned: true }
2743 }
2744
2745 /// See [`KeysManager::spend_spendable_outputs`] for documentation on this method.
2746 #[must_use]
2747 #[no_mangle]
2748 pub extern "C" fn PhantomKeysManager_spend_spendable_outputs(this_arg: &crate::lightning::sign::PhantomKeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_u32Z) -> crate::c_types::derived::CResult_TransactionNoneZ {
2749         let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); };
2750         let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); };
2751         let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::PackedLockTime({ locktime_opt.take() }) }})} };
2752         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.spend_spendable_outputs(&local_descriptors.iter().collect::<Vec<_>>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime, secp256k1::global::SECP256K1);
2753         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2754         local_ret
2755 }
2756
2757 /// See [`KeysManager::derive_channel_keys`] for documentation on this method.
2758 #[must_use]
2759 #[no_mangle]
2760 pub extern "C" fn PhantomKeysManager_derive_channel_keys(this_arg: &crate::lightning::sign::PhantomKeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::lightning::sign::InMemorySigner {
2761         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_keys(channel_value_satoshis, unsafe { &*params});
2762         crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true }
2763 }
2764
2765 /// Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc.
2766 #[must_use]
2767 #[no_mangle]
2768 pub extern "C" fn PhantomKeysManager_get_node_secret_key(this_arg: &crate::lightning::sign::PhantomKeysManager) -> crate::c_types::SecretKey {
2769         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_node_secret_key();
2770         crate::c_types::SecretKey::from_rust(ret)
2771 }
2772
2773 /// Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the
2774 /// last-hop onion data, etc.
2775 #[must_use]
2776 #[no_mangle]
2777 pub extern "C" fn PhantomKeysManager_get_phantom_node_secret_key(this_arg: &crate::lightning::sign::PhantomKeysManager) -> crate::c_types::SecretKey {
2778         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_node_secret_key();
2779         crate::c_types::SecretKey::from_rust(ret)
2780 }
2781