Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / events / bump_transaction.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 //! Utilities for bumping transactions originating from [`Event`]s.
10 //!
11 //! [`Event`]: crate::events::Event
12
13 use alloc::str::FromStr;
14 use alloc::string::String;
15 use core::ffi::c_void;
16 use core::convert::Infallible;
17 use bitcoin::hashes::Hash;
18 use crate::c_types::*;
19 #[cfg(feature="no-std")]
20 use alloc::{vec::Vec, boxed::Box};
21
22
23 use lightning::events::bump_transaction::ChannelDerivationParameters as nativeChannelDerivationParametersImport;
24 pub(crate) type nativeChannelDerivationParameters = nativeChannelDerivationParametersImport;
25
26 /// The parameters required to derive a channel signer via [`SignerProvider`].
27 #[must_use]
28 #[repr(C)]
29 pub struct ChannelDerivationParameters {
30         /// A pointer to the opaque Rust object.
31
32         /// Nearly everywhere, inner must be non-null, however in places where
33         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
34         pub inner: *mut nativeChannelDerivationParameters,
35         /// Indicates that this is the only struct which contains the same pointer.
36
37         /// Rust functions which take ownership of an object provided via an argument require
38         /// this to be true and invalidate the object pointed to by inner.
39         pub is_owned: bool,
40 }
41
42 impl Drop for ChannelDerivationParameters {
43         fn drop(&mut self) {
44                 if self.is_owned && !<*mut nativeChannelDerivationParameters>::is_null(self.inner) {
45                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
46                 }
47         }
48 }
49 /// Frees any resources used by the ChannelDerivationParameters, if is_owned is set and inner is non-NULL.
50 #[no_mangle]
51 pub extern "C" fn ChannelDerivationParameters_free(this_obj: ChannelDerivationParameters) { }
52 #[allow(unused)]
53 /// Used only if an object of this type is returned as a trait impl by a method
54 pub(crate) extern "C" fn ChannelDerivationParameters_free_void(this_ptr: *mut c_void) {
55         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelDerivationParameters) };
56 }
57 #[allow(unused)]
58 impl ChannelDerivationParameters {
59         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDerivationParameters {
60                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
61         }
62         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDerivationParameters {
63                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
64         }
65         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
66         pub(crate) fn take_inner(mut self) -> *mut nativeChannelDerivationParameters {
67                 assert!(self.is_owned);
68                 let ret = ObjOps::untweak_ptr(self.inner);
69                 self.inner = core::ptr::null_mut();
70                 ret
71         }
72 }
73 /// The value in satoshis of the channel we're attempting to spend the anchor output of.
74 #[no_mangle]
75 pub extern "C" fn ChannelDerivationParameters_get_value_satoshis(this_ptr: &ChannelDerivationParameters) -> u64 {
76         let mut inner_val = &mut this_ptr.get_native_mut_ref().value_satoshis;
77         *inner_val
78 }
79 /// The value in satoshis of the channel we're attempting to spend the anchor output of.
80 #[no_mangle]
81 pub extern "C" fn ChannelDerivationParameters_set_value_satoshis(this_ptr: &mut ChannelDerivationParameters, mut val: u64) {
82         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.value_satoshis = val;
83 }
84 /// The unique identifier to re-derive the signer for the associated channel.
85 #[no_mangle]
86 pub extern "C" fn ChannelDerivationParameters_get_keys_id(this_ptr: &ChannelDerivationParameters) -> *const [u8; 32] {
87         let mut inner_val = &mut this_ptr.get_native_mut_ref().keys_id;
88         inner_val
89 }
90 /// The unique identifier to re-derive the signer for the associated channel.
91 #[no_mangle]
92 pub extern "C" fn ChannelDerivationParameters_set_keys_id(this_ptr: &mut ChannelDerivationParameters, mut val: crate::c_types::ThirtyTwoBytes) {
93         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys_id = val.data;
94 }
95 /// The necessary channel parameters that need to be provided to the re-derived signer through
96 /// [`ChannelSigner::provide_channel_parameters`].
97 ///
98 /// [`ChannelSigner::provide_channel_parameters`]: crate::sign::ChannelSigner::provide_channel_parameters
99 #[no_mangle]
100 pub extern "C" fn ChannelDerivationParameters_get_transaction_parameters(this_ptr: &ChannelDerivationParameters) -> crate::lightning::ln::chan_utils::ChannelTransactionParameters {
101         let mut inner_val = &mut this_ptr.get_native_mut_ref().transaction_parameters;
102         crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }
103 }
104 /// The necessary channel parameters that need to be provided to the re-derived signer through
105 /// [`ChannelSigner::provide_channel_parameters`].
106 ///
107 /// [`ChannelSigner::provide_channel_parameters`]: crate::sign::ChannelSigner::provide_channel_parameters
108 #[no_mangle]
109 pub extern "C" fn ChannelDerivationParameters_set_transaction_parameters(this_ptr: &mut ChannelDerivationParameters, mut val: crate::lightning::ln::chan_utils::ChannelTransactionParameters) {
110         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.transaction_parameters = *unsafe { Box::from_raw(val.take_inner()) };
111 }
112 /// Constructs a new ChannelDerivationParameters given each field
113 #[must_use]
114 #[no_mangle]
115 pub extern "C" fn ChannelDerivationParameters_new(mut value_satoshis_arg: u64, mut keys_id_arg: crate::c_types::ThirtyTwoBytes, mut transaction_parameters_arg: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> ChannelDerivationParameters {
116         ChannelDerivationParameters { inner: ObjOps::heap_alloc(nativeChannelDerivationParameters {
117                 value_satoshis: value_satoshis_arg,
118                 keys_id: keys_id_arg.data,
119                 transaction_parameters: *unsafe { Box::from_raw(transaction_parameters_arg.take_inner()) },
120         }), is_owned: true }
121 }
122 impl Clone for ChannelDerivationParameters {
123         fn clone(&self) -> Self {
124                 Self {
125                         inner: if <*mut nativeChannelDerivationParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
126                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
127                         is_owned: true,
128                 }
129         }
130 }
131 #[allow(unused)]
132 /// Used only if an object of this type is returned as a trait impl by a method
133 pub(crate) extern "C" fn ChannelDerivationParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
134         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelDerivationParameters)).clone() })) as *mut c_void
135 }
136 #[no_mangle]
137 /// Creates a copy of the ChannelDerivationParameters
138 pub extern "C" fn ChannelDerivationParameters_clone(orig: &ChannelDerivationParameters) -> ChannelDerivationParameters {
139         orig.clone()
140 }
141 /// Checks if two ChannelDerivationParameterss contain equal inner contents.
142 /// This ignores pointers and is_owned flags and looks at the values in fields.
143 /// Two objects with NULL inner values will be considered "equal" here.
144 #[no_mangle]
145 pub extern "C" fn ChannelDerivationParameters_eq(a: &ChannelDerivationParameters, b: &ChannelDerivationParameters) -> bool {
146         if a.inner == b.inner { return true; }
147         if a.inner.is_null() || b.inner.is_null() { return false; }
148         if a.get_native_ref() == b.get_native_ref() { true } else { false }
149 }
150 #[no_mangle]
151 /// Serialize the ChannelDerivationParameters object into a byte array which can be read by ChannelDerivationParameters_read
152 pub extern "C" fn ChannelDerivationParameters_write(obj: &crate::lightning::events::bump_transaction::ChannelDerivationParameters) -> crate::c_types::derived::CVec_u8Z {
153         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
154 }
155 #[no_mangle]
156 pub(crate) extern "C" fn ChannelDerivationParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
157         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDerivationParameters) })
158 }
159 #[no_mangle]
160 /// Read a ChannelDerivationParameters from a byte array, created by ChannelDerivationParameters_write
161 pub extern "C" fn ChannelDerivationParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelDerivationParametersDecodeErrorZ {
162         let res: Result<lightning::events::bump_transaction::ChannelDerivationParameters, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
163         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::bump_transaction::ChannelDerivationParameters { 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() };
164         local_res
165 }
166
167 use lightning::events::bump_transaction::AnchorDescriptor as nativeAnchorDescriptorImport;
168 pub(crate) type nativeAnchorDescriptor = nativeAnchorDescriptorImport;
169
170 /// A descriptor used to sign for a commitment transaction's anchor output.
171 #[must_use]
172 #[repr(C)]
173 pub struct AnchorDescriptor {
174         /// A pointer to the opaque Rust object.
175
176         /// Nearly everywhere, inner must be non-null, however in places where
177         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
178         pub inner: *mut nativeAnchorDescriptor,
179         /// Indicates that this is the only struct which contains the same pointer.
180
181         /// Rust functions which take ownership of an object provided via an argument require
182         /// this to be true and invalidate the object pointed to by inner.
183         pub is_owned: bool,
184 }
185
186 impl Drop for AnchorDescriptor {
187         fn drop(&mut self) {
188                 if self.is_owned && !<*mut nativeAnchorDescriptor>::is_null(self.inner) {
189                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
190                 }
191         }
192 }
193 /// Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL.
194 #[no_mangle]
195 pub extern "C" fn AnchorDescriptor_free(this_obj: AnchorDescriptor) { }
196 #[allow(unused)]
197 /// Used only if an object of this type is returned as a trait impl by a method
198 pub(crate) extern "C" fn AnchorDescriptor_free_void(this_ptr: *mut c_void) {
199         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnchorDescriptor) };
200 }
201 #[allow(unused)]
202 impl AnchorDescriptor {
203         pub(crate) fn get_native_ref(&self) -> &'static nativeAnchorDescriptor {
204                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
205         }
206         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnchorDescriptor {
207                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
208         }
209         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
210         pub(crate) fn take_inner(mut self) -> *mut nativeAnchorDescriptor {
211                 assert!(self.is_owned);
212                 let ret = ObjOps::untweak_ptr(self.inner);
213                 self.inner = core::ptr::null_mut();
214                 ret
215         }
216 }
217 /// The parameters required to derive the signer for the anchor input.
218 #[no_mangle]
219 pub extern "C" fn AnchorDescriptor_get_channel_derivation_parameters(this_ptr: &AnchorDescriptor) -> crate::lightning::events::bump_transaction::ChannelDerivationParameters {
220         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_derivation_parameters;
221         crate::lightning::events::bump_transaction::ChannelDerivationParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::events::bump_transaction::ChannelDerivationParameters<>) as *mut _) }, is_owned: false }
222 }
223 /// The parameters required to derive the signer for the anchor input.
224 #[no_mangle]
225 pub extern "C" fn AnchorDescriptor_set_channel_derivation_parameters(this_ptr: &mut AnchorDescriptor, mut val: crate::lightning::events::bump_transaction::ChannelDerivationParameters) {
226         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_derivation_parameters = *unsafe { Box::from_raw(val.take_inner()) };
227 }
228 /// The transaction input's outpoint corresponding to the commitment transaction's anchor
229 /// output.
230 #[no_mangle]
231 pub extern "C" fn AnchorDescriptor_get_outpoint(this_ptr: &AnchorDescriptor) -> crate::lightning::chain::transaction::OutPoint {
232         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
233         crate::c_types::bitcoin_to_C_outpoint(inner_val)
234 }
235 /// The transaction input's outpoint corresponding to the commitment transaction's anchor
236 /// output.
237 #[no_mangle]
238 pub extern "C" fn AnchorDescriptor_set_outpoint(this_ptr: &mut AnchorDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) {
239         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val);
240 }
241 /// Constructs a new AnchorDescriptor given each field
242 #[must_use]
243 #[no_mangle]
244 pub extern "C" fn AnchorDescriptor_new(mut channel_derivation_parameters_arg: crate::lightning::events::bump_transaction::ChannelDerivationParameters, mut outpoint_arg: crate::lightning::chain::transaction::OutPoint) -> AnchorDescriptor {
245         AnchorDescriptor { inner: ObjOps::heap_alloc(nativeAnchorDescriptor {
246                 channel_derivation_parameters: *unsafe { Box::from_raw(channel_derivation_parameters_arg.take_inner()) },
247                 outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg),
248         }), is_owned: true }
249 }
250 impl Clone for AnchorDescriptor {
251         fn clone(&self) -> Self {
252                 Self {
253                         inner: if <*mut nativeAnchorDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else {
254                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
255                         is_owned: true,
256                 }
257         }
258 }
259 #[allow(unused)]
260 /// Used only if an object of this type is returned as a trait impl by a method
261 pub(crate) extern "C" fn AnchorDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
262         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnchorDescriptor)).clone() })) as *mut c_void
263 }
264 #[no_mangle]
265 /// Creates a copy of the AnchorDescriptor
266 pub extern "C" fn AnchorDescriptor_clone(orig: &AnchorDescriptor) -> AnchorDescriptor {
267         orig.clone()
268 }
269 /// Checks if two AnchorDescriptors contain equal inner contents.
270 /// This ignores pointers and is_owned flags and looks at the values in fields.
271 /// Two objects with NULL inner values will be considered "equal" here.
272 #[no_mangle]
273 pub extern "C" fn AnchorDescriptor_eq(a: &AnchorDescriptor, b: &AnchorDescriptor) -> bool {
274         if a.inner == b.inner { return true; }
275         if a.inner.is_null() || b.inner.is_null() { return false; }
276         if a.get_native_ref() == b.get_native_ref() { true } else { false }
277 }
278 /// Returns the UTXO to be spent by the anchor input, which can be obtained via
279 /// [`Self::unsigned_tx_input`].
280 #[must_use]
281 #[no_mangle]
282 pub extern "C" fn AnchorDescriptor_previous_utxo(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::TxOut {
283         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.previous_utxo();
284         crate::c_types::TxOut::from_rust(&ret)
285 }
286
287 /// Returns the unsigned transaction input spending the anchor output in the commitment
288 /// transaction.
289 #[must_use]
290 #[no_mangle]
291 pub extern "C" fn AnchorDescriptor_unsigned_tx_input(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::TxIn {
292         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.unsigned_tx_input();
293         crate::c_types::TxIn::from_rust(&ret)
294 }
295
296 /// Returns the witness script of the anchor output in the commitment transaction.
297 #[must_use]
298 #[no_mangle]
299 pub extern "C" fn AnchorDescriptor_witness_script(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::derived::CVec_u8Z {
300         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.witness_script();
301         ret.into_bytes().into()
302 }
303
304 /// Returns the fully signed witness required to spend the anchor output in the commitment
305 /// transaction.
306 #[must_use]
307 #[no_mangle]
308 pub extern "C" fn AnchorDescriptor_tx_input_witness(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor, mut signature: crate::c_types::ECDSASignature) -> crate::c_types::Witness {
309         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust());
310         crate::c_types::Witness::from_bitcoin(&ret)
311 }
312
313 /// Derives the channel signer required to sign the anchor input.
314 #[must_use]
315 #[no_mangle]
316 pub extern "C" fn AnchorDescriptor_derive_channel_signer(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::WriteableEcdsaChannelSigner {
317         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider);
318         Into::into(ret)
319 }
320
321
322 use lightning::events::bump_transaction::HTLCDescriptor as nativeHTLCDescriptorImport;
323 pub(crate) type nativeHTLCDescriptor = nativeHTLCDescriptorImport;
324
325 /// A descriptor used to sign for a commitment transaction's HTLC output.
326 #[must_use]
327 #[repr(C)]
328 pub struct HTLCDescriptor {
329         /// A pointer to the opaque Rust object.
330
331         /// Nearly everywhere, inner must be non-null, however in places where
332         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
333         pub inner: *mut nativeHTLCDescriptor,
334         /// Indicates that this is the only struct which contains the same pointer.
335
336         /// Rust functions which take ownership of an object provided via an argument require
337         /// this to be true and invalidate the object pointed to by inner.
338         pub is_owned: bool,
339 }
340
341 impl Drop for HTLCDescriptor {
342         fn drop(&mut self) {
343                 if self.is_owned && !<*mut nativeHTLCDescriptor>::is_null(self.inner) {
344                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
345                 }
346         }
347 }
348 /// Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL.
349 #[no_mangle]
350 pub extern "C" fn HTLCDescriptor_free(this_obj: HTLCDescriptor) { }
351 #[allow(unused)]
352 /// Used only if an object of this type is returned as a trait impl by a method
353 pub(crate) extern "C" fn HTLCDescriptor_free_void(this_ptr: *mut c_void) {
354         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeHTLCDescriptor) };
355 }
356 #[allow(unused)]
357 impl HTLCDescriptor {
358         pub(crate) fn get_native_ref(&self) -> &'static nativeHTLCDescriptor {
359                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
360         }
361         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeHTLCDescriptor {
362                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
363         }
364         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
365         pub(crate) fn take_inner(mut self) -> *mut nativeHTLCDescriptor {
366                 assert!(self.is_owned);
367                 let ret = ObjOps::untweak_ptr(self.inner);
368                 self.inner = core::ptr::null_mut();
369                 ret
370         }
371 }
372 /// The parameters required to derive the signer for the HTLC input.
373 #[no_mangle]
374 pub extern "C" fn HTLCDescriptor_get_channel_derivation_parameters(this_ptr: &HTLCDescriptor) -> crate::lightning::events::bump_transaction::ChannelDerivationParameters {
375         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_derivation_parameters;
376         crate::lightning::events::bump_transaction::ChannelDerivationParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::events::bump_transaction::ChannelDerivationParameters<>) as *mut _) }, is_owned: false }
377 }
378 /// The parameters required to derive the signer for the HTLC input.
379 #[no_mangle]
380 pub extern "C" fn HTLCDescriptor_set_channel_derivation_parameters(this_ptr: &mut HTLCDescriptor, mut val: crate::lightning::events::bump_transaction::ChannelDerivationParameters) {
381         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_derivation_parameters = *unsafe { Box::from_raw(val.take_inner()) };
382 }
383 /// The number of the commitment transaction in which the HTLC output lives.
384 #[no_mangle]
385 pub extern "C" fn HTLCDescriptor_get_per_commitment_number(this_ptr: &HTLCDescriptor) -> u64 {
386         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_number;
387         *inner_val
388 }
389 /// The number of the commitment transaction in which the HTLC output lives.
390 #[no_mangle]
391 pub extern "C" fn HTLCDescriptor_set_per_commitment_number(this_ptr: &mut HTLCDescriptor, mut val: u64) {
392         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_number = val;
393 }
394 /// The key tweak corresponding to the number of the commitment transaction in which the HTLC
395 /// output lives. This tweak is applied to all the basepoints for both parties in the channel to
396 /// arrive at unique keys per commitment.
397 ///
398 /// See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
399 #[no_mangle]
400 pub extern "C" fn HTLCDescriptor_get_per_commitment_point(this_ptr: &HTLCDescriptor) -> crate::c_types::PublicKey {
401         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_point;
402         crate::c_types::PublicKey::from_rust(&inner_val)
403 }
404 /// The key tweak corresponding to the number of the commitment transaction in which the HTLC
405 /// output lives. This tweak is applied to all the basepoints for both parties in the channel to
406 /// arrive at unique keys per commitment.
407 ///
408 /// See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
409 #[no_mangle]
410 pub extern "C" fn HTLCDescriptor_set_per_commitment_point(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::PublicKey) {
411         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_point = val.into_rust();
412 }
413 /// The details of the HTLC as it appears in the commitment transaction.
414 #[no_mangle]
415 pub extern "C" fn HTLCDescriptor_get_htlc(this_ptr: &HTLCDescriptor) -> crate::lightning::ln::chan_utils::HTLCOutputInCommitment {
416         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc;
417         crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }
418 }
419 /// The details of the HTLC as it appears in the commitment transaction.
420 #[no_mangle]
421 pub extern "C" fn HTLCDescriptor_set_htlc(this_ptr: &mut HTLCDescriptor, mut val: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) {
422         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc = *unsafe { Box::from_raw(val.take_inner()) };
423 }
424 /// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
425 /// taken.
426 #[no_mangle]
427 pub extern "C" fn HTLCDescriptor_get_preimage(this_ptr: &HTLCDescriptor) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
428         let mut inner_val = &mut this_ptr.get_native_mut_ref().preimage;
429         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().0 } }) };
430         local_inner_val
431 }
432 /// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
433 /// taken.
434 #[no_mangle]
435 pub extern "C" fn HTLCDescriptor_set_preimage(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
436         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ val_opt.take() }.data) }})} };
437         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.preimage = local_val;
438 }
439 /// The counterparty's signature required to spend the HTLC output.
440 #[no_mangle]
441 pub extern "C" fn HTLCDescriptor_get_counterparty_sig(this_ptr: &HTLCDescriptor) -> crate::c_types::ECDSASignature {
442         let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty_sig;
443         crate::c_types::ECDSASignature::from_rust(&inner_val)
444 }
445 /// The counterparty's signature required to spend the HTLC output.
446 #[no_mangle]
447 pub extern "C" fn HTLCDescriptor_set_counterparty_sig(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::ECDSASignature) {
448         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty_sig = val.into_rust();
449 }
450 impl Clone for HTLCDescriptor {
451         fn clone(&self) -> Self {
452                 Self {
453                         inner: if <*mut nativeHTLCDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else {
454                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
455                         is_owned: true,
456                 }
457         }
458 }
459 #[allow(unused)]
460 /// Used only if an object of this type is returned as a trait impl by a method
461 pub(crate) extern "C" fn HTLCDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
462         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCDescriptor)).clone() })) as *mut c_void
463 }
464 #[no_mangle]
465 /// Creates a copy of the HTLCDescriptor
466 pub extern "C" fn HTLCDescriptor_clone(orig: &HTLCDescriptor) -> HTLCDescriptor {
467         orig.clone()
468 }
469 /// Checks if two HTLCDescriptors contain equal inner contents.
470 /// This ignores pointers and is_owned flags and looks at the values in fields.
471 /// Two objects with NULL inner values will be considered "equal" here.
472 #[no_mangle]
473 pub extern "C" fn HTLCDescriptor_eq(a: &HTLCDescriptor, b: &HTLCDescriptor) -> bool {
474         if a.inner == b.inner { return true; }
475         if a.inner.is_null() || b.inner.is_null() { return false; }
476         if a.get_native_ref() == b.get_native_ref() { true } else { false }
477 }
478 #[no_mangle]
479 /// Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read
480 pub extern "C" fn HTLCDescriptor_write(obj: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::derived::CVec_u8Z {
481         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
482 }
483 #[no_mangle]
484 pub(crate) extern "C" fn HTLCDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
485         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCDescriptor) })
486 }
487 #[no_mangle]
488 /// Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write
489 pub extern "C" fn HTLCDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HTLCDescriptorDecodeErrorZ {
490         let res: Result<lightning::events::bump_transaction::HTLCDescriptor, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
491         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::bump_transaction::HTLCDescriptor { 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() };
492         local_res
493 }
494 /// Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint
495 /// being spent by the HTLC input in the HTLC transaction.
496 #[must_use]
497 #[no_mangle]
498 pub extern "C" fn HTLCDescriptor_outpoint(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::lightning::chain::transaction::OutPoint {
499         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.outpoint();
500         crate::c_types::bitcoin_to_C_outpoint(&ret)
501 }
502
503 /// Returns the UTXO to be spent by the HTLC input, which can be obtained via
504 /// [`Self::unsigned_tx_input`].
505 #[must_use]
506 #[no_mangle]
507 pub extern "C" fn HTLCDescriptor_previous_utxo(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxOut {
508         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.previous_utxo(secp256k1::global::SECP256K1);
509         crate::c_types::TxOut::from_rust(&ret)
510 }
511
512 /// Returns the unsigned transaction input spending the HTLC output in the commitment
513 /// transaction.
514 #[must_use]
515 #[no_mangle]
516 pub extern "C" fn HTLCDescriptor_unsigned_tx_input(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxIn {
517         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.unsigned_tx_input();
518         crate::c_types::TxIn::from_rust(&ret)
519 }
520
521 /// Returns the delayed output created as a result of spending the HTLC output in the commitment
522 /// transaction.
523 #[must_use]
524 #[no_mangle]
525 pub extern "C" fn HTLCDescriptor_tx_output(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxOut {
526         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_output(secp256k1::global::SECP256K1);
527         crate::c_types::TxOut::from_rust(&ret)
528 }
529
530 /// Returns the witness script of the HTLC output in the commitment transaction.
531 #[must_use]
532 #[no_mangle]
533 pub extern "C" fn HTLCDescriptor_witness_script(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::derived::CVec_u8Z {
534         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.witness_script(secp256k1::global::SECP256K1);
535         ret.into_bytes().into()
536 }
537
538 /// Returns the fully signed witness required to spend the HTLC output in the commitment
539 /// transaction.
540 #[must_use]
541 #[no_mangle]
542 pub extern "C" fn HTLCDescriptor_tx_input_witness(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor, mut signature: crate::c_types::ECDSASignature, mut witness_script: crate::c_types::u8slice) -> crate::c_types::Witness {
543         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust(), &::bitcoin::blockdata::script::Script::from(Vec::from(witness_script.to_slice())));
544         crate::c_types::Witness::from_bitcoin(&ret)
545 }
546
547 /// Derives the channel signer required to sign the HTLC input.
548 #[must_use]
549 #[no_mangle]
550 pub extern "C" fn HTLCDescriptor_derive_channel_signer(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::WriteableEcdsaChannelSigner {
551         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider);
552         Into::into(ret)
553 }
554
555 /// Represents the different types of transactions, originating from LDK, to be bumped.
556 #[derive(Clone)]
557 #[must_use]
558 #[repr(C)]
559 pub enum BumpTransactionEvent {
560         /// Indicates that a channel featuring anchor outputs is to be closed by broadcasting the local
561         /// commitment transaction. Since commitment transactions have a static feerate pre-agreed upon,
562         /// they may need additional fees to be attached through a child transaction using the popular
563         /// [Child-Pays-For-Parent](https://bitcoinops.org/en/topics/cpfp) fee bumping technique. This
564         /// child transaction must include the anchor input described within `anchor_descriptor` along
565         /// with additional inputs to meet the target feerate. Failure to meet the target feerate
566         /// decreases the confirmation odds of the transaction package (which includes the commitment
567         /// and child anchor transactions), possibly resulting in a loss of funds. Once the transaction
568         /// is constructed, it must be fully signed for and broadcast by the consumer of the event
569         /// along with the `commitment_tx` enclosed. Note that the `commitment_tx` must always be
570         /// broadcast first, as the child anchor transaction depends on it.
571         ///
572         /// The consumer should be able to sign for any of the additional inputs included within the
573         /// child anchor transaction. To sign its anchor input, an [`EcdsaChannelSigner`] should be
574         /// re-derived through [`AnchorDescriptor::derive_channel_signer`]. The anchor input signature
575         /// can be computed with [`EcdsaChannelSigner::sign_holder_anchor_input`], which can then be
576         /// provided to [`build_anchor_input_witness`] along with the `funding_pubkey` to obtain the
577         /// full witness required to spend.
578         ///
579         /// It is possible to receive more than one instance of this event if a valid child anchor
580         /// transaction is never broadcast or is but not with a sufficient fee to be mined. Care should
581         /// be taken by the consumer of the event to ensure any future iterations of the child anchor
582         /// transaction adhere to the [Replace-By-Fee
583         /// rules](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md)
584         /// for fee bumps to be accepted into the mempool, and eventually the chain. As the frequency of
585         /// these events is not user-controlled, users may ignore/drop the event if they are no longer
586         /// able to commit external confirmed funds to the child anchor transaction.
587         ///
588         /// The set of `pending_htlcs` on the commitment transaction to be broadcast can be inspected to
589         /// determine whether a significant portion of the channel's funds are allocated to HTLCs,
590         /// enabling users to make their own decisions regarding the importance of the commitment
591         /// transaction's confirmation. Note that this is not required, but simply exists as an option
592         /// for users to override LDK's behavior. On commitments with no HTLCs (indicated by those with
593         /// an empty `pending_htlcs`), confirmation of the commitment transaction can be considered to
594         /// be not urgent.
595         ///
596         /// [`EcdsaChannelSigner`]: crate::sign::EcdsaChannelSigner
597         /// [`EcdsaChannelSigner::sign_holder_anchor_input`]: crate::sign::EcdsaChannelSigner::sign_holder_anchor_input
598         /// [`build_anchor_input_witness`]: crate::ln::chan_utils::build_anchor_input_witness
599         ChannelClose {
600                 /// The unique identifier for the claim of the anchor output in the commitment transaction.
601                 ///
602                 /// The identifier must map to the set of external UTXOs assigned to the claim, such that
603                 /// they can be reused when a new claim with the same identifier needs to be made, resulting
604                 /// in a fee-bumping attempt.
605                 claim_id: crate::c_types::ThirtyTwoBytes,
606                 /// The target feerate that the transaction package, which consists of the commitment
607                 /// transaction and the to-be-crafted child anchor transaction, must meet.
608                 package_target_feerate_sat_per_1000_weight: u32,
609                 /// The channel's commitment transaction to bump the fee of. This transaction should be
610                 /// broadcast along with the anchor transaction constructed as a result of consuming this
611                 /// event.
612                 commitment_tx: crate::c_types::Transaction,
613                 /// The absolute fee in satoshis of the commitment transaction. This can be used along the
614                 /// with weight of the commitment transaction to determine its feerate.
615                 commitment_tx_fee_satoshis: u64,
616                 /// The descriptor to sign the anchor input of the anchor transaction constructed as a
617                 /// result of consuming this event.
618                 anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor,
619                 /// The set of pending HTLCs on the commitment transaction that need to be resolved once the
620                 /// commitment transaction confirms.
621                 pending_htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ,
622         },
623         /// Indicates that a channel featuring anchor outputs has unilaterally closed on-chain by a
624         /// holder commitment transaction and its HTLC(s) need to be resolved on-chain. With the
625         /// zero-HTLC-transaction-fee variant of anchor outputs, the pre-signed HTLC
626         /// transactions have a zero fee, thus requiring additional inputs and/or outputs to be attached
627         /// for a timely confirmation within the chain. These additional inputs and/or outputs must be
628         /// appended to the resulting HTLC transaction to meet the target feerate. Failure to meet the
629         /// target feerate decreases the confirmation odds of the transaction, possibly resulting in a
630         /// loss of funds. Once the transaction meets the target feerate, it must be signed for and
631         /// broadcast by the consumer of the event.
632         ///
633         /// The consumer should be able to sign for any of the non-HTLC inputs added to the resulting
634         /// HTLC transaction. To sign HTLC inputs, an [`EcdsaChannelSigner`] should be re-derived
635         /// through [`HTLCDescriptor::derive_channel_signer`]. Each HTLC input's signature can be
636         /// computed with [`EcdsaChannelSigner::sign_holder_htlc_transaction`], which can then be
637         /// provided to [`HTLCDescriptor::tx_input_witness`] to obtain the fully signed witness required
638         /// to spend.
639         ///
640         /// It is possible to receive more than one instance of this event if a valid HTLC transaction
641         /// is never broadcast or is but not with a sufficient fee to be mined. Care should be taken by
642         /// the consumer of the event to ensure any future iterations of the HTLC transaction adhere to
643         /// the [Replace-By-Fee
644         /// rules](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md)
645         /// for fee bumps to be accepted into the mempool, and eventually the chain. As the frequency of
646         /// these events is not user-controlled, users may ignore/drop the event if either they are no
647         /// longer able to commit external confirmed funds to the HTLC transaction or the fee committed
648         /// to the HTLC transaction is greater in value than the HTLCs being claimed.
649         ///
650         /// [`EcdsaChannelSigner`]: crate::sign::EcdsaChannelSigner
651         /// [`EcdsaChannelSigner::sign_holder_htlc_transaction`]: crate::sign::EcdsaChannelSigner::sign_holder_htlc_transaction
652         /// [`HTLCDescriptor::tx_input_witness`]: HTLCDescriptor::tx_input_witness
653         HTLCResolution {
654                 /// The unique identifier for the claim of the HTLCs in the confirmed commitment
655                 /// transaction.
656                 ///
657                 /// The identifier must map to the set of external UTXOs assigned to the claim, such that
658                 /// they can be reused when a new claim with the same identifier needs to be made, resulting
659                 /// in a fee-bumping attempt.
660                 claim_id: crate::c_types::ThirtyTwoBytes,
661                 /// The target feerate that the resulting HTLC transaction must meet.
662                 target_feerate_sat_per_1000_weight: u32,
663                 /// The set of pending HTLCs on the confirmed commitment that need to be claimed, preferably
664                 /// by the same transaction.
665                 htlc_descriptors: crate::c_types::derived::CVec_HTLCDescriptorZ,
666                 /// The locktime required for the resulting HTLC transaction.
667                 tx_lock_time: u32,
668         },
669 }
670 use lightning::events::bump_transaction::BumpTransactionEvent as BumpTransactionEventImport;
671 pub(crate) type nativeBumpTransactionEvent = BumpTransactionEventImport;
672
673 impl BumpTransactionEvent {
674         #[allow(unused)]
675         pub(crate) fn to_native(&self) -> nativeBumpTransactionEvent {
676                 match self {
677                         BumpTransactionEvent::ChannelClose {ref claim_id, ref package_target_feerate_sat_per_1000_weight, ref commitment_tx, ref commitment_tx_fee_satoshis, ref anchor_descriptor, ref pending_htlcs, } => {
678                                 let mut claim_id_nonref = Clone::clone(claim_id);
679                                 let mut package_target_feerate_sat_per_1000_weight_nonref = Clone::clone(package_target_feerate_sat_per_1000_weight);
680                                 let mut commitment_tx_nonref = Clone::clone(commitment_tx);
681                                 let mut commitment_tx_fee_satoshis_nonref = Clone::clone(commitment_tx_fee_satoshis);
682                                 let mut anchor_descriptor_nonref = Clone::clone(anchor_descriptor);
683                                 let mut pending_htlcs_nonref = Clone::clone(pending_htlcs);
684                                 let mut local_pending_htlcs_nonref = Vec::new(); for mut item in pending_htlcs_nonref.into_rust().drain(..) { local_pending_htlcs_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
685                                 nativeBumpTransactionEvent::ChannelClose {
686                                         claim_id: ::lightning::chain::ClaimId(claim_id_nonref.data),
687                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight_nonref,
688                                         commitment_tx: commitment_tx_nonref.into_bitcoin(),
689                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis_nonref,
690                                         anchor_descriptor: *unsafe { Box::from_raw(anchor_descriptor_nonref.take_inner()) },
691                                         pending_htlcs: local_pending_htlcs_nonref,
692                                 }
693                         },
694                         BumpTransactionEvent::HTLCResolution {ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => {
695                                 let mut claim_id_nonref = Clone::clone(claim_id);
696                                 let mut target_feerate_sat_per_1000_weight_nonref = Clone::clone(target_feerate_sat_per_1000_weight);
697                                 let mut htlc_descriptors_nonref = Clone::clone(htlc_descriptors);
698                                 let mut local_htlc_descriptors_nonref = Vec::new(); for mut item in htlc_descriptors_nonref.into_rust().drain(..) { local_htlc_descriptors_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
699                                 let mut tx_lock_time_nonref = Clone::clone(tx_lock_time);
700                                 nativeBumpTransactionEvent::HTLCResolution {
701                                         claim_id: ::lightning::chain::ClaimId(claim_id_nonref.data),
702                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight_nonref,
703                                         htlc_descriptors: local_htlc_descriptors_nonref,
704                                         tx_lock_time: ::bitcoin::PackedLockTime(tx_lock_time_nonref),
705                                 }
706                         },
707                 }
708         }
709         #[allow(unused)]
710         pub(crate) fn into_native(self) -> nativeBumpTransactionEvent {
711                 match self {
712                         BumpTransactionEvent::ChannelClose {mut claim_id, mut package_target_feerate_sat_per_1000_weight, mut commitment_tx, mut commitment_tx_fee_satoshis, mut anchor_descriptor, mut pending_htlcs, } => {
713                                 let mut local_pending_htlcs = Vec::new(); for mut item in pending_htlcs.into_rust().drain(..) { local_pending_htlcs.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
714                                 nativeBumpTransactionEvent::ChannelClose {
715                                         claim_id: ::lightning::chain::ClaimId(claim_id.data),
716                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight,
717                                         commitment_tx: commitment_tx.into_bitcoin(),
718                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis,
719                                         anchor_descriptor: *unsafe { Box::from_raw(anchor_descriptor.take_inner()) },
720                                         pending_htlcs: local_pending_htlcs,
721                                 }
722                         },
723                         BumpTransactionEvent::HTLCResolution {mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => {
724                                 let mut local_htlc_descriptors = Vec::new(); for mut item in htlc_descriptors.into_rust().drain(..) { local_htlc_descriptors.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
725                                 nativeBumpTransactionEvent::HTLCResolution {
726                                         claim_id: ::lightning::chain::ClaimId(claim_id.data),
727                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight,
728                                         htlc_descriptors: local_htlc_descriptors,
729                                         tx_lock_time: ::bitcoin::PackedLockTime(tx_lock_time),
730                                 }
731                         },
732                 }
733         }
734         #[allow(unused)]
735         pub(crate) fn from_native(native: &nativeBumpTransactionEvent) -> Self {
736                 match native {
737                         nativeBumpTransactionEvent::ChannelClose {ref claim_id, ref package_target_feerate_sat_per_1000_weight, ref commitment_tx, ref commitment_tx_fee_satoshis, ref anchor_descriptor, ref pending_htlcs, } => {
738                                 let mut claim_id_nonref = Clone::clone(claim_id);
739                                 let mut package_target_feerate_sat_per_1000_weight_nonref = Clone::clone(package_target_feerate_sat_per_1000_weight);
740                                 let mut commitment_tx_nonref = Clone::clone(commitment_tx);
741                                 let mut commitment_tx_fee_satoshis_nonref = Clone::clone(commitment_tx_fee_satoshis);
742                                 let mut anchor_descriptor_nonref = Clone::clone(anchor_descriptor);
743                                 let mut pending_htlcs_nonref = Clone::clone(pending_htlcs);
744                                 let mut local_pending_htlcs_nonref = Vec::new(); for mut item in pending_htlcs_nonref.drain(..) { local_pending_htlcs_nonref.push( { crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
745                                 BumpTransactionEvent::ChannelClose {
746                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id_nonref.0 },
747                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight_nonref,
748                                         commitment_tx: crate::c_types::Transaction::from_bitcoin(&commitment_tx_nonref),
749                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis_nonref,
750                                         anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor { inner: ObjOps::heap_alloc(anchor_descriptor_nonref), is_owned: true },
751                                         pending_htlcs: local_pending_htlcs_nonref.into(),
752                                 }
753                         },
754                         nativeBumpTransactionEvent::HTLCResolution {ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => {
755                                 let mut claim_id_nonref = Clone::clone(claim_id);
756                                 let mut target_feerate_sat_per_1000_weight_nonref = Clone::clone(target_feerate_sat_per_1000_weight);
757                                 let mut htlc_descriptors_nonref = Clone::clone(htlc_descriptors);
758                                 let mut local_htlc_descriptors_nonref = Vec::new(); for mut item in htlc_descriptors_nonref.drain(..) { local_htlc_descriptors_nonref.push( { crate::lightning::events::bump_transaction::HTLCDescriptor { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
759                                 let mut tx_lock_time_nonref = Clone::clone(tx_lock_time);
760                                 BumpTransactionEvent::HTLCResolution {
761                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id_nonref.0 },
762                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight_nonref,
763                                         htlc_descriptors: local_htlc_descriptors_nonref.into(),
764                                         tx_lock_time: tx_lock_time_nonref.0,
765                                 }
766                         },
767                 }
768         }
769         #[allow(unused)]
770         pub(crate) fn native_into(native: nativeBumpTransactionEvent) -> Self {
771                 match native {
772                         nativeBumpTransactionEvent::ChannelClose {mut claim_id, mut package_target_feerate_sat_per_1000_weight, mut commitment_tx, mut commitment_tx_fee_satoshis, mut anchor_descriptor, mut pending_htlcs, } => {
773                                 let mut local_pending_htlcs = Vec::new(); for mut item in pending_htlcs.drain(..) { local_pending_htlcs.push( { crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
774                                 BumpTransactionEvent::ChannelClose {
775                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id.0 },
776                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight,
777                                         commitment_tx: crate::c_types::Transaction::from_bitcoin(&commitment_tx),
778                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis,
779                                         anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor { inner: ObjOps::heap_alloc(anchor_descriptor), is_owned: true },
780                                         pending_htlcs: local_pending_htlcs.into(),
781                                 }
782                         },
783                         nativeBumpTransactionEvent::HTLCResolution {mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => {
784                                 let mut local_htlc_descriptors = Vec::new(); for mut item in htlc_descriptors.drain(..) { local_htlc_descriptors.push( { crate::lightning::events::bump_transaction::HTLCDescriptor { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
785                                 BumpTransactionEvent::HTLCResolution {
786                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id.0 },
787                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight,
788                                         htlc_descriptors: local_htlc_descriptors.into(),
789                                         tx_lock_time: tx_lock_time.0,
790                                 }
791                         },
792                 }
793         }
794 }
795 /// Frees any resources used by the BumpTransactionEvent
796 #[no_mangle]
797 pub extern "C" fn BumpTransactionEvent_free(this_ptr: BumpTransactionEvent) { }
798 /// Creates a copy of the BumpTransactionEvent
799 #[no_mangle]
800 pub extern "C" fn BumpTransactionEvent_clone(orig: &BumpTransactionEvent) -> BumpTransactionEvent {
801         orig.clone()
802 }
803 #[no_mangle]
804 /// Utility method to constructs a new ChannelClose-variant BumpTransactionEvent
805 pub extern "C" fn BumpTransactionEvent_channel_close(claim_id: crate::c_types::ThirtyTwoBytes, package_target_feerate_sat_per_1000_weight: u32, commitment_tx: crate::c_types::Transaction, commitment_tx_fee_satoshis: u64, anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor, pending_htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> BumpTransactionEvent {
806         BumpTransactionEvent::ChannelClose {
807                 claim_id,
808                 package_target_feerate_sat_per_1000_weight,
809                 commitment_tx,
810                 commitment_tx_fee_satoshis,
811                 anchor_descriptor,
812                 pending_htlcs,
813         }
814 }
815 #[no_mangle]
816 /// Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent
817 pub extern "C" fn BumpTransactionEvent_htlcresolution(claim_id: crate::c_types::ThirtyTwoBytes, target_feerate_sat_per_1000_weight: u32, htlc_descriptors: crate::c_types::derived::CVec_HTLCDescriptorZ, tx_lock_time: u32) -> BumpTransactionEvent {
818         BumpTransactionEvent::HTLCResolution {
819                 claim_id,
820                 target_feerate_sat_per_1000_weight,
821                 htlc_descriptors,
822                 tx_lock_time,
823         }
824 }
825 /// Checks if two BumpTransactionEvents contain equal inner contents.
826 /// This ignores pointers and is_owned flags and looks at the values in fields.
827 #[no_mangle]
828 pub extern "C" fn BumpTransactionEvent_eq(a: &BumpTransactionEvent, b: &BumpTransactionEvent) -> bool {
829         if &a.to_native() == &b.to_native() { true } else { false }
830 }
831
832 use lightning::events::bump_transaction::Input as nativeInputImport;
833 pub(crate) type nativeInput = nativeInputImport;
834
835 /// An input that must be included in a transaction when performing coin selection through
836 /// [`CoinSelectionSource::select_confirmed_utxos`]. It is guaranteed to be a SegWit input, so it
837 /// must have an empty [`TxIn::script_sig`] when spent.
838 #[must_use]
839 #[repr(C)]
840 pub struct Input {
841         /// A pointer to the opaque Rust object.
842
843         /// Nearly everywhere, inner must be non-null, however in places where
844         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
845         pub inner: *mut nativeInput,
846         /// Indicates that this is the only struct which contains the same pointer.
847
848         /// Rust functions which take ownership of an object provided via an argument require
849         /// this to be true and invalidate the object pointed to by inner.
850         pub is_owned: bool,
851 }
852
853 impl Drop for Input {
854         fn drop(&mut self) {
855                 if self.is_owned && !<*mut nativeInput>::is_null(self.inner) {
856                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
857                 }
858         }
859 }
860 /// Frees any resources used by the Input, if is_owned is set and inner is non-NULL.
861 #[no_mangle]
862 pub extern "C" fn Input_free(this_obj: Input) { }
863 #[allow(unused)]
864 /// Used only if an object of this type is returned as a trait impl by a method
865 pub(crate) extern "C" fn Input_free_void(this_ptr: *mut c_void) {
866         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInput) };
867 }
868 #[allow(unused)]
869 impl Input {
870         pub(crate) fn get_native_ref(&self) -> &'static nativeInput {
871                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
872         }
873         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInput {
874                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
875         }
876         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
877         pub(crate) fn take_inner(mut self) -> *mut nativeInput {
878                 assert!(self.is_owned);
879                 let ret = ObjOps::untweak_ptr(self.inner);
880                 self.inner = core::ptr::null_mut();
881                 ret
882         }
883 }
884 /// The unique identifier of the input.
885 #[no_mangle]
886 pub extern "C" fn Input_get_outpoint(this_ptr: &Input) -> crate::lightning::chain::transaction::OutPoint {
887         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
888         crate::c_types::bitcoin_to_C_outpoint(inner_val)
889 }
890 /// The unique identifier of the input.
891 #[no_mangle]
892 pub extern "C" fn Input_set_outpoint(this_ptr: &mut Input, mut val: crate::lightning::chain::transaction::OutPoint) {
893         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val);
894 }
895 /// The UTXO being spent by the input.
896 #[no_mangle]
897 pub extern "C" fn Input_get_previous_utxo(this_ptr: &Input) -> crate::c_types::TxOut {
898         let mut inner_val = &mut this_ptr.get_native_mut_ref().previous_utxo;
899         crate::c_types::TxOut::from_rust(inner_val)
900 }
901 /// The UTXO being spent by the input.
902 #[no_mangle]
903 pub extern "C" fn Input_set_previous_utxo(this_ptr: &mut Input, mut val: crate::c_types::TxOut) {
904         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.previous_utxo = val.into_rust();
905 }
906 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
907 /// [`TxIn::witness`], each with their lengths included, required to satisfy the output's
908 /// script.
909 #[no_mangle]
910 pub extern "C" fn Input_get_satisfaction_weight(this_ptr: &Input) -> u64 {
911         let mut inner_val = &mut this_ptr.get_native_mut_ref().satisfaction_weight;
912         *inner_val
913 }
914 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
915 /// [`TxIn::witness`], each with their lengths included, required to satisfy the output's
916 /// script.
917 #[no_mangle]
918 pub extern "C" fn Input_set_satisfaction_weight(this_ptr: &mut Input, mut val: u64) {
919         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.satisfaction_weight = val;
920 }
921 /// Constructs a new Input given each field
922 #[must_use]
923 #[no_mangle]
924 pub extern "C" fn Input_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut previous_utxo_arg: crate::c_types::TxOut, mut satisfaction_weight_arg: u64) -> Input {
925         Input { inner: ObjOps::heap_alloc(nativeInput {
926                 outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg),
927                 previous_utxo: previous_utxo_arg.into_rust(),
928                 satisfaction_weight: satisfaction_weight_arg,
929         }), is_owned: true }
930 }
931 impl Clone for Input {
932         fn clone(&self) -> Self {
933                 Self {
934                         inner: if <*mut nativeInput>::is_null(self.inner) { core::ptr::null_mut() } else {
935                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
936                         is_owned: true,
937                 }
938         }
939 }
940 #[allow(unused)]
941 /// Used only if an object of this type is returned as a trait impl by a method
942 pub(crate) extern "C" fn Input_clone_void(this_ptr: *const c_void) -> *mut c_void {
943         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInput)).clone() })) as *mut c_void
944 }
945 #[no_mangle]
946 /// Creates a copy of the Input
947 pub extern "C" fn Input_clone(orig: &Input) -> Input {
948         orig.clone()
949 }
950 /// Generates a non-cryptographic 64-bit hash of the Input.
951 #[no_mangle]
952 pub extern "C" fn Input_hash(o: &Input) -> u64 {
953         if o.inner.is_null() { return 0; }
954         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
955         #[allow(deprecated)]
956         let mut hasher = core::hash::SipHasher::new();
957         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
958         core::hash::Hasher::finish(&hasher)
959 }
960 /// Checks if two Inputs contain equal inner contents.
961 /// This ignores pointers and is_owned flags and looks at the values in fields.
962 /// Two objects with NULL inner values will be considered "equal" here.
963 #[no_mangle]
964 pub extern "C" fn Input_eq(a: &Input, b: &Input) -> bool {
965         if a.inner == b.inner { return true; }
966         if a.inner.is_null() || b.inner.is_null() { return false; }
967         if a.get_native_ref() == b.get_native_ref() { true } else { false }
968 }
969
970 use lightning::events::bump_transaction::Utxo as nativeUtxoImport;
971 pub(crate) type nativeUtxo = nativeUtxoImport;
972
973 /// An unspent transaction output that is available to spend resulting from a successful
974 /// [`CoinSelection`] attempt.
975 #[must_use]
976 #[repr(C)]
977 pub struct Utxo {
978         /// A pointer to the opaque Rust object.
979
980         /// Nearly everywhere, inner must be non-null, however in places where
981         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
982         pub inner: *mut nativeUtxo,
983         /// Indicates that this is the only struct which contains the same pointer.
984
985         /// Rust functions which take ownership of an object provided via an argument require
986         /// this to be true and invalidate the object pointed to by inner.
987         pub is_owned: bool,
988 }
989
990 impl Drop for Utxo {
991         fn drop(&mut self) {
992                 if self.is_owned && !<*mut nativeUtxo>::is_null(self.inner) {
993                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
994                 }
995         }
996 }
997 /// Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL.
998 #[no_mangle]
999 pub extern "C" fn Utxo_free(this_obj: Utxo) { }
1000 #[allow(unused)]
1001 /// Used only if an object of this type is returned as a trait impl by a method
1002 pub(crate) extern "C" fn Utxo_free_void(this_ptr: *mut c_void) {
1003         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUtxo) };
1004 }
1005 #[allow(unused)]
1006 impl Utxo {
1007         pub(crate) fn get_native_ref(&self) -> &'static nativeUtxo {
1008                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1009         }
1010         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUtxo {
1011                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1012         }
1013         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1014         pub(crate) fn take_inner(mut self) -> *mut nativeUtxo {
1015                 assert!(self.is_owned);
1016                 let ret = ObjOps::untweak_ptr(self.inner);
1017                 self.inner = core::ptr::null_mut();
1018                 ret
1019         }
1020 }
1021 /// The unique identifier of the output.
1022 #[no_mangle]
1023 pub extern "C" fn Utxo_get_outpoint(this_ptr: &Utxo) -> crate::lightning::chain::transaction::OutPoint {
1024         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
1025         crate::c_types::bitcoin_to_C_outpoint(inner_val)
1026 }
1027 /// The unique identifier of the output.
1028 #[no_mangle]
1029 pub extern "C" fn Utxo_set_outpoint(this_ptr: &mut Utxo, mut val: crate::lightning::chain::transaction::OutPoint) {
1030         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val);
1031 }
1032 /// The output to spend.
1033 #[no_mangle]
1034 pub extern "C" fn Utxo_get_output(this_ptr: &Utxo) -> crate::c_types::TxOut {
1035         let mut inner_val = &mut this_ptr.get_native_mut_ref().output;
1036         crate::c_types::TxOut::from_rust(inner_val)
1037 }
1038 /// The output to spend.
1039 #[no_mangle]
1040 pub extern "C" fn Utxo_set_output(this_ptr: &mut Utxo, mut val: crate::c_types::TxOut) {
1041         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust();
1042 }
1043 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each
1044 /// with their lengths included, required to satisfy the output's script. The weight consumed by
1045 /// the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`].
1046 #[no_mangle]
1047 pub extern "C" fn Utxo_get_satisfaction_weight(this_ptr: &Utxo) -> u64 {
1048         let mut inner_val = &mut this_ptr.get_native_mut_ref().satisfaction_weight;
1049         *inner_val
1050 }
1051 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each
1052 /// with their lengths included, required to satisfy the output's script. The weight consumed by
1053 /// the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`].
1054 #[no_mangle]
1055 pub extern "C" fn Utxo_set_satisfaction_weight(this_ptr: &mut Utxo, mut val: u64) {
1056         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.satisfaction_weight = val;
1057 }
1058 /// Constructs a new Utxo given each field
1059 #[must_use]
1060 #[no_mangle]
1061 pub extern "C" fn Utxo_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut satisfaction_weight_arg: u64) -> Utxo {
1062         Utxo { inner: ObjOps::heap_alloc(nativeUtxo {
1063                 outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg),
1064                 output: output_arg.into_rust(),
1065                 satisfaction_weight: satisfaction_weight_arg,
1066         }), is_owned: true }
1067 }
1068 impl Clone for Utxo {
1069         fn clone(&self) -> Self {
1070                 Self {
1071                         inner: if <*mut nativeUtxo>::is_null(self.inner) { core::ptr::null_mut() } else {
1072                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1073                         is_owned: true,
1074                 }
1075         }
1076 }
1077 #[allow(unused)]
1078 /// Used only if an object of this type is returned as a trait impl by a method
1079 pub(crate) extern "C" fn Utxo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1080         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUtxo)).clone() })) as *mut c_void
1081 }
1082 #[no_mangle]
1083 /// Creates a copy of the Utxo
1084 pub extern "C" fn Utxo_clone(orig: &Utxo) -> Utxo {
1085         orig.clone()
1086 }
1087 /// Generates a non-cryptographic 64-bit hash of the Utxo.
1088 #[no_mangle]
1089 pub extern "C" fn Utxo_hash(o: &Utxo) -> u64 {
1090         if o.inner.is_null() { return 0; }
1091         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1092         #[allow(deprecated)]
1093         let mut hasher = core::hash::SipHasher::new();
1094         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1095         core::hash::Hasher::finish(&hasher)
1096 }
1097 /// Checks if two Utxos contain equal inner contents.
1098 /// This ignores pointers and is_owned flags and looks at the values in fields.
1099 /// Two objects with NULL inner values will be considered "equal" here.
1100 #[no_mangle]
1101 pub extern "C" fn Utxo_eq(a: &Utxo, b: &Utxo) -> bool {
1102         if a.inner == b.inner { return true; }
1103         if a.inner.is_null() || b.inner.is_null() { return false; }
1104         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1105 }
1106 /// Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output.
1107 #[must_use]
1108 #[no_mangle]
1109 pub extern "C" fn Utxo_new_p2pkh(mut outpoint: crate::lightning::chain::transaction::OutPoint, mut value: u64, pubkey_hash: *const [u8; 20]) -> crate::lightning::events::bump_transaction::Utxo {
1110         let mut ret = lightning::events::bump_transaction::Utxo::new_p2pkh(crate::c_types::C_to_bitcoin_outpoint(outpoint), value, &bitcoin::hash_types::PubkeyHash::from_hash(bitcoin::hashes::Hash::from_inner(unsafe { *pubkey_hash }.clone())));
1111         crate::lightning::events::bump_transaction::Utxo { inner: ObjOps::heap_alloc(ret), is_owned: true }
1112 }
1113
1114
1115 use lightning::events::bump_transaction::CoinSelection as nativeCoinSelectionImport;
1116 pub(crate) type nativeCoinSelection = nativeCoinSelectionImport;
1117
1118 /// The result of a successful coin selection attempt for a transaction requiring additional UTXOs
1119 /// to cover its fees.
1120 #[must_use]
1121 #[repr(C)]
1122 pub struct CoinSelection {
1123         /// A pointer to the opaque Rust object.
1124
1125         /// Nearly everywhere, inner must be non-null, however in places where
1126         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1127         pub inner: *mut nativeCoinSelection,
1128         /// Indicates that this is the only struct which contains the same pointer.
1129
1130         /// Rust functions which take ownership of an object provided via an argument require
1131         /// this to be true and invalidate the object pointed to by inner.
1132         pub is_owned: bool,
1133 }
1134
1135 impl Drop for CoinSelection {
1136         fn drop(&mut self) {
1137                 if self.is_owned && !<*mut nativeCoinSelection>::is_null(self.inner) {
1138                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1139                 }
1140         }
1141 }
1142 /// Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL.
1143 #[no_mangle]
1144 pub extern "C" fn CoinSelection_free(this_obj: CoinSelection) { }
1145 #[allow(unused)]
1146 /// Used only if an object of this type is returned as a trait impl by a method
1147 pub(crate) extern "C" fn CoinSelection_free_void(this_ptr: *mut c_void) {
1148         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCoinSelection) };
1149 }
1150 #[allow(unused)]
1151 impl CoinSelection {
1152         pub(crate) fn get_native_ref(&self) -> &'static nativeCoinSelection {
1153                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1154         }
1155         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCoinSelection {
1156                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1157         }
1158         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1159         pub(crate) fn take_inner(mut self) -> *mut nativeCoinSelection {
1160                 assert!(self.is_owned);
1161                 let ret = ObjOps::untweak_ptr(self.inner);
1162                 self.inner = core::ptr::null_mut();
1163                 ret
1164         }
1165 }
1166 /// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
1167 /// requiring additional fees.
1168 #[no_mangle]
1169 pub extern "C" fn CoinSelection_get_confirmed_utxos(this_ptr: &CoinSelection) -> crate::c_types::derived::CVec_UtxoZ {
1170         let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmed_utxos;
1171         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::events::bump_transaction::Utxo { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::events::bump_transaction::Utxo<>) as *mut _) }, is_owned: false } }); };
1172         local_inner_val.into()
1173 }
1174 /// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
1175 /// requiring additional fees.
1176 #[no_mangle]
1177 pub extern "C" fn CoinSelection_set_confirmed_utxos(this_ptr: &mut CoinSelection, mut val: crate::c_types::derived::CVec_UtxoZ) {
1178         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1179         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmed_utxos = local_val;
1180 }
1181 /// An additional output tracking whether any change remained after coin selection. This output
1182 /// should always have a value above dust for its given `script_pubkey`. It should not be
1183 /// spent until the transaction it belongs to confirms to ensure mempool descendant limits are
1184 /// not met. This implies no other party should be able to spend it except us.
1185 #[no_mangle]
1186 pub extern "C" fn CoinSelection_get_change_output(this_ptr: &CoinSelection) -> crate::c_types::derived::COption_TxOutZ {
1187         let mut inner_val = &mut this_ptr.get_native_mut_ref().change_output;
1188         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_TxOutZ::None } else { crate::c_types::derived::COption_TxOutZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::TxOut::from_rust(&(*inner_val.as_ref().unwrap()).clone()) }) };
1189         local_inner_val
1190 }
1191 /// An additional output tracking whether any change remained after coin selection. This output
1192 /// should always have a value above dust for its given `script_pubkey`. It should not be
1193 /// spent until the transaction it belongs to confirms to ensure mempool descendant limits are
1194 /// not met. This implies no other party should be able to spend it except us.
1195 #[no_mangle]
1196 pub extern "C" fn CoinSelection_set_change_output(this_ptr: &mut CoinSelection, mut val: crate::c_types::derived::COption_TxOutZ) {
1197         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_rust() }})} };
1198         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.change_output = local_val;
1199 }
1200 /// Constructs a new CoinSelection given each field
1201 #[must_use]
1202 #[no_mangle]
1203 pub extern "C" fn CoinSelection_new(mut confirmed_utxos_arg: crate::c_types::derived::CVec_UtxoZ, mut change_output_arg: crate::c_types::derived::COption_TxOutZ) -> CoinSelection {
1204         let mut local_confirmed_utxos_arg = Vec::new(); for mut item in confirmed_utxos_arg.into_rust().drain(..) { local_confirmed_utxos_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1205         let mut local_change_output_arg = { /*change_output_arg*/ let change_output_arg_opt = change_output_arg; if change_output_arg_opt.is_none() { None } else { Some({ { { change_output_arg_opt.take() }.into_rust() }})} };
1206         CoinSelection { inner: ObjOps::heap_alloc(nativeCoinSelection {
1207                 confirmed_utxos: local_confirmed_utxos_arg,
1208                 change_output: local_change_output_arg,
1209         }), is_owned: true }
1210 }
1211 impl Clone for CoinSelection {
1212         fn clone(&self) -> Self {
1213                 Self {
1214                         inner: if <*mut nativeCoinSelection>::is_null(self.inner) { core::ptr::null_mut() } else {
1215                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1216                         is_owned: true,
1217                 }
1218         }
1219 }
1220 #[allow(unused)]
1221 /// Used only if an object of this type is returned as a trait impl by a method
1222 pub(crate) extern "C" fn CoinSelection_clone_void(this_ptr: *const c_void) -> *mut c_void {
1223         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCoinSelection)).clone() })) as *mut c_void
1224 }
1225 #[no_mangle]
1226 /// Creates a copy of the CoinSelection
1227 pub extern "C" fn CoinSelection_clone(orig: &CoinSelection) -> CoinSelection {
1228         orig.clone()
1229 }
1230 /// An abstraction over a bitcoin wallet that can perform coin selection over a set of UTXOs and can
1231 /// sign for them. The coin selection method aims to mimic Bitcoin Core's `fundrawtransaction` RPC,
1232 /// which most wallets should be able to satisfy. Otherwise, consider implementing [`WalletSource`],
1233 /// which can provide a default implementation of this trait when used with [`Wallet`].
1234 #[repr(C)]
1235 pub struct CoinSelectionSource {
1236         /// An opaque pointer which is passed to your function implementations as an argument.
1237         /// This has no meaning in the LDK, and can be NULL or any other value.
1238         pub this_arg: *mut c_void,
1239         /// Performs coin selection of a set of UTXOs, with at least 1 confirmation each, that are
1240         /// available to spend. Implementations are free to pick their coin selection algorithm of
1241         /// choice, as long as the following requirements are met:
1242         ///
1243         /// 1. `must_spend` contains a set of [`Input`]s that must be included in the transaction
1244         ///    throughout coin selection, but must not be returned as part of the result.
1245         /// 2. `must_pay_to` contains a set of [`TxOut`]s that must be included in the transaction
1246         ///    throughout coin selection. In some cases, like when funding an anchor transaction, this
1247         ///    set is empty. Implementations should ensure they handle this correctly on their end,
1248         ///    e.g., Bitcoin Core's `fundrawtransaction` RPC requires at least one output to be
1249         ///    provided, in which case a zero-value empty OP_RETURN output can be used instead.
1250         /// 3. Enough inputs must be selected/contributed for the resulting transaction (including the
1251         ///    inputs and outputs noted above) to meet `target_feerate_sat_per_1000_weight`.
1252         ///
1253         /// Implementations must take note that [`Input::satisfaction_weight`] only tracks the weight of
1254         /// the input's `script_sig` and `witness`. Some wallets, like Bitcoin Core's, may require
1255         /// providing the full input weight. Failing to do so may lead to underestimating fee bumps and
1256         /// delaying block inclusion.
1257         ///
1258         /// The `claim_id` must map to the set of external UTXOs assigned to the claim, such that they
1259         /// can be re-used within new fee-bumped iterations of the original claiming transaction,
1260         /// ensuring that claims don't double spend each other. If a specific `claim_id` has never had a
1261         /// transaction associated with it, and all of the available UTXOs have already been assigned to
1262         /// other claims, implementations must be willing to double spend their UTXOs. The choice of
1263         /// which UTXOs to double spend is left to the implementation, but it must strive to keep the
1264         /// set of other claims being double spent to a minimum.
1265         pub select_confirmed_utxos: extern "C" fn (this_arg: *const c_void, claim_id: crate::c_types::ThirtyTwoBytes, must_spend: crate::c_types::derived::CVec_InputZ, must_pay_to: crate::c_types::derived::CVec_TxOutZ, target_feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_CoinSelectionNoneZ,
1266         /// Signs and provides the full witness for all inputs within the transaction known to the
1267         /// trait (i.e., any provided via [`CoinSelectionSource::select_confirmed_utxos`]).
1268         pub sign_tx: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionNoneZ,
1269         /// Frees any resources associated with this object given its this_arg pointer.
1270         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1271         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1272 }
1273 unsafe impl Send for CoinSelectionSource {}
1274 unsafe impl Sync for CoinSelectionSource {}
1275 pub(crate) fn CoinSelectionSource_clone_fields(orig: &CoinSelectionSource) -> CoinSelectionSource {
1276         CoinSelectionSource {
1277                 this_arg: orig.this_arg,
1278                 select_confirmed_utxos: Clone::clone(&orig.select_confirmed_utxos),
1279                 sign_tx: Clone::clone(&orig.sign_tx),
1280                 free: Clone::clone(&orig.free),
1281         }
1282 }
1283
1284 use lightning::events::bump_transaction::CoinSelectionSource as rustCoinSelectionSource;
1285 impl rustCoinSelectionSource for CoinSelectionSource {
1286         fn select_confirmed_utxos(&self, mut claim_id: lightning::chain::ClaimId, mut must_spend: Vec<lightning::events::bump_transaction::Input>, mut must_pay_to: &[bitcoin::TxOut], mut target_feerate_sat_per_1000_weight: u32) -> Result<lightning::events::bump_transaction::CoinSelection, ()> {
1287                 let mut local_must_spend = Vec::new(); for mut item in must_spend.drain(..) { local_must_spend.push( { crate::lightning::events::bump_transaction::Input { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
1288                 let mut local_must_pay_to_clone = Vec::new(); local_must_pay_to_clone.extend_from_slice(must_pay_to); let mut must_pay_to = local_must_pay_to_clone; let mut local_must_pay_to = Vec::new(); for mut item in must_pay_to.drain(..) { local_must_pay_to.push( { crate::c_types::TxOut::from_rust(&item) }); };
1289                 let mut ret = (self.select_confirmed_utxos)(self.this_arg, crate::c_types::ThirtyTwoBytes { data: claim_id.0 }, local_must_spend.into(), local_must_pay_to.into(), target_feerate_sat_per_1000_weight);
1290                 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)) })*/ })};
1291                 local_ret
1292         }
1293         fn sign_tx(&self, mut tx: bitcoin::Transaction) -> Result<bitcoin::Transaction, ()> {
1294                 let mut ret = (self.sign_tx)(self.this_arg, crate::c_types::Transaction::from_bitcoin(&tx));
1295                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1296                 local_ret
1297         }
1298 }
1299
1300 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1301 // directly as a Deref trait in higher-level structs:
1302 impl core::ops::Deref for CoinSelectionSource {
1303         type Target = Self;
1304         fn deref(&self) -> &Self {
1305                 self
1306         }
1307 }
1308 impl core::ops::DerefMut for CoinSelectionSource {
1309         fn deref_mut(&mut self) -> &mut Self {
1310                 self
1311         }
1312 }
1313 /// Calls the free function if one is set
1314 #[no_mangle]
1315 pub extern "C" fn CoinSelectionSource_free(this_ptr: CoinSelectionSource) { }
1316 impl Drop for CoinSelectionSource {
1317         fn drop(&mut self) {
1318                 if let Some(f) = self.free {
1319                         f(self.this_arg);
1320                 }
1321         }
1322 }
1323 /// An alternative to [`CoinSelectionSource`] that can be implemented and used along [`Wallet`] to
1324 /// provide a default implementation to [`CoinSelectionSource`].
1325 #[repr(C)]
1326 pub struct WalletSource {
1327         /// An opaque pointer which is passed to your function implementations as an argument.
1328         /// This has no meaning in the LDK, and can be NULL or any other value.
1329         pub this_arg: *mut c_void,
1330         /// Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
1331         pub list_confirmed_utxos: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_CVec_UtxoZNoneZ,
1332         /// Returns a script to use for change above dust resulting from a successful coin selection
1333         /// attempt.
1334         pub get_change_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_CVec_u8ZNoneZ,
1335         /// Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
1336         /// the transaction known to the wallet (i.e., any provided via
1337         /// [`WalletSource::list_confirmed_utxos`]).
1338         pub sign_tx: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionNoneZ,
1339         /// Frees any resources associated with this object given its this_arg pointer.
1340         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1341         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1342 }
1343 unsafe impl Send for WalletSource {}
1344 unsafe impl Sync for WalletSource {}
1345 pub(crate) fn WalletSource_clone_fields(orig: &WalletSource) -> WalletSource {
1346         WalletSource {
1347                 this_arg: orig.this_arg,
1348                 list_confirmed_utxos: Clone::clone(&orig.list_confirmed_utxos),
1349                 get_change_script: Clone::clone(&orig.get_change_script),
1350                 sign_tx: Clone::clone(&orig.sign_tx),
1351                 free: Clone::clone(&orig.free),
1352         }
1353 }
1354
1355 use lightning::events::bump_transaction::WalletSource as rustWalletSource;
1356 impl rustWalletSource for WalletSource {
1357         fn list_confirmed_utxos(&self) -> Result<Vec<lightning::events::bump_transaction::Utxo>, ()> {
1358                 let mut ret = (self.list_confirmed_utxos)(self.this_arg);
1359                 let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1360                 local_ret
1361         }
1362         fn get_change_script(&self) -> Result<bitcoin::Script, ()> {
1363                 let mut ret = (self.get_change_script)(self.this_arg);
1364                 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)) })*/ })};
1365                 local_ret
1366         }
1367         fn sign_tx(&self, mut tx: bitcoin::Transaction) -> Result<bitcoin::Transaction, ()> {
1368                 let mut ret = (self.sign_tx)(self.this_arg, crate::c_types::Transaction::from_bitcoin(&tx));
1369                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1370                 local_ret
1371         }
1372 }
1373
1374 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1375 // directly as a Deref trait in higher-level structs:
1376 impl core::ops::Deref for WalletSource {
1377         type Target = Self;
1378         fn deref(&self) -> &Self {
1379                 self
1380         }
1381 }
1382 impl core::ops::DerefMut for WalletSource {
1383         fn deref_mut(&mut self) -> &mut Self {
1384                 self
1385         }
1386 }
1387 /// Calls the free function if one is set
1388 #[no_mangle]
1389 pub extern "C" fn WalletSource_free(this_ptr: WalletSource) { }
1390 impl Drop for WalletSource {
1391         fn drop(&mut self) {
1392                 if let Some(f) = self.free {
1393                         f(self.this_arg);
1394                 }
1395         }
1396 }
1397
1398 use lightning::events::bump_transaction::Wallet as nativeWalletImport;
1399 pub(crate) type nativeWallet = nativeWalletImport<crate::lightning::events::bump_transaction::WalletSource, crate::lightning::util::logger::Logger>;
1400
1401 /// A wrapper over [`WalletSource`] that implements [`CoinSelection`] by preferring UTXOs that would
1402 /// avoid conflicting double spends. If not enough UTXOs are available to do so, conflicting double
1403 /// spends may happen.
1404 #[must_use]
1405 #[repr(C)]
1406 pub struct Wallet {
1407         /// A pointer to the opaque Rust object.
1408
1409         /// Nearly everywhere, inner must be non-null, however in places where
1410         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1411         pub inner: *mut nativeWallet,
1412         /// Indicates that this is the only struct which contains the same pointer.
1413
1414         /// Rust functions which take ownership of an object provided via an argument require
1415         /// this to be true and invalidate the object pointed to by inner.
1416         pub is_owned: bool,
1417 }
1418
1419 impl Drop for Wallet {
1420         fn drop(&mut self) {
1421                 if self.is_owned && !<*mut nativeWallet>::is_null(self.inner) {
1422                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1423                 }
1424         }
1425 }
1426 /// Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL.
1427 #[no_mangle]
1428 pub extern "C" fn Wallet_free(this_obj: Wallet) { }
1429 #[allow(unused)]
1430 /// Used only if an object of this type is returned as a trait impl by a method
1431 pub(crate) extern "C" fn Wallet_free_void(this_ptr: *mut c_void) {
1432         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWallet) };
1433 }
1434 #[allow(unused)]
1435 impl Wallet {
1436         pub(crate) fn get_native_ref(&self) -> &'static nativeWallet {
1437                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1438         }
1439         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWallet {
1440                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1441         }
1442         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1443         pub(crate) fn take_inner(mut self) -> *mut nativeWallet {
1444                 assert!(self.is_owned);
1445                 let ret = ObjOps::untweak_ptr(self.inner);
1446                 self.inner = core::ptr::null_mut();
1447                 ret
1448         }
1449 }
1450 /// Returns a new instance backed by the given [`WalletSource`] that serves as an implementation
1451 /// of [`CoinSelectionSource`].
1452 #[must_use]
1453 #[no_mangle]
1454 pub extern "C" fn Wallet_new(mut source: crate::lightning::events::bump_transaction::WalletSource, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::events::bump_transaction::Wallet {
1455         let mut ret = lightning::events::bump_transaction::Wallet::new(source, logger);
1456         crate::lightning::events::bump_transaction::Wallet { inner: ObjOps::heap_alloc(ret), is_owned: true }
1457 }
1458
1459 impl From<nativeWallet> for crate::lightning::events::bump_transaction::CoinSelectionSource {
1460         fn from(obj: nativeWallet) -> Self {
1461                 let mut rust_obj = Wallet { inner: ObjOps::heap_alloc(obj), is_owned: true };
1462                 let mut ret = Wallet_as_CoinSelectionSource(&rust_obj);
1463                 // 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
1464                 rust_obj.inner = core::ptr::null_mut();
1465                 ret.free = Some(Wallet_free_void);
1466                 ret
1467         }
1468 }
1469 /// Constructs a new CoinSelectionSource which calls the relevant methods on this_arg.
1470 /// This copies the `inner` pointer in this_arg and thus the returned CoinSelectionSource must be freed before this_arg is
1471 #[no_mangle]
1472 pub extern "C" fn Wallet_as_CoinSelectionSource(this_arg: &Wallet) -> crate::lightning::events::bump_transaction::CoinSelectionSource {
1473         crate::lightning::events::bump_transaction::CoinSelectionSource {
1474                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
1475                 free: None,
1476                 select_confirmed_utxos: Wallet_CoinSelectionSource_select_confirmed_utxos,
1477                 sign_tx: Wallet_CoinSelectionSource_sign_tx,
1478         }
1479 }
1480
1481 #[must_use]
1482 extern "C" fn Wallet_CoinSelectionSource_select_confirmed_utxos(this_arg: *const c_void, mut claim_id: crate::c_types::ThirtyTwoBytes, mut must_spend: crate::c_types::derived::CVec_InputZ, mut must_pay_to: crate::c_types::derived::CVec_TxOutZ, mut target_feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_CoinSelectionNoneZ {
1483         let mut local_must_spend = Vec::new(); for mut item in must_spend.into_rust().drain(..) { local_must_spend.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1484         let mut local_must_pay_to = Vec::new(); for mut item in must_pay_to.into_rust().drain(..) { local_must_pay_to.push( { item.into_rust() }); };
1485         let mut ret = <nativeWallet as lightning::events::bump_transaction::CoinSelectionSource<>>::select_confirmed_utxos(unsafe { &mut *(this_arg as *mut nativeWallet) }, ::lightning::chain::ClaimId(claim_id.data), local_must_spend, &local_must_pay_to[..], target_feerate_sat_per_1000_weight);
1486         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::bump_transaction::CoinSelection { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
1487         local_ret
1488 }
1489 #[must_use]
1490 extern "C" fn Wallet_CoinSelectionSource_sign_tx(this_arg: *const c_void, mut tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionNoneZ {
1491         let mut ret = <nativeWallet as lightning::events::bump_transaction::CoinSelectionSource<>>::sign_tx(unsafe { &mut *(this_arg as *mut nativeWallet) }, tx.into_bitcoin());
1492         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() };
1493         local_ret
1494 }
1495
1496
1497 use lightning::events::bump_transaction::BumpTransactionEventHandler as nativeBumpTransactionEventHandlerImport;
1498 pub(crate) type nativeBumpTransactionEventHandler = nativeBumpTransactionEventHandlerImport<crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::events::bump_transaction::CoinSelectionSource, crate::lightning::sign::SignerProvider, crate::lightning::util::logger::Logger>;
1499
1500 /// A handler for [`Event::BumpTransaction`] events that sources confirmed UTXOs from a
1501 /// [`CoinSelectionSource`] to fee bump transactions via Child-Pays-For-Parent (CPFP) or
1502 /// Replace-By-Fee (RBF).
1503 ///
1504 /// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction
1505 #[must_use]
1506 #[repr(C)]
1507 pub struct BumpTransactionEventHandler {
1508         /// A pointer to the opaque Rust object.
1509
1510         /// Nearly everywhere, inner must be non-null, however in places where
1511         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1512         pub inner: *mut nativeBumpTransactionEventHandler,
1513         /// Indicates that this is the only struct which contains the same pointer.
1514
1515         /// Rust functions which take ownership of an object provided via an argument require
1516         /// this to be true and invalidate the object pointed to by inner.
1517         pub is_owned: bool,
1518 }
1519
1520 impl Drop for BumpTransactionEventHandler {
1521         fn drop(&mut self) {
1522                 if self.is_owned && !<*mut nativeBumpTransactionEventHandler>::is_null(self.inner) {
1523                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1524                 }
1525         }
1526 }
1527 /// Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL.
1528 #[no_mangle]
1529 pub extern "C" fn BumpTransactionEventHandler_free(this_obj: BumpTransactionEventHandler) { }
1530 #[allow(unused)]
1531 /// Used only if an object of this type is returned as a trait impl by a method
1532 pub(crate) extern "C" fn BumpTransactionEventHandler_free_void(this_ptr: *mut c_void) {
1533         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBumpTransactionEventHandler) };
1534 }
1535 #[allow(unused)]
1536 impl BumpTransactionEventHandler {
1537         pub(crate) fn get_native_ref(&self) -> &'static nativeBumpTransactionEventHandler {
1538                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1539         }
1540         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBumpTransactionEventHandler {
1541                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1542         }
1543         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1544         pub(crate) fn take_inner(mut self) -> *mut nativeBumpTransactionEventHandler {
1545                 assert!(self.is_owned);
1546                 let ret = ObjOps::untweak_ptr(self.inner);
1547                 self.inner = core::ptr::null_mut();
1548                 ret
1549         }
1550 }
1551 /// Returns a new instance capable of handling [`Event::BumpTransaction`] events.
1552 ///
1553 /// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction
1554 #[must_use]
1555 #[no_mangle]
1556 pub extern "C" fn BumpTransactionEventHandler_new(mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut utxo_source: crate::lightning::events::bump_transaction::CoinSelectionSource, mut signer_provider: crate::lightning::sign::SignerProvider, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::events::bump_transaction::BumpTransactionEventHandler {
1557         let mut ret = lightning::events::bump_transaction::BumpTransactionEventHandler::new(broadcaster, utxo_source, signer_provider, logger);
1558         crate::lightning::events::bump_transaction::BumpTransactionEventHandler { inner: ObjOps::heap_alloc(ret), is_owned: true }
1559 }
1560
1561 /// Handles all variants of [`BumpTransactionEvent`].
1562 #[no_mangle]
1563 pub extern "C" fn BumpTransactionEventHandler_handle_event(this_arg: &crate::lightning::events::bump_transaction::BumpTransactionEventHandler, event: &crate::lightning::events::bump_transaction::BumpTransactionEvent) {
1564         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.handle_event(&event.to_native())
1565 }
1566